Besides render
uses "traversal library Cheerio"..
I've just replaced all my mount
's with render
's and it works the same.
They look similar to me.
What should I choose? Is API of those two is somehow not identical?
What are particular recommendations when to use render
over mount
?
The Mount method in Enzyme renders the full DOM, including the parent component's child component on which we are running the tests. It tests the life cycle methods of your React application, allowing testing the state, props, and everything else that makes the lifecycle of a React application.
What to do when you want to test that a function is been called, on componentDidMount() React lifecycle Method. Basically the component code looks like this: state = { randomStateToPopulate: [] }; // Test componentDidMount componentDidMount() { this. randomFunction(); } randomFunction= () => { listRandomData().
Shallow rendering lets you render a component “one level deep” and assert facts about what its render method returns, without worrying about the behavior of child components, which are not instantiated or rendered. This does not require a DOM.
Render testing is a periodic load test and calibration of a mooring winch brake at a load based on the Equipment Number (EN) assigned to the ship. Why do we render test? When moored, winch brakes and lines are expected to keep the vessel safely alongside.
Render doesn't need a global DOM to be available. So it allows the tests to be run outside of an environment like a browser. In your case, if your test cases were working before it would seem you are running the tests in a browser (since mount worked) and you wouldn't need to use render. If however, your tests were failing because there was no global DOM available, then render might be a good solution
http://airbnb.io/enzyme/docs/api/render.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With