I am doing unit tests with vue-utils on the front-end of an application written in vue2.
When I run my test, I get this error: SyntaxError: Cannot use import statement outside a module
(I don't even need the problematic module in my test.)
I have looked at several answers on the subject (including adding "type": "module" in package.json or add extension ".mjs") but I always get an additional error after testing the solution. I work with node/14.19.2.
Do you have any idea? I don't know which file to show you, don't hesitate to ask me for my code
CodePudding user response:
I had a same issue and in my case the Visual Studio added (modules/js file). Check the top of your vue/javascript code, is there any imported file or not!
CodePudding user response:
I solve my issue by adding this line:
transformIgnorePatterns: [
'node_modules/(?!module_name)' ]
in my jest.config.js file