May 2019
Intermediate to advanced
496 pages
10h 38m
English
The next test introduces some new concepts, so we'll break it down into its component parts. To start, add ReactTestUtils to your list of imports in test/CustomerForm.test.js:
import ReactTestUtils from 'react-dom/test-utils';
Then, begin your test with the following outline:
it('saves existing first name when submitted', async () => { expect.hasAssertions();});
There are two new pieces of functionality here.
The async keyword appears on the first line, just before our test function definition. This tells Jest that the test will return a promise, and that the test runner should wait for that promise to resolve before reporting on the success or failure of the test.
The hasAssertions expectation tells Jest that ...
Read now
Unlock full access