Hi!
I configurated jest for testing vue components:
"jest": {
"transform": {
".*.(vue)$": "/node_modules/vue-jest",
But imported nested components are not transformed and I've got a error:
FAIL src/components/card/contacts.test.js
โ Test suite failed to run
/www/spa/node_modules/components/b-button/b-button.vue:1
({"Object.
^
SyntaxError: Unexpected token <
What am I doing wrong?
PS corresponding to @eddyerburgh 's question - yes I'm importing with .vue extension.
The problem is that jest does not transform node_modules by default, and b-button is a .vue file.
The solution is to install an npm module and add a couple of lines to the Jest config:
"transformIgnorePatterns": [
"node_modules/(?!b-button)"
]
transformIgnorePatterns: says to ignore all node_modules except vue-quill-editor
You also need to install a module that passes css, because b-button. You can add extra modules if you need to.
Hooray!!! Thank you very much, it has really helped!
Most helpful comment
The problem is that jest does not transform node_modules by default, and b-button is a .vue file.
The solution is to install an npm module and add a couple of lines to the Jest config:
transformIgnorePatterns: says to ignore all node_modules except vue-quill-editorYou also need to install a module that passes css, because
b-button. You can add extra modules if you need to.