From 549a64eec62be26c48d53aee779c677ce1146aa2 Mon Sep 17 00:00:00 2001 From: Jesse Rosenberger Date: Wed, 26 Sep 2018 13:32:59 +0300 Subject: [PATCH] Add support for Jest JUnit test output for consumption by CircleCI. This should hopefully make it easier to quickly identify failing tests within the CircleCI interface since CircleCI will be able to programmatically consume the test results. --- .circleci/config.yml | 9 ++++++++- .gitignore | 4 ++++ package-lock.json | 18 ++++++++++++++++++ package.json | 3 ++- 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 9cafe5bb..df93f897 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -39,8 +39,15 @@ common_test_steps: &common_test_steps # This should cache the npm cache instead of node_modules, which is needed because # npm ci actually removes node_modules before installing to guarantee a clean slate. - ~/.npm - - run: npm run test:ci + - run: + command: npm run test:ci + environment: + JEST_JUNIT_OUTPUT: "reports/junit/js-test-results.xml" - run: npm run coverage:upload + - store_test_results: + path: reports/junit + - store_artifacts: + path: reports/junit # Important! When adding a new job to `jobs`, make sure to define when it # executes by also adding it to the `workflows` section below! diff --git a/.gitignore b/.gitignore index 84093d1d..842a0b9f 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,9 @@ yarn-error.log* # Coverage (from Jest) coverage/ +# JUnit Reports (used mainly in CircleCI) +reports/ +junit.xml + # Node modules node_modules/ diff --git a/package-lock.json b/package-lock.json index e1fc3caa..24d8bbcc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7485,6 +7485,18 @@ } } }, + "jest-junit": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/jest-junit/-/jest-junit-5.1.0.tgz", + "integrity": "sha512-3EVf1puv2ox5wybQDfLX3AEn3IKOgDV4E76y4pO2hBu46DEtAFZZAm//X1pzPQpqKji0zqgMIzqzF/K+uGAX9A==", + "dev": true, + "requires": { + "jest-validate": "^23.0.1", + "mkdirp": "^0.5.1", + "strip-ansi": "^4.0.0", + "xml": "^1.0.1" + } + }, "jest-leak-detector": { "version": "23.6.0", "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-23.6.0.tgz", @@ -12946,6 +12958,12 @@ "async-limiter": "~1.0.0" } }, + "xml": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz", + "integrity": "sha1-eLpyAgApxbyHuKgaPPzXS0ovweU=", + "dev": true + }, "xml-name-validator": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz", diff --git a/package.json b/package.json index aa9c5507..954df786 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "test": "jest --verbose", "posttest": "npm run lint", "testonly": "npm test", - "test:ci": "npm run coverage -- --ci --maxWorkers=2", + "test:ci": "npm run coverage -- --ci --maxWorkers=2 --reporters=default --reporters=jest-junit", "coverage": "npm test -- --coverage", "coverage:upload": "codecov" }, @@ -90,6 +90,7 @@ "hapi": "17.6.0", "husky": "0.14.3", "jest": "23.6.0", + "jest-junit": "^5.1.0", "jest-matcher-utils": "23.6.0", "js-sha256": "0.9.0", "koa": "2.5.3",