Unexpected token 'import' error while running Jest tests? Unexpected token 'import' error while running Jest tests? vue.js vue.js

Unexpected token 'import' error while running Jest tests?


You just need to make sure that vue-awesome will be transformed by jest, so add following to your jest config:

transformIgnorePatterns: ["/node_modules/(?!vue-awesome)"],

which means: "Ignore everything in node_modules except for vue-awesome.

Also here is exhausive list of other issues that might cause this error: https://github.com/facebook/jest/issues/2081


If you are encountering this problem after updating to a newer Jest version, try clearing Jest's internal cache:

jest --clearCache


We had the same issue with another library. The root cause was that we had a circular dependency in code. But the error text did not refer to it at all. just like in this post: "Jest encountered an unexpected token..."