Test Vue with Jest fail, Jest encountered an unexpected token, SyntaxError: Unexpected token import

前端 未结 2 808
粉色の甜心
粉色の甜心 2020-12-21 18:16

I test Vue project with jest, bug I got errors says:

Jest encountered an unexpected token and SyntaxError: Unexpected token import

相关标签:
2条回答
  • 2020-12-21 18:24

    Most probably when updating package dependency, "babel-core" dependency may have been updated to 6.xx.x, it should be "7.0.0-bridge.0" for jest to work.

    Reference: https://github.com/vuejs/vue-cli/issues/1879#issuecomment-412300256 https://github.com/vuejs/vue-cli/issues/1879#issuecomment-435194932

    0 讨论(0)
  • 2020-12-21 18:34

    I had a similar problem and "babel-plugin-transform-es2015-modules-commonjs" is working for me

    npm i -D babel-plugin-transform-es2015-modules-commonjs

    .babelrc config "plugins":["transform-es2015-modules-commonjs"]

    0 讨论(0)
提交回复
热议问题