我試圖讓Jest運行我的React應用程序的快照測試。從我的package.json版本:從'ReactDebugTool.js'找不到模塊'react/lib/ReactComponentTreeHook'
"react": "15.6.1",
"react-dom": "15.6.1",
"react-test-renderer": "15.6.1",
我不能讓過去的這個錯誤:
● Test suite failed to run
Cannot find module 'react/lib/ReactComponentTreeHook' from 'ReactDebugTool.js'
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:179:17)
at Object.<anonymous> (node_modules/react-test-renderer/lib/ReactDebugTool.js:16:30)
我試圖刪除並重新安裝我的node_modules DIR和我驗證過的路徑,我組件是正確的,但仍然得到這個相同的錯誤。
我的測試是這樣的:
import React from 'react';
import renderer from 'react-test-renderer';
import { Section } from '../../app/views/containers/section';
it('renders correctly',() => {
const section = renderer.create(
<Section key="1" section="finance"/>
).toJSON();
expect(section).toMatchSnapshot();
});
我在做什麼錯?