Not working with Jest
Closed this issue · 2 comments
lmiller1990 commented
Hi,
I installed this using the vue cli plugin found here. Works great, except when running unit tests with Jest, I get this:
FAIL tests/unit/example.spec.ts
● Test suite failed to run
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html
Details:
/Users/lachlanmiller/javascript/vue/tsx/src/components/HelloWorld.tsx:7
return (<div>Ok</div>);
any ideas?
wonderful-panda commented
vue-tsx-support itself is tested by jest.
see package.json and files under test/jest as an example.
lmiller1990 commented
Hey,
Thanks for the reply. I had a look, but I must be missing something. I was able to get it to work using babel-jest
and @babel/preset-typescript
. I also followed up here: vuejs/vue-cli#3100.
I'll close this for now, since it looks like it was something I was doing incorrectly. Thanks again, this library is excellent.