我正在尝试使用 React 组件进行简单的单元测试,但我不断得到:
C:\work\portfolio\node_modules\gsap\TweenMax.js:13
import TweenLite, { TweenPlugin, Ease, Power0, Power1, Power2, Power3, Power4, Linear } from "./TweenLite.js";
^^^^^^^^^
这是导入“App”组件第 3 方库之一的错误。
import React from "react";
import { shallow } from 'enzyme';
import App from "./App";
fit("renders without crashing", () => {
const wrapper = shallow(<App />);
});
应用程序.js
import React from "react";
import "./App.css";
import ChronologyGraph from "./chronology/ChronologyGraph";
import { nodeTypes, milestones } from "../staticData";
const App = () => (
<ChronologyGraph
width="700"
height="800"
nodeSize={10}
milestones={milestones.reverse()}
columns={nodeTypes}
/>
);
export default App;
包.json:
{
"name": "portfolio",
"version": "0.1.0",
"private": true,
"dependencies": {
"font-awesome": "^4.7.0",
"gsap": "^2.0.1",
"moment": "^2.22.2",
"prop-types": "^15.6.2",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-fontawesome": "^1.6.1",
"react-scripts": "^1.1.5",
"react-transition-group": "^2.4.0",
"typeface-lato": "0.0.54",
"typeface-roboto": "0.0.54",
"uuid": "^3.3.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"lint": "eslint src",
"test": "react-scripts test --env=jsdom",
"testCov": "react-scripts test --env=jsdom --coverage",
"eject": "react-scripts eject"
},
"devDependencies": {
"enzyme": "^3.4.4",
"enzyme-adapter-react-16": "^1.2.0",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^17.0.0",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.9.1",
"prettier-eslint": "^8.8.2"
}
}
我在网上找不到任何类似的例子,我应该以某种方式嘲笑孩子的进口吗?我认为“浅”渲染不会导入儿童,因此不会导入儿童