Skip to content

Commit

Permalink
test: bring back code coverage (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson authored Jun 19, 2020
1 parent d897412 commit edb2fae
Show file tree
Hide file tree
Showing 4 changed files with 300 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ if (/KAIOS/.test(navigator.userAgent)) {

npm test

### Code coverage

npm run cover

### Manual KaiOS app test

The `index.html` and `manifest.webapp` files are designed for a quick-and-dirty KaiOS app test.
Expand Down
19 changes: 16 additions & 3 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ const resolve = require('@rollup/plugin-node-resolve').default
const cjs = require('@rollup/plugin-commonjs')
const json = require('@rollup/plugin-json')
const polyfills = require('rollup-plugin-node-polyfills')
const istanbul = require('rollup-plugin-istanbul')

module.exports = function (config) {
config.set({
plugins: [
require('karma-rollup-preprocessor'),
require('karma-mocha'),
require('karma-chrome-launcher')
require('karma-chrome-launcher'),
...(process.env.COVERAGE ? [require('karma-coverage')] : [])
],

files: [
Expand All @@ -27,7 +29,15 @@ module.exports = function (config) {
}),
cjs(),
json(),
polyfills()
polyfills(),
...(process.env.COVERAGE ? [
istanbul ({
exclude: [
'test/*.js',
'node_modules/**/*.js'
]
})
] : [])
],
output: {
format: 'iife', // Helps prevent naming collisions.
Expand All @@ -40,6 +50,9 @@ module.exports = function (config) {

browsers: [
'ChromeHeadless'
]
],
...(process.env.COVERAGE ? {
reporters: ['coverage']
} : null)
})
}
276 changes: 276 additions & 0 deletions package-lock.json

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

Loading

0 comments on commit edb2fae

Please sign in to comment.