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 43 44 45 46 47 48 49 50 51
|
var cp = require('child_process')
var spawn = cp.spawn
var exec = cp.execFile
var node = process.execPath
var run = require.resolve('../bin/run.js')
var ok = require.resolve('./test/ok.js')
var t = require('../')
var fs = require('fs')
var mkdirp = require('mkdirp')
var rimraf = require('rimraf')
var dir = __dirname + '/coverage-html-no-browser'
var htmlfile = dir + '/coverage/lcov-report/bin/run.js.html'
process.exit()
t.test('setup a working dir', function (t) {
mkdirp.sync(dir)
t.end()
})
t.test('generate some coverage data', function (t) {
spawn(node, [run, ok, '--coverage', '--no-coverage-report'], {
cwd: dir,
stdio: 'ignore'
}).on('close', function (code, signal) {
t.equal(code, 0)
t.equal(signal, null)
t.end()
})
})
t.test('generate html, but do not open in a browser', function (t) {
spawn(node, [run, '--coverage-report=html', '--no-browser'], {
cwd: dir,
stdio: 'ignore'
}).on('close', function (code, signal) {
var output = fs.readFileSync(htmlfile, 'utf8')
t.match(output, /^<!doctype html>/)
t.match(output, /Code coverage report for bin[\\\/]run\.js/)
t.equal(code, 0)
t.equal(signal, null)
t.end()
})
})
t.test('cleanup', function (t) {
rimraf.sync(dir)
t.end()
})
|