Skip to content

Commit

Permalink
Run coverage at the end of jest and configure thresholds (#8371)
Browse files Browse the repository at this point in the history
* Run coverage at the end of jest and configure thresholds

* Better configure coverage sources and remoce ratchet

* Default to no coverage, with a command to run with coverage
  • Loading branch information
oorestisime authored and m-allanson committed Sep 27, 2018
1 parent 401b8de commit bc1a79d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
16 changes: 14 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ const reGatsby = /gatsby$/
const gatsbyDir = pkgs.find(p => reGatsby.exec(p))
const gatsbyBuildDirs = [`dist`].map(dir => path.join(gatsbyDir, dir))
const builtTestsDirs = pkgs.map(p => path.join(p, `__tests__`))

const ignoreDirs = [].concat(gatsbyBuildDirs, builtTestsDirs)
const distDirs = pkgs.map(p => path.join(p, `dist`))
const ignoreDirs = [].concat(gatsbyBuildDirs, builtTestsDirs, distDirs)
const coverageDirs = pkgs.map(p => path.join(p, `src/**/*.js`))

module.exports = {
notify: true,
Expand All @@ -27,4 +28,15 @@ module.exports = {
moduleNameMapper: {
"^highlight.js$": `<rootDir>/node_modules/highlight.js/lib/index.js`,
},
collectCoverage: false,
coverageReporters: [`json-summary`, `text`, `html`],
coverageThreshold: {
global: {
lines: 42,
statements: 43,
functions: 40,
branches: 42,
},
},
collectCoverageFrom: coverageDirs,
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@
"publish-canary": "lerna publish --canary --yes",
"publish-next": "lerna publish --npm-tag=next --bump=prerelease",
"test": "npm-run-all -s lint jest",
"test:coverage": "jest --coverage",
"test:update": "jest --updateSnapshot",
"test:watch": "jest --watch",
"test:integration": "jest --config=jest.integration.js",
"test_bkup": "npm-run-all -s lint test-node test-integration",
"version": "prettier --write \"**/CHANGELOG.md\" --no-semi",
"watch": "lerna run watch --no-sort --stream --concurrency 999"
},
Expand Down

0 comments on commit bc1a79d

Please sign in to comment.