Simulate failing on after updating react and enzyme version
See original GitHub issueAfter updating enzyme version, a lot of tests seem to be failing for no reason. Here’s a change history of my packages -
react: 16.4.2 -> 16.8.4 react-dom: 16.4.2 -> 16.8.4 enzyme: 3.3.0 -> 3.9.0 enzyme-adapter-react-16: 1.1.1 -> 1.11.2 react-test-renderer: 16.8.1 - 16.8.2
-
Expected value to be truthy, instead received false 51 | sidebarComp.instance().toggle(); 52 | sidebarComp.update(); 53 | **expect(sidebarComp.state().visible).toBeTruthy();** 54 | });
toggle = () => { this.setState(prevState => { return { visible: !prevState.visible }; }); };
-
ShallowWrapper::update() can only be called when wrapping one node 37 | const expandButton = component.find('button'); 38 | expect(expandButton).toHaveLength(1); 39 | **expandButton.simulate('click');** 40 | expect(component.state().expanded).toBeTruthy(); 41 | }); 42 | });
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Simulate failing on after updating react and enzyme version
After updating enzyme version, a lot of tests seem to be failing for no reason. Here's a change history of my packages -...
Read more >React input onchange simulation not updating value using ...
the problem is that simulation of the event is not updating state. I tried wrapper.update() as well but it is not working. you...
Read more >Change Log · Enzyme - GitHub Pages
explain why need to re-call .find() after update (#2140); shallow : fix childAt (#2134); Update v2 -> v3 migration guide re props after...
Read more >enzyme-adapter-react-15 - npm
JavaScript Testing utilities for React. Latest version: 1.4.4, last published: 2 months ago. Start using enzyme-adapter-react-15 in your ...
Read more >Continuous integration for React applications using Jest and ...
npm install --save-dev enzyme enzyme-adapter-react-16 ... object to simulate a click event sent by the browser when the button is clicked.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@anmoltw : I got it. You have to wrap map(JSX) output with
<Fragment>
or<>
where as I didnt see any issue with SideBar testingHere you go ==> https://codesandbox.io/s/w6183xxjr8 Refer: Hello.js : Line: 19,25 (wrapping)
I prefer to use props().onClick over simulate (thats Ok for this case) when using shallow mount (which I love too) Please let me know if any other issue after suggested change.
@ljharb Please add explanation/extra details if I missed any.
@anmoltw sorry for the delay; can you prepare a new sandbox that highlights the remaining issue?