jest: Test suite failed to run, SyntaxError: Unexpected token import

前端 未结 6 1743
粉色の甜心
粉色の甜心 2020-12-01 20:44

This is my jest configuration from the package.json file:

\"jest\": {
    \"automock\": false,
    \"browser\": true,
    \"moduleNameMapper\": {
      \"\\\         


        
6条回答
  •  情话喂你
    2020-12-01 21:14

    In my case, I had the following .babelrc config:

    {
      "presets": [
        ["env", { "modules": false }],
        "react",
        "stage-2"
      ],
      "plugins": [
        "transform-runtime",
        "transform-class-properties",
        "react-hot-loader/babel"
      ]
    }
    

    Even though babel-env was specified I still got the error. To fix it I had to remove the "modules": false flag.

提交回复
热议问题