Assertion for shallow rendering `equals`
See original GitHub issueIt would be nice to have assertion to check node against node, equals
from shallow rendering of enzyme
(probably equalsJSX
, same to https://github.com/algolia/expect-jsx)
Now
expect(shallow(<Component />).find('SubComponent').equals(<SubComponent foo="bar" />)).to.be.true
Would like to have
expect(shallow(<Component />).find('SubComponent')).to.be.equalsJSX(<SubComponent foo="bar" />)
Issue Analytics
- State:
- Created 8 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Better assertions for shallow-rendered React components
Another particularly useful approach is to find nodes in the rendered tree which are equal to an expected node, specified by the test....
Read more >Shallow Renderer - React
Shallow rendering lets you render a component “one level deep” and assert facts about what its render method returns, without worrying about the...
Read more >Shallow Rendering API - Enzyme - GitHub Pages
Returns whether or not one of the given react elements exists in the shallow render tree. .equals(node) => Boolean. Returns whether or not...
Read more >Better assertions for shallow-rendered React components | by ...
The React TestUtils shallow rendering feature allows us to test React components in true isolation from other component classes, and removes the need...
Read more >Shallow rendering using enzyme simple test not working
You're asserting that an enzyme ShallowWrapper is equal to 3 or 0. This doesn't make sense. Instead, the ShallowWrapper that is returned ...
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
+1 for
.to.equal
i had same issue and this is my solution for it:
usage:
and nice error message:
changed code in package react-element-to-string - props wasnt sorted (not nesseseary - props order is irelevant but if changed tests would fail…)
file: index.js
cheers
edit: sorry for thread necromancy 😃