Use the Command line opitions or can use test.only() to use a particular test , or test.skip() to skip a particular test.
Nesting of describe is possible, multiple describe blocks are possible , using .only() and .skip() are also possible.
instead of test() , we can use it() and .only() is fit() and .skip() is xit()
The report can be viewed in the index.html in the coverage Folder created or in the terminal itself.
To add filters on the type of files to be included in the report -
"coverage": "react-scripts test --coverage --watchAll --collectCoverageFrom='src/components/**/*.{ts,tsx}' --collectCoverageFrom='!src/components/**/*.{types, stories, constants, test, spec}.{ts,tsx}'"
To add a threshold -
"jest": {
"coverageThreshold": {
"global": {
"branches": 80,
"functions": 80,
"lines": 80,
"statements": -10
}
}
}
Refer this link for more - https://jestjs.io/docs/using-matchers
Custom matcher functions - https://github.com/testing-library/jest-dom