Showing posts with label react. Show all posts
Showing posts with label react. Show all posts

Thursday, 13 April 2017

TDD with React, couple of tutorials from semaphoreci community

https://semaphoreci.com/community/tutorials/testing-react-components-with-enzyme-and-mocha

Some notes...

Enzyme gives us several ways to render components for testing: using shallow, mount, and static. 

shallow ... is used to isolate one component for testing and ensure child components do not affect assertions. 
You can think of it as rendering "just" the component you want it to.

mount is "real" rendering that will actually render your component into a browser environment. If you are creating full React components (and not just stateless components), you will want to use mount to do testing on the lifecycle methods of your component. We are using jsdom to accomplish rendering in a browser-like environment, but you could just as easily run it in a browser of your choosing.

static ... is used for analyzing the actual HTML output of a component