Repository navigation
React Testing and Deployment
Shallow rendering is a way to test a single React component by itself as a single unit. It's a way to make sure the component isn't influencing any parent/child/sibling components.
Use shallow rendering in test by bringing it in from Enzyme.:
import { shallow } from 'enzyme';
Then call the function like this:
const wrapper = shallow(<MyComponent />);
Use static rendering to examine the actual HTML structure of components.
Use shallow rendering in test by bringing it in from Enzyme.:
import { render } from 'enzyme';
Then call the function like this:
const wrapper = render(<MyComponent />);
Full mounting or DOM rendering is done when you have components that interact with one another.
Use shallow rendering in test by bringing it in from Enzyme:
import { mount } from 'enzyme';
Snapshot testing involves rendering your UI, saving a "snapshot" of it at that point, run a test on your component, then compare it to the snapshot.
All wiki pages are summaries of the work of others. See the top of each page for the source blogs/articles/books and their authors. All other content by Billy Bunn.