Jest Unit Test SyntaxError: Unexpected token import
See original GitHub issueVersions and Environment
Vuetify: 1.3.0 Vue: 2.5.17 OS: Windows 10
Previously worked in:
Vuetify: 1.2.10 Vue: 2.5.17
Steps to reproduce
Vue Create (typescript/Babel/Jest) Vue Add vuetify (default) Create jest test that involves any vuetify component
Expected Behavior
All my jest test should run
Actual Behavior
Get an error before test start to run:
location_to_project\node_modules\vuetify\lib\index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import Vuetify from './components/Vuetify';
^^^^^^
SyntaxError: Unexpected token import
1 | import Vue from 'vue'
2 | // @ts-ignore
> 3 | import * as Vuetify from 'vuetify/lib'
| ^
4 | import 'vuetify/src/stylus/app.styl'
5 |
6 | Vue.use(Vuetify, {
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:4 7)
03:17)
at Object.<anonymous> (src/plugins/vuetify.ts:3:1)
Additional Comments:
It is probable a babel transform issue with jest.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (4 by maintainers)
Top Results From Across the Web
jest: Test suite failed to run, SyntaxError: Unexpected token ...
Jest sets the env variable to test, so I had to add my presets to the env setting in .babelrc: { "plugins": ["syntax-dynamic-import", ......
Read more >How I Fixed The Unexpected Token Error In Jest
To put this in different terms, I'm using Jest to test a package with "modern" JavaScript, which in-turn imports another package with ...
Read more >"Syntax Error: Invalid or unexpected token" with .png · Issue ...
I was experiencing this on React Native as well, when attempting to jest test a file with React Navigation v5 Stack.Navigator and Stack.Screens ......
Read more >jest encountered an unexpected token this usually means that ...
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...
Read more >[Solved] SyntaxError: Unexpected token '.' Jest Error for Next.js ...
Running into the following error when trying to run unit tests for a Next.js application using the jest command: This error could be...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is a problem with your test setup, it has nothing to do with vuetify.
@KaelWD Thank you so much for all your effort, I really appreciate it a lot. Thanks so much for the changes you made.
Thanks for everything you do for the community.