diff --git a/.gitignore b/.gitignore index 7235646f5e614..8cf179a8ccd9e 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ lib-cov # Coverage directory used by tools like istanbul coverage +junit.xml # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7ddefe8cffc29..fa7a5faf1c283 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -15,6 +15,8 @@ steps: - script: yarn bootstrap - script: yarn test + env: + GENERATE_JEST_REPORT: true - task: PublishTestResults@2 displayName: "Publish Test Results" diff --git a/jest.config.js b/jest.config.js index c2d5419b42b79..65ac17ebc84e6 100644 --- a/jest.config.js +++ b/jest.config.js @@ -13,6 +13,7 @@ const builtTestsDirs = pkgs 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`)) +const useCoverage = !!process.env.GENERATE_JEST_REPORT module.exports = { notify: true, @@ -31,7 +32,7 @@ module.exports = { moduleNameMapper: { "^highlight.js$": `/node_modules/highlight.js/lib/index.js`, }, - collectCoverage: true, + collectCoverage: useCoverage, coverageReporters: [`json-summary`, `text`, `html`, `cobertura`], coverageThreshold: { global: { @@ -42,5 +43,5 @@ module.exports = { }, }, collectCoverageFrom: coverageDirs, - reporters: [`default`, `jest-junit`], + reporters: [`default`].concat(useCoverage ? `jest-junit` : []), } diff --git a/package.json b/package.json index 2ba4b8856d497..9f2e6b1223b8c 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,8 @@ "glob": "^7.1.1", "husky": "1.1.1", "jest": "^23.5.0", - "jest-junit": "^5.0.0", "jest-cli": "^23.5.0", + "jest-junit": "^5.0.0", "lerna": "^3.3.0", "lint-staged": "^8.0.4", "npm-run-all": "4.1.5",