I am using webpack-provision-plugin to import.
new webpack.ProvidePlugin({ "React": "react", }),
//text.jsx
let text = (props) => ( <div> <p class="text">this.props.text</p> </div> ) export default text
//text.test.js
import React from 'react'; import { shallow } from 'enzyme'; import text from 'text'; it('Renders text', () => { const wrapper = shallow(<text/>); expect(wrapper.hasClass("text")).toEqual(true); });
But during the test tests of the components with a joke, I get an error
ReferenceError: React is not defined
Of course, because the reaction is not imported explicitly. Is there a way to this problem besides explicit import and refusal to provide the plugin?
source share