vue-signature
vue-signature copied to clipboard
Using Jest: Cannot use import statement outside a module
Test suite failed to run
.........\node_modules\vue-signature\src\main.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import VueSignature from './components/vueSignature.vue'
^^^^^^
SyntaxError: Cannot use import statement outside a module
When i use jest, i'm getting this errror, even when the parent component is shallow mounted. When i just serve or build this, i'm not getting this error
I am getting this error with nuxt. But not right away. Only after like 2 minutes does the error come. Once it arrived it doesn't go away. Super weird.
I also had this issue with Jest. May not fit your exact use case, but the solution for me was to set an exclusion to this package for the transformIgnorePatterns
in my jest.config.js
like so:
transformIgnorePatterns: ['/node_modules/(?!vue-signature)'],
This was recommended in the testing config docs for @vue/cli-plugin-unit-jest
https://www.npmjs.com/package/@vue/cli-plugin-unit-jest