Enzyme Testing: Mount versus Visualization

In addition, render uses the Cheerio workaround library ..

I just replaced all my mount with render , and it works the same way.
They look like me.

What should I choose? Is the two APIs somehow not identical?
What are the specific guidelines for using render over mount ?

+5
source share
2 answers

Render does not require a global DOM. Thus, it allows you to conduct tests outside the environment, such as a browser. In your case, if your test cases worked before it seemed to you that you were running tests in the browser (since the time you worked with them), and you would not need to use rendering. If, however, your tests did not run because there was no globally accessible DOM, then rendering might be a good solution.

http://airbnb.io/enzyme/docs/api/render.html

+3
source

Mount - rendering FullDom. Take a look at the official documentation for examples. From my understanding, if you want to test lifecycle events like componentDidMount, you should use mount.

Docs: http://airbnb.io/enzyme/docs/api/mount.html

0
source

All Articles