Open baffalop opened 2 years ago
It looks like the generic *.vue
shim is the problem - I'm fairly sure we have tests for the actual feature you are describing.
Can you try configuring isolatedModules
? https://huafu.github.io/ts-jest/user/config/isolatedModules to ignore this error?
You will lose some type safety, but it should work. This is what I do. I then run vue-tsc
in another process/as part of my CI pipeline, or rely on Volar, to get the actual type checks.
I have the same problem, it is not possible to use named import from a .vue file in a unit test file. Indeed the generic shim ^.+\\.vue$
doesn't allow named import.. If anyone has a solution I'm listening (except "move the export to another file")
Are you even allowed to have a named export in script setup
? According to the docs, this isn't supported: https://vuejs.org/api/sfc-script-setup.html#usage-alongside-normal-script (I could be wrong, I haven't tried this - I just assumed it wasn't meant to work).
I know it "kind of" works with vue-tsc and Volar (eg, types), but is it actually valid code when exporting an actual JS object?
I'm using
vue-jest
4.0.1 with@jest/core
26.6.3 (viavue-cli-service test
).I can't seem to import named exports from a Vue SFC. For example, in my vue file I have:
And in my test, I have:
When running the test I get a typescript error:
The same happens for named exports that are values, not types.
Config
The relevant parts of
jest.config.js
are: