How to do it...

We want to measure how thorough our testing is, so let's look at the necessary steps. When working with Node, we directly invoked the jest command. Here, however, as the application was built by create-react-app, we'll have to work a bit differently. We'll have to add a new script to package.json that will invoke our tests with extra parameters:

"scripts": {
.
.
.
"test": "react-app-rewired test --env=jsdom",
"coverage": "react-app-rewired test --env=jsdom --coverage --no-cache",
.
.
.
}

The --coverage option will produce a coverage report, and also generate a /coverage directory, in the same way as with Node, and the --no-cache option will force Jest to regenerate all results instead of depending on previously, possibly no longer valid, cached values.

Our .gitignore file includes a line reading /coverage, so the generated files won't be pushed to the Git server.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.40.189