-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-harness.js
42 lines (35 loc) · 1.04 KB
/
test-harness.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
const fs = require('fs')
const path = require('path')
const browserify = require('browserify')
const tapeIstanbul = require('tape-istanbul')
const tapeRun = require('tape-run')
const istanbul = require('istanbul')
const opener = require('opener')
function mainTests (cb) {
fs.readdir('./test', (err, files) => {
if (err) throw err
const bfy = browserify()
const ti = tapeIstanbul('./coverage-main.json')
ti.on('end', cb)
files
.filter((f) => /(.*)\.spec.js$/.test(f))
.forEach((spec) => bfy.add(path.join('./test', spec)))
bfy
.plugin('tape-istanbul/plugin', {stripBasePath: true})
.bundle()
.pipe(tapeRun())
.pipe(ti)
})
}
function createCoverage () {
const collector = new istanbul.Collector()
const reporter = new istanbul.Reporter()
collector.add(require('./coverage-main.json'))
reporter.add('lcov')
reporter.write(collector, false, () => {
if (process.env.CIRCLE_CI !== 'true') {
opener('./coverage/lcov-report/index.html')
}
})
}
mainTests(createCoverage)