【发布时间】:2018-12-01 03:07:19
【问题描述】:
有没有一种简单的方法来配置 Create React App 以便它使用预先配置的 Jest 来使用 ES6 模块 不弹出?我正在将基础站点导入项目中。当我为 App 组件运行第一个测试时,我收到以下错误:
FAIL src/App/App.test.js
Test suite failed to run
/node_modules/foundation-sites/dist/js/npm.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import $ from 'jquery';
^^^^^^
SyntaxError: Unexpected token import
我尝试安装 babel-jest 并添加一个带有预设的 .babelrc 文件:["react", "es2015"] 没有运气。如果您的 node_modules 之一使用 JS 模块,我不知道其他人是否使用 Create-React-App 开玩笑测试取得了任何成功。
【问题讨论】:
标签: javascript reactjs jestjs create-react-app es6-modules