xxxxxxxxxx
// in package.json
{
"scripts": {
"coverage": "yarn test --coverage --watchAll --collectCoverageFrom='src/components/**/*.{js,jsx}' --collectCoverageFrom='!src/components/**/*{types,stories,constants,test,spec}.{js,jsx}' "
},
"jest": {
"coverageThreshold": {
"global": {
"branches": 80,
"functions": 80,
"lines": 80,
"statements": -10
}
}
}
}
xxxxxxxxxx
// Command
npm run test -- --coverage
// If you wanna watch
npm run test -- --coverage --watchAll=true
// or
npm run test -- --coverage --watchAll=true
xxxxxxxxxx
# in package.json
# "scripts": {
# "test": "jest --coverage"
# },
# using yarn
yarn test
# using npm
npm run test