Babel unexpected token import when running mocha tests

前端 未结 17 1485
Happy的楠姐
Happy的楠姐 2020-11-27 14:40

The solutions offered in other related questions, such as including the proper presets (es2015) in .babelrc, are already implemented in my project.

I have two projec

17条回答
  •  粉色の甜心
    2020-11-27 15:01

    I ran into that same issue. Having tried every other solution on stackoverflow and beyond, adding this simple config on package.json did it for me:

      "babel": {
        "presets": [
          "es2015"
        ]
      }
    

    All my ES6 imports worked after that. By the way, I had this same configuration inside webpack.config.js, but apparently this was the only way to make it work for mocha testing as well.

    Hope this helps someone.

提交回复
热议问题