From d1dac0ecb083a1d0498d6f9a92fd658d71c441cd Mon Sep 17 00:00:00 2001 From: William Killerud Date: Thu, 8 Mar 2018 08:35:52 +0100 Subject: [PATCH] infra: Add coverage reporting to CI build (#7) This commit introduces a new test script for CI that includes coverage reporting with Jest and Coveralls. It also uses Jests `--ci` option. From the docs: > When this option is provided, Jest will assume it is running in a CI > environment. This changes the behavior when a new snapshot is > encountered. Instead of the regular behavior of storing a new > snapshot automatically, it will fail the test and require Jest to be > run with `--updateSnapshot`. The result from the coverage report is piped to a `coveralls` util which takes care of submitting the coverage report to Coveralls and further on to Github. Travis will use this new CI script so we get Coveralls reporting on pull requests. --- .gitignore | 1 + .travis.yml | 2 +- package.json | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index fd918e9926..9b0e6ae6e7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ node_modules # Built files +coverage/ dist/ lib/ src/styleguidist.html diff --git a/.travis.yml b/.travis.yml index 60cd335566..f0153ed481 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,4 +6,4 @@ cache: - "node_modules" script: - npm run build - - npm test + - npm run test:ci diff --git a/package.json b/package.json index cbdce5ce52..f87acaba8b 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "styleguidist:server": "styleguidist server", "styleguidist:build": "styleguidist build", "test": "jest", + "test:ci": "jest --ci --coverage && cat ./coverage/lcov.info | coveralls && rimraf ./coverage", "test:watch": "jest --watch" }, "devDependencies": { @@ -41,6 +42,7 @@ "babel-preset-react": "^6.24.1", "babel-preset-stage-3": "^6.24.1", "case": "^1.5.4", + "coveralls": "^3.0.0", "css-loader": "^0.28.7", "enzyme": "^3.3.0", "enzyme-adapter-react-16": "^1.1.1",