December 2019
Intermediate to advanced
474 pages
10h 3m
English
Since there are multiple ways Jest can detect which file contains a test, let's choose the structure where every component has a separate test file. This test file will have the same name as the file that holds the component, with the .test suffix. If we choose the SubHeader component, we can create a new file called SubHeader.test.js in the src/components/Header directory. Add the following code to this file:
describe('the <SubHeader /> component', () => { it('should render', () => { });});
Two global functions from Jest are used here:
Within the definition of a test, you can add assumptions such as toEqual or toBe, which check ...
Read now
Unlock full access