【发布时间】:2018-06-09 20:21:50
【问题描述】:
我使用 create-react-app 创建了一个新的 react 应用,并添加了几个简单的组件和测试。使用“npm test”运行测试时,它们运行良好。在开玩笑运行时,在测试中使用导入的组件时,我得到“意外令牌”。例如:
import React from 'react';
import { shallow } from 'enzyme';
import App from './App';
it('renders without crashing', () => {
shallow(<App />);
});
测试中 App 的使用给出了错误,但仅在运行 jest 时。
【问题讨论】:
-
你开什么玩笑?当你运行
npm test时 create-react-app 使用 jest -
大部分时间只是在玩。试图找出差异。看起来 create-react-app 在 package.json 中创建了一些名为“react-scripts test --env=jsdom”的东西。我猜这在下面使用玩笑?我想要更多的控制,因为它与观察者一起运行,我并不总是想这样做。我也想要报道
标签: javascript node.js reactjs jestjs