While writing the test case in JEST for React file I am getting this error. Following is my sample code:
search_basr_test.js
jest.autoMockOff();
global.React = require('react/addons');
jest.setMock('../stores/browser_store.jsx');
beforeEach(function() {
var search_bar = require('../components/search_bar.jsx');
});
var TestUtils = React.addons.TestUtils;
describe("Test", function() {
it("should render Test", function() {
var test = TestUtils.renderIntoDocument(<search_bar/>);
expect(test).toBeDefined();
});
it("renders a list in a box with proper CSS classes", function() {
var test = TestUtils.renderIntoDocument(<search_bar/>);
let box = TestUtils.findRenderedDOMComponentWithTag(test, "div");
expect(box.className).toEqual("sidebar__collapse");
});
});
search_bar.jsx
return (
<div>
<div
className='sidebar__collapse'
onClick={this.handleClose}
>
<span className='fa fa-angle-left'></span>
</div>
<span
className='search__clear'
onClick={this.clearFocus}
>
{'Cancel'}
</span>
}
Anyone out there to help me out from this??