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

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

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

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


        
6条回答
  •  Happy的楠姐
    2020-12-01 21:09

    Each yearly preset only compiles what was ratified in that year. babel-preset-env replaces es2015, es2016, es2017, latest

    Based on this, on latest configurations you must use/replace your Plugins/Preset of es2015 and any esX to the new one: env.

    1. You must install babel-preset-env with npm install.
    2. In your .babelrc you should update accordingly:
    {
      "presets": [
        "env", 
        "stage-0", 
        "react-native"
      ],
      "plugins": ...
    }
    

    More information on Babel plugins official Documentation.

    ☝️ Remember the order of the plugins/preset in the array is important.

提交回复
热议问题