June 2019
Intermediate to advanced
192 pages
4h
English
Since this chapter’s project will have three components (Carousel, CarouselButton, and CarouselSlide), it’s going to have three test files. Rather than duplicate the Enzyme configuration logic across all three, we should move that logic into a “setup file” that will only run once whenever Jest runs our tests.
Actually, we’re going to need two files: the setup file, and a Jest configuration to point to it. Let’s start with the configuration. By default, Jest looks for a file called jest.config.js in the root of the project:
| | module.exports = { |
| ① | setupTestFrameworkScriptFile: './src/tests/jestSetup.js', |
| | }; |
The setupTestFrameworkScriptFile entry tells Jest to go ahead and “Run the file called ...
Read now
Unlock full access