Skip to content
This repository has been archived by the owner on Dec 4, 2024. It is now read-only.

support for vue-jest@v5 #23

Open
kazupon opened this issue Dec 21, 2020 · 2 comments · May be fixed by #43
Open

support for vue-jest@v5 #23

kazupon opened this issue Dec 21, 2020 · 2 comments · May be fixed by #43
Labels
help wanted Extra attention is needed Type: Feature Includes new features

Comments

@kazupon
Copy link
Member

kazupon commented Dec 21, 2020

No description provided.

@kazupon kazupon added help wanted Extra attention is needed Type: Feature Includes new features labels Dec 21, 2020
@XavierChevalier
Copy link

It does not seem to support version 5.
When I try to run tests, I have this exception:

 ● Test suite failed to run

  TypeError: codes.forEach is not a function

    at node_modules/@vue/vue3-jest/lib/generate-code.js:70:13
        at Array.forEach (<anonymous>)
    at generateCode (node_modules/@vue/vue3-jest/lib/generate-code.js:69:24)
    at Object.module.exports [as process] (node_modules/@vue/vue3-jest/lib/process.js:171:18)
    at ScriptTransformer.transformSource (node_modules/@jest/transform/build/ScriptTransformer.js:620:31)
    at ScriptTransformer._transformAndBuildScript (node_modules/@jest/transform/build/ScriptTransformer.js:766:40)
    at ScriptTransformer.transform (node_modules/@jest/transform/build/ScriptTransformer.js:823:19)

With this Jest configuration:

{
  // ...
  transform: {
    '^.+\\.ts$': 'ts-jest',
    '^.+\\.vue$': '@vue/vue3-jest',
  },
  globals: {
    'vue-jest': {
      transform: {
        i18n: 'vue-i18n-jest',
      },
    },
}

It's fail here:

https://github.com/vuejs/vue-jest/blob/6edfa9cd93be05ca4c9c41849db668dbf2ae92d5/packages/vue3-jest/lib/generate-code.js#L70-L72

I tried to debug, and the value of variable codes is a string:

"undefined.__i18n = ['{"en":{...},"fr":{...}}']"

This string is not iterable here.

My dependencies version:

"devDependencies": {
  "@babel/core": "^7.16.0",
  "@intlify/vite-plugin-vue-i18n": "^3.2.1",
  "@intlify/vue-i18n-loader": "^4.0.1",
  "@vue/test-utils": "^2.0.0-rc.16",
  "@vue/vue3-jest": "^27.0.0-alpha.4",
  "babel-loader": "^8.2.3",
  "jest": "^27.4.1",
  "ts-jest": "^27.0.7",
  "typescript": "^4.4.3",
  "vue-i18n-jest": "^1.1.1",
  "vue-loader": "^16.8.3",
  "vue-tsc": "^0.3.0"
}

@XavierChevalier
Copy link

XavierChevalier commented Nov 30, 2021

After investigating, I tried to change the code to be compatible with vue-jest@5. I will open a PR soon.

Several changes are to be expected:

XavierChevalier pushed a commit to XavierChevalier/vue-i18n-jest that referenced this issue Nov 30, 2021
@XavierChevalier XavierChevalier linked a pull request Nov 30, 2021 that will close this issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted Extra attention is needed Type: Feature Includes new features
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants