question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jest Unit Test SyntaxError: Unexpected token import

See original GitHub issue

Versions 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:closed
  • Created 5 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

5reactions
KaelWDcommented, Oct 23, 2018

This is a problem with your test setup, it has nothing to do with vuetify.

1reaction
JeremyWalterscommented, Oct 26, 2018

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found