"devDependencies": {
"@babel/core": "^7.8.4",
"@babel/preset-env": "^7.8.4",
"@babel/preset-react": "^7.8.3",
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"react": "^15.3.1",
"redux-mock-store": "^1.5.4"
}
//Test.js
import React from "react";
import { render, unmountComponentAtNode } from "reactdom";
import { shallow,mount } from "enzyme";`enter code here`
import {Provider} from 'react-redux'
import configureMockStore from 'redux-mock-store';
import App from "../../App";
let container = null;
let mockStore = configureMockStore()
beforeEach(() => {
container = document.createElement("div");
document.body.appendChild(container);
});
afterEach(() => {
unmountComponentAtNode(container);
container.remove();
container = null;
});
it('It RENDERS WITHOUT CRASHING', () => {
})```
Я получаю эту ошибку
● Не удалось запустить набор тестов. Я пытался настроить jest и babelr c, но у меня ничего не получалось. Он работает нормально для компонентов с чистой реакцией, но выдает ошибку, когда я начинаю тестировать компоненты с использованием магазина redux.
Cannot find module 'react' from 'Provider.js'
However, Jest was able to find:
'components/Provider.js'
You might want to include a file extension in your import, or update your 'moduleFileExtensions', which is currently ['web.js', 'js', 'web.ts', 'ts', 'web.tsx', 'tsx', 'json', 'web.jsx', 'jsx', 'node'].
See https://jestjs.io/docs/en/configuration#modulefileextensions-array-string
at Resolver.resolveModule (node_modules/jest-resolve/build/index.js:259:17)
at Object.<anonymous> (../../node_modules/react-redux/lib/components/Provider.js:10:38)