Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue compat with Jest: "TypeError: decode_js.EntityDecoder is not a constructor" #10609

Open
baffalop opened this issue Mar 28, 2024 · 2 comments

Comments

@baffalop
Copy link

baffalop commented Mar 28, 2024

Vue version

3.4.21 (with @vue/compat 3.4.21)

Link to minimal reproduction

https://stackblitz.com/edit/vue2-jest-8qoex3?file=jest.config.js&view=editor

Steps to reproduce

yarn install
yarn test

What is expected?

I would like to run unit tests with Vue Test Utils, while on the migration build. My application has Vue 2 dependencies which cause unit tests to fail when they are run with Vue 3. I would expect to be able to use the migration build to fix this by aliasing vue to @vue/compat via moduleNameMapper. (This is the approach recommended by vue-test-utils-compat though the minimal reproduction uses latest @vue/test-utils.)

What is actually happening?

Running tests with moduleNameMapper: { '^vue$': '@vue/compat' } causes the following TypeError:

TypeError: decode_js.EntityDecoder is not a constructor
...
at new Tokenizer (node_modules/@vue/compat/dist/vue.cjs.js:13619:28)
      at Object.<anonymous> (tests/unit/example.spec.ts:6:22)

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.18.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.3 - /usr/local/bin/pnpm
  npmPackages:
    vue: ^3.3.4 => 3.4.21 

Any additional comments?

This is the same error as in #10148 though it doesn't affect me at build- or runtime, only in Jest.

@baffalop
Copy link
Author

baffalop commented Mar 28, 2024

Update: I was mistaken about versions. My ^3.3.4 actually resolved to 3.4. When I pin both vue and @vue/compat to ~3.3.4 the issue goes away. This fits with #10148 which reports the error as only present on 3.4, not 3.3.

@codeonmoon
Copy link

Is there any update on this issue further, I am also getting this issue in my project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants