我正在使用Jest和Enzyme(前者有一段时间,只是从后者开始)。
我package.json
的相关版本:
"devDependencies": {
"enzyme": "^2.8.2",
"jest": "^19.0.2",
"react-addons-test-utils": "^15.5.1",
"react-dom": "^15.4.2",
"react-test-context-provider": "^2.1.2",
"react-test-renderer": "^15.4.2"
},
我尝试运行的测试的简化版本:
import React from 'react';
import { shallow, mount, render } from 'enzyme';
import Dashboard from '../../../javascript/components/ecosystems/Dashboard';
describe('<Dashboard />', () =>{
it('renders', () => {
const wrapper = shallow(
<Dashboard routeParams={{}} />,
{
context: {
executeAction: () => {},
}
}
);
expect(wrapper).toMatchSnapshot();
});
});
这不会给我任何错误,但警告:
Ran all test suites matching "Dashboard.test.js". console.error node_modules/fbjs/lib/warning.js:36 Warning: ReactTestUtils has been moved to react-dom/test-utils. Update references to remove this warning.
但我正在尝试使用Enzyme而不是React的TestUtils。如何删除此警告?