I'm new to Jest and vue-jest
. Just trying to get basic tests working.
In my bootstrap.js
file (this file will, ideally, be loaded for all tests), I attempt to register the 3rd party component vue-picture-input
:
import PictureInput from 'vue-picture-input';
Vue.component('picture-input', PictureInput);
(This is part of a standard file (bootstrap.js
) file I use for my entire project.) But Jest gives me the following error:
Details:
/home/vagrant/Code/Patrol/node_modules/vue-picture-input/PictureInput.vue:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){<template>
^
SyntaxError: Unexpected token <
85 | // ...
86 |
> 87 | import PictureInput from 'vue-picture-input';
| ^
88 | Vue.component('picture-input', PictureInput);
I've taken a look at similar questions on Stack Overflow for this error, but I can't seem to decipher what is going on or what I need to change. Seems like this answer addresses a similar issue, but I don't know how to adapt the solution for this particular issue (or if it's even close, to be honest).
Currently, the "jest" section of my package.json
file reads:
"jest": {
"moduleFileExtensions": [
"js",
"json",
"vue"
],
"moduleNameMapper": {
"\\.(css|scss|sass|less)$": "<rootDir>/tests/js/config/cssLoader.js"
},
"transform": {
".*\\.(vue)$": "vue-jest",
"^.+\\.js$": "<rootDir>/node_modules/babel-jest"
}
}
Not sure where to go from here...