When I run, npm run test -- -u, in the command line, the test is failing. It says that it expects true when it receives false.
The problem is that .hasClass is not finding 'classname2' inside the wrapper that has the class 'classname'.
I have a wrapper.debug() in the code which shows the markup being printed out. The code the debug() function prints out is below, as well as the Jest unit test I wrote.
Why is it not working?
<div className="progress-bar-component"> <div className="range text-center"> 25 of 100 </div> <Progress value="25" color="danger" striped={true} animated={true} tag="div" max={100} /> </div> it('passes in the correct value', () => { const wrapper = shallow(<Component />); console.log(wrapper.debug()); expect(wrapper.find('.classname).hasClass('classname2')).toEqual(true); }); The jest error message is:
expect(received).toEqual(expected)
Expected value to equal: true Received: false 6 Reset to default