【发布时间】:2018-04-12 06:20:01
【问题描述】:
我尝试在我的项目中使用 Jest 与 bablejs 和 ES2017,根据 Jest Getting Started 页面和 Bablejs config for ES2017 这是我的 .babelrc 文件:
{
"presets": ["es2017"],
"env": {
"test": {
"presets": ["es2017"]
}
}
}
我的包 json 是:
{
"name": "",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest"
},
"repository": {
"type": "git",
"url": ""
},
"author": "",
"license": "ISC",
"bugs": {
"url": ""
},
"homepage": "",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-jest": "^21.2.0",
"babel-polyfill": "^6.26.0",
"babel-preset-es2017": "^6.24.1",
"jest": "^21.2.1"
}
}
并且知道当我输入 npm test 以开玩笑地运行我的所有测试时,我得到了这些错误:
){import StateList from './StateList';
^^^^^^
SyntaxError: Unexpected token import
这意味着它不知道import,我在SF上搜索但没有任何解决方案解决我的问题
【问题讨论】:
标签: node.js babeljs jestjs ecmascript-2017