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.
This commit is contained in:
Jesse Rosenberger 2018-09-26 13:32:59 +03:00
parent 74ca606c8a
commit 549a64eec6
No known key found for this signature in database
GPG key ID: C0CCCF81AA6C08D8
4 changed files with 32 additions and 2 deletions

View file

@ -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!

4
.gitignore vendored
View file

@ -11,5 +11,9 @@ yarn-error.log*
# Coverage (from Jest)
coverage/
# JUnit Reports (used mainly in CircleCI)
reports/
junit.xml
# Node modules
node_modules/

18
package-lock.json generated
View file

@ -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",

View file

@ -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",