2

I am running a Vue/Typescript/Vuetify project(Created with vue cli 3). For unit testing I am using Jest. I upgraded to a newer version of Vuetify(1.3.1). Since the upgrade I get an error when running my Jest tests:

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

Versions and Environment

Vuetify: 1.3.0 Vue: 2.5.17

Previously worked in:

Vuetify: 1.2.10 Vue: 2.5.17

babel.config.js

module.exports = {
  presets: [
        [
            "@vue/app",
            {
                useBuiltIns: "entry"
            }
    ],
  ],
};

tsConfig Compiler:

"target": "esnext"

"module": "esnext"

1
  • I get the same error when I try the import your way in version 1.1.13. I'm not sure why this had ever worked before. Commented Oct 23, 2018 at 13:28

2 Answers 2

3

I encountered same problem.
but, I could workaround by below.

import Vuetify from 'vuetify'

just remove "/lib"

Sign up to request clarification or add additional context in comments.

3 Comments

When I followed your advice, I got rid of the error regarding that line. However, an error was detected on the next line: import 'vuetify/src/stylus/app.styl'. Also, it seams a bit scary to make changes in Vuetify package...
Why do you need to import style(like css)? How about removing it?
Thank you! I found the root of the problem: the component, which I was testing, imported an event bus from main.js and it was the Vuetify import in this main.js file, which created the problem. I restructured my code so that the component does not import from main.js any more
0

I had a similar (odd) issue. Found an answer in this thread.

The solution was to run

npx jest --clearCache

and the tests worked after that.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.