我正在尝试在 Jest 中运行基本的“安装 React 组件”测试。测试是
test("Create App component", () => {
const div = document.createElement("div");
ReactDOM.render(<App />, div);
ReactDOM.unmountComponentAtNode(div);
});
测试基础设施是使用create-react-app
.
该App
组件有一个使用组件的子react-vis
组件。
当我尝试运行测试时,出现以下错误
import _AbstractSeries from './plot/series/abstract-series';
^^^^^^^^^^^^^^^
SyntaxError: Unexpected identifier
2 | import PropTypes from "prop-types";
3 | import { withStyles } from "@material-ui/core/styles";
> 4 | import {
| ^
5 | AreaSeries,
6 | Crosshair,
7 | CustomSVGSeries,
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)
at Object.<anonymous> (src/components/Charts/MyCustomChart.js:4:1)
关于如何让这个测试工作的任何建议?