Skip to content

Commit

Permalink
Introduce minimum test coverage thresholds, coveralls.io for threshol…
Browse files Browse the repository at this point in the history
…d reporting and repo badge (#185)

* chore(deps): install coveralls

* feat(readme): add coveralls badge to readme

* feat(coveralls): configure jest to collect test coverage info and report it to coveralls.io

* fix(jest): only collect coverage from TS files, bump threshold to 14%

* fix(jest): restore test coverage behavior

This reverts commit e2909d8.
  • Loading branch information
liangyuanruo authored Aug 25, 2020
1 parent e6c7221 commit 31555c8
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,7 @@ tmp/
# @shelf/jest-mongodb generated file
# =======
globalConfig.json

# Tests
# =======
coverage/
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# FormSG

[![Build Status](https://travis-ci.com/opengovsg/formsg.svg?branch=release)](https://travis-ci.com/opengovsg/formsg)
[![Coverage Status](https://coveralls.io/repos/github/opengovsg/FormSG/badge.svg?branch=develop)](https://coveralls.io/github/opengovsg/FormSG?branch=develop)

## Table of Contents

Expand All @@ -10,6 +11,7 @@
- [Prerequisites](#prerequisites)
- [Running Locally](#running-locally)
- [Environment variables](#environment-variables)
- [Trouble-shooting](#trouble-shooting)
- [Testing](#testing)
- [Testing Prerequisites](#testing-prerequisites)
- [Running tests](#running-tests)
Expand Down
7 changes: 7 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,11 @@ module.exports = {
// Needed to use @shelf/jest-mongodb preset.
...tsJestPreset.transform,
},
collectCoverageFrom: ['./src/**/*.{ts,js}'],
coveragePathIgnorePatterns: ['./node_modules/', './tests'],
coverageThreshold: {
global: {
statements: 12, // Increase this percentage as test coverage improves
},
},
}
25 changes: 25 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
"dev": "docker-compose up --build",
"docker-dev": "npm run build-frontend-dev & ts-node-dev --respawn --transpileOnly --inspect=0.0.0.0 -- src/server.ts",
"test-backend": "npm run test-backend-jasmine && npm run test-backend-jest",
"test-backend-jest": "env-cmd -f tests/.test-full-env jest",
"test-backend-jest": "env-cmd -f tests/.test-full-env jest --coverage",
"test-backend-jest:watch": "env-cmd -f tests/.test-full-env jest --watch",
"test-backend-jasmine": "env-cmd -f tests/.test-full-env --use-shell \"npm run download-binary && jasmine --config=tests/unit/backend/jasmine.json\"",
"test-frontend": "jest --config=tests/unit/frontend/jest.config.js",
"test-ci": "npm run test-backend && npm run test-frontend",
"test-ci": "npm run test-backend && npm run test-frontend && coveralls < coverage/lcov.info",
"test": "npm run build-backend && npm run test-backend && npm run test-frontend",
"test-e2e-build": "npm run build-backend && npm run build-frontend-dev",
"test-run": "concurrently --success last --kill-others \"mockpass\" \"maildev\" \"node dist/backend/server.js\" \"localstack start --host\"",
Expand Down Expand Up @@ -190,6 +190,7 @@
"concurrently": "^3.6.1",
"copy-webpack-plugin": "^6.0.2",
"core-js": "^3.6.4",
"coveralls": "^3.1.0",
"css-loader": "^2.1.1",
"env-cmd": "^10.1.0",
"eslint": "^6.8.0",
Expand Down

0 comments on commit 31555c8

Please sign in to comment.