nyc 3.0.1 → 3.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.npmignore +2 -0
- package/CHANGELOG.md +10 -0
- package/README.md +5 -0
- package/bin/nyc.js +10 -1
- package/index.js +77 -34
- package/node_modules/foreground-child/.npmignore +3 -0
- package/node_modules/foreground-child/.travis.yml +6 -0
- package/node_modules/foreground-child/LICENSE +15 -0
- package/node_modules/foreground-child/README.md +33 -0
- package/node_modules/foreground-child/index.js +54 -0
- package/node_modules/foreground-child/node_modules/win-spawn/.npmignore +15 -0
- package/node_modules/foreground-child/node_modules/win-spawn/README.md +41 -0
- package/node_modules/foreground-child/node_modules/win-spawn/bin/win-spawn +12 -0
- package/node_modules/foreground-child/node_modules/win-spawn/index.js +64 -0
- package/node_modules/foreground-child/node_modules/win-spawn/package.json +45 -0
- package/node_modules/foreground-child/package.json +40 -0
- package/node_modules/foreground-child/test/basic.js +150 -0
- package/node_modules/spawn-wrap/.travis.yml +8 -0
- package/node_modules/spawn-wrap/LICENSE +15 -0
- package/node_modules/spawn-wrap/README.md +62 -0
- package/node_modules/spawn-wrap/index.js +225 -0
- package/node_modules/spawn-wrap/lib/is-windows.js +5 -0
- package/node_modules/spawn-wrap/lib/win-rebase.js +7 -0
- package/node_modules/spawn-wrap/node_modules/os-homedir/index.js +24 -0
- package/node_modules/spawn-wrap/node_modules/os-homedir/license +21 -0
- package/node_modules/spawn-wrap/node_modules/os-homedir/package.json +70 -0
- package/node_modules/spawn-wrap/node_modules/os-homedir/readme.md +33 -0
- package/node_modules/spawn-wrap/package.json +41 -0
- package/node_modules/spawn-wrap/shim.js +139 -0
- package/node_modules/spawn-wrap/t.js +26 -0
- package/node_modules/spawn-wrap/test/basic.js +139 -0
- package/node_modules/spawn-wrap/test/fixtures/script.js +3 -0
- package/node_modules/spawn-wrap/test/win-rebase.js +20 -0
- package/package.json +12 -6
- package/test/fixtures/not-loaded.js +2 -0
- package/test/nyc-test.js +46 -3
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
// This module should *only* be loaded as a main script
|
|
2
|
+
// by child processes wrapped by spawn-wrap. It sets up
|
|
3
|
+
// argv to include the injected argv (including the user's
|
|
4
|
+
// wrapper script) and any environment variables specified.
|
|
5
|
+
//
|
|
6
|
+
// If any argv were passed in (ie, if it's used to force
|
|
7
|
+
// a wrapper script, and not just ensure that an env is kept
|
|
8
|
+
// around through all the child procs), then we also set up
|
|
9
|
+
// a require('spawn-wrap').runMain() function that will strip
|
|
10
|
+
// off the injected arguments and run the main file.
|
|
11
|
+
|
|
12
|
+
if (module !== require.main) {
|
|
13
|
+
throw new Error('spawn-wrap: cli wrapper invoked as non-main script')
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// require('fs').createWriteStream('/dev/tty').write('WRAP ' + process.argv.slice(2).join(' ') + '\n')
|
|
17
|
+
var Module = require('module')
|
|
18
|
+
var assert = require('assert')
|
|
19
|
+
var path = require('path')
|
|
20
|
+
var node = process.execPath
|
|
21
|
+
|
|
22
|
+
var settings = require('./settings.json')
|
|
23
|
+
var foregroundChild = require(settings.deps.foregroundChild)
|
|
24
|
+
var argv = settings.argv
|
|
25
|
+
var nargs = argv.length
|
|
26
|
+
var env = settings.env
|
|
27
|
+
|
|
28
|
+
for (var key in env) {
|
|
29
|
+
process.env[key] = env[key]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var needExecArgv = settings.execArgv || []
|
|
33
|
+
|
|
34
|
+
// If the user added their OWN wrapper pre-load script, then
|
|
35
|
+
// this will pop that off of the argv, and load the "real" main
|
|
36
|
+
function runMain () {
|
|
37
|
+
process.argv.splice(1, nargs)
|
|
38
|
+
process.argv[1] = path.resolve(process.argv[1])
|
|
39
|
+
Module.runMain()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Argv coming in looks like:
|
|
43
|
+
// bin shim execArgv main argv
|
|
44
|
+
//
|
|
45
|
+
// Turn it into:
|
|
46
|
+
// bin settings.execArgv execArgv settings.argv main argv
|
|
47
|
+
//
|
|
48
|
+
// If we don't have a main script, then just run with the necessary
|
|
49
|
+
// execArgv
|
|
50
|
+
var hasMain = false
|
|
51
|
+
for (var a = 2; !hasMain && a < process.argv.length; a++) {
|
|
52
|
+
switch (process.argv[a]) {
|
|
53
|
+
case '-i':
|
|
54
|
+
case '--interactive':
|
|
55
|
+
case '--eval':
|
|
56
|
+
case '-e':
|
|
57
|
+
case '-pe':
|
|
58
|
+
hasMain = false
|
|
59
|
+
a = process.argv.length
|
|
60
|
+
continue
|
|
61
|
+
|
|
62
|
+
case '-r':
|
|
63
|
+
case '--require':
|
|
64
|
+
a += 1
|
|
65
|
+
continue
|
|
66
|
+
|
|
67
|
+
default:
|
|
68
|
+
if (process.argv[a].match(/^-/)) {
|
|
69
|
+
continue
|
|
70
|
+
} else {
|
|
71
|
+
hasMain = a
|
|
72
|
+
a = process.argv.length
|
|
73
|
+
break
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (hasMain > 2) {
|
|
79
|
+
// if the main file is above #2, then it means that there
|
|
80
|
+
// was a --exec_arg *before* it. This means that we need
|
|
81
|
+
// to slice everything from 2 to hasMain, and pass that
|
|
82
|
+
// directly to node. This also splices out the user-supplied
|
|
83
|
+
// execArgv from the argv.
|
|
84
|
+
var addExecArgv = process.argv.splice(2, hasMain - 2)
|
|
85
|
+
needExecArgv.push.apply(needExecArgv, addExecArgv)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (!hasMain) {
|
|
89
|
+
// we got loaded by mistake for a `node -pe script` or something.
|
|
90
|
+
var args = process.execArgv.concat(needExecArgv, process.argv.slice(2))
|
|
91
|
+
foregroundChild(node, args)
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// If there are execArgv, and they're not the same as how this module
|
|
96
|
+
// was executed, then we need to inject those. This is for stuff like
|
|
97
|
+
// --harmony or --use_strict that needs to be *before* the main
|
|
98
|
+
// module.
|
|
99
|
+
if (needExecArgv.length) {
|
|
100
|
+
var pexec = process.execArgv
|
|
101
|
+
if (JSON.stringify(pexec) !== JSON.stringify(needExecArgv)) {
|
|
102
|
+
var spawn = require('child_process').spawn
|
|
103
|
+
var sargs = pexec.concat(needExecArgv).concat(process.argv.slice(1))
|
|
104
|
+
foregroundChild(node, sargs)
|
|
105
|
+
return
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// At this point, we've verified that we got the correct execArgv,
|
|
110
|
+
// and that we have a main file, and that the main file is sitting at
|
|
111
|
+
// argv[2]. Splice this shim off the list so it looks like the main.
|
|
112
|
+
var spliceArgs = [1, 1].concat(argv)
|
|
113
|
+
process.argv.splice.apply(process.argv, spliceArgs)
|
|
114
|
+
|
|
115
|
+
// Unwrap the PATH environment var so that we're not mucking
|
|
116
|
+
// with the environment. It'll get re-added if they spawn anything
|
|
117
|
+
var isWindows = (
|
|
118
|
+
process.platform === 'win32' ||
|
|
119
|
+
process.env.OSTYPE === 'cygwin' ||
|
|
120
|
+
process.env.OSTYPE === 'msys'
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
if (isWindows) {
|
|
124
|
+
for (var i in process.env) {
|
|
125
|
+
if (i.match(/^path$/i)) {
|
|
126
|
+
process.env[i] = process.env[i].replace(__dirname + ';', '')
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
process.env.PATH = process.env.PATH.replace(__dirname + ':', '')
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
var spawnWrap = require(settings.module)
|
|
134
|
+
if (nargs) {
|
|
135
|
+
spawnWrap.runMain = runMain
|
|
136
|
+
}
|
|
137
|
+
spawnWrap(argv, env, __dirname)
|
|
138
|
+
|
|
139
|
+
Module.runMain()
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
if (process.env.xyz) {
|
|
3
|
+
console.log('in t.js, xyz=%j', process.env.xyz)
|
|
4
|
+
console.log('gc is a', typeof gc)
|
|
5
|
+
console.log('%j', process.argv)
|
|
6
|
+
console.log('about to run the main file\u001b[32m')
|
|
7
|
+
require('./index.js').runMain()
|
|
8
|
+
console.log('\u001b[31mran wrapped main')
|
|
9
|
+
return
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
var wrap = require('./index.js')
|
|
13
|
+
|
|
14
|
+
var unwrap = wrap(['--expose_gc', __filename, ' a $ b '], { xyz: 'ABC' })
|
|
15
|
+
|
|
16
|
+
console.log('about to run child process')
|
|
17
|
+
console.log('gc is a', typeof gc)
|
|
18
|
+
var cp = require('child_process')
|
|
19
|
+
var child = cp.exec(process.execPath + ' $(which tap ) -h', { env: { foo: 'asdf', PATH:process.env.PATH } }, function (er, out, err) {
|
|
20
|
+
console.error('returned')
|
|
21
|
+
console.error('error = ', er)
|
|
22
|
+
console.error('outlen=', out.length)
|
|
23
|
+
console.error('\u001b[31m' + out + '\u001b[m')
|
|
24
|
+
console.error('errlen=', err.length)
|
|
25
|
+
process.stderr.write(err)
|
|
26
|
+
})
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
var sw = require('../')
|
|
2
|
+
var onExit = require('signal-exit')
|
|
3
|
+
|
|
4
|
+
var cp = require('child_process')
|
|
5
|
+
var isWindows = require('../lib/is-windows')()
|
|
6
|
+
var spawn = require('win-spawn')
|
|
7
|
+
var fixture = require.resolve('./fixtures/script.js')
|
|
8
|
+
|
|
9
|
+
if (process.argv[2] === 'parent') {
|
|
10
|
+
// hang up once
|
|
11
|
+
process.once('SIGHUP', function onHup () {
|
|
12
|
+
console.log('SIGHUP')
|
|
13
|
+
})
|
|
14
|
+
// handle sigints forever
|
|
15
|
+
process.on('SIGINT', function onInt () {
|
|
16
|
+
console.log('SIGINT')
|
|
17
|
+
})
|
|
18
|
+
onExit(function (code, signal) {
|
|
19
|
+
console.log('EXIT %j', [code, signal])
|
|
20
|
+
})
|
|
21
|
+
var argv = process.argv.slice(3).map(function (arg) {
|
|
22
|
+
if (arg === fixture) {
|
|
23
|
+
return '{{FIXTURE}}'
|
|
24
|
+
}
|
|
25
|
+
return arg
|
|
26
|
+
})
|
|
27
|
+
console.log('WRAP %j', process.execArgv.concat(argv))
|
|
28
|
+
sw.runMain()
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var t = require('tap')
|
|
33
|
+
var unwrap = sw([__filename, 'parent'])
|
|
34
|
+
|
|
35
|
+
var expect = 'WRAP ["{{FIXTURE}}","xyz"]\n' +
|
|
36
|
+
'[]\n' +
|
|
37
|
+
'["xyz"]\n' +
|
|
38
|
+
'EXIT [0,null]\n'
|
|
39
|
+
|
|
40
|
+
t.test('spawn execPath', function (t) {
|
|
41
|
+
var child = spawn(process.execPath, [fixture, 'xyz'])
|
|
42
|
+
|
|
43
|
+
var out = ''
|
|
44
|
+
child.stdout.on('data', function (c) {
|
|
45
|
+
out += c
|
|
46
|
+
})
|
|
47
|
+
child.on('close', function (code, signal) {
|
|
48
|
+
t.equal(code, 0)
|
|
49
|
+
t.equal(signal, null)
|
|
50
|
+
t.equal(out, expect)
|
|
51
|
+
t.end()
|
|
52
|
+
})
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
t.test('exec shebang', function (t) {
|
|
56
|
+
var child = spawn(fixture, ['xyz'])
|
|
57
|
+
|
|
58
|
+
var out = ''
|
|
59
|
+
child.stdout.on('data', function (c) {
|
|
60
|
+
out += c
|
|
61
|
+
})
|
|
62
|
+
child.on('close', function (code, signal) {
|
|
63
|
+
t.equal(code, 0)
|
|
64
|
+
t.equal(signal, null)
|
|
65
|
+
t.equal(out, expect)
|
|
66
|
+
t.end()
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
if (!isWindows)
|
|
71
|
+
t.test('SIGHUP', function (t) {
|
|
72
|
+
var child = cp.exec(fixture + ' xyz')
|
|
73
|
+
|
|
74
|
+
var out = ''
|
|
75
|
+
child.stdout.on('data', function (c) {
|
|
76
|
+
out += c
|
|
77
|
+
child.kill('SIGHUP')
|
|
78
|
+
})
|
|
79
|
+
child.on('close', function (code, signal) {
|
|
80
|
+
t.equal(code, null)
|
|
81
|
+
t.equal(signal, 'SIGHUP')
|
|
82
|
+
t.equal(out, 'WRAP ["{{FIXTURE}}","xyz"]\n' +
|
|
83
|
+
'[]\n' +
|
|
84
|
+
'["xyz"]\n' +
|
|
85
|
+
'SIGHUP\n' +
|
|
86
|
+
'EXIT [null,"SIGHUP"]\n')
|
|
87
|
+
t.end()
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
|
|
91
|
+
if (!isWindows)
|
|
92
|
+
t.test('SIGINT', function (t) {
|
|
93
|
+
var child = cp.exec(fixture + ' xyz')
|
|
94
|
+
|
|
95
|
+
var out = ''
|
|
96
|
+
child.stdout.on('data', function (c) {
|
|
97
|
+
out += c
|
|
98
|
+
})
|
|
99
|
+
child.stdout.once('data', function () {
|
|
100
|
+
child.kill('SIGINT')
|
|
101
|
+
})
|
|
102
|
+
child.stderr.on('data', function (t) {
|
|
103
|
+
console.error(t)
|
|
104
|
+
})
|
|
105
|
+
child.on('close', function (code, signal) {
|
|
106
|
+
t.equal(code, 0)
|
|
107
|
+
t.equal(signal, null)
|
|
108
|
+
t.equal(out, 'WRAP ["{{FIXTURE}}","xyz"]\n' +
|
|
109
|
+
'[]\n' +
|
|
110
|
+
'["xyz"]\n' +
|
|
111
|
+
'SIGINT\n' +
|
|
112
|
+
'EXIT [0,null]\n')
|
|
113
|
+
t.end()
|
|
114
|
+
})
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
if (!isWindows)
|
|
118
|
+
t.test('--harmony', function (t) {
|
|
119
|
+
var node = process.execPath
|
|
120
|
+
var child = spawn(node, ['--harmony', fixture, 'xyz'])
|
|
121
|
+
var out = ''
|
|
122
|
+
child.stdout.on('data', function (c) {
|
|
123
|
+
out += c
|
|
124
|
+
})
|
|
125
|
+
child.on('close', function (code, signal) {
|
|
126
|
+
t.equal(code, 0)
|
|
127
|
+
t.equal(signal, null)
|
|
128
|
+
t.equal(out, 'WRAP ["--harmony","{{FIXTURE}}","xyz"]\n' +
|
|
129
|
+
'["--harmony"]\n' +
|
|
130
|
+
'["xyz"]\n' +
|
|
131
|
+
'EXIT [0,null]\n')
|
|
132
|
+
t.end()
|
|
133
|
+
})
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
t.test('unwrap', function (t) {
|
|
137
|
+
unwrap()
|
|
138
|
+
t.end()
|
|
139
|
+
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var t = require('tap')
|
|
2
|
+
var winRebase = require('../lib/win-rebase')
|
|
3
|
+
|
|
4
|
+
t.test('it replaces path to node bin', function (t) {
|
|
5
|
+
var result = winRebase('C:\\Program Files\\nodejs\\node.exe', 'C:\\foo')
|
|
6
|
+
t.equal(result, 'C:\\foo')
|
|
7
|
+
t.done()
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
t.test('it does not replace path if it references an unknown bin', function (t) {
|
|
11
|
+
var result = winRebase('C:\\Program Files\\nodejs\\banana', 'C:\\foo')
|
|
12
|
+
t.equal(result, 'C:\\Program Files\\nodejs\\banana')
|
|
13
|
+
t.done()
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
t.test('replaces node bin and leaves the script being executed', function (t) {
|
|
17
|
+
var result = winRebase('C:\\Program Files\\nodejs\\node.exe foo.js', 'C:\\foo')
|
|
18
|
+
t.equal(result, 'C:\\foo foo.js')
|
|
19
|
+
t.done()
|
|
20
|
+
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nyc",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.2",
|
|
4
4
|
"description": "a code coverage tool that works well with subprocesses.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"config": {
|
|
14
14
|
"nyc": {
|
|
15
15
|
"exclude": [
|
|
16
|
-
"node_modules
|
|
16
|
+
"node_modules",
|
|
17
|
+
"bin"
|
|
17
18
|
]
|
|
18
19
|
}
|
|
19
20
|
},
|
|
@@ -36,8 +37,9 @@
|
|
|
36
37
|
"author": "Ben Coe <ben@npmjs.com>",
|
|
37
38
|
"license": "ISC",
|
|
38
39
|
"dependencies": {
|
|
39
|
-
"foreground-child": "
|
|
40
|
-
"
|
|
40
|
+
"foreground-child": "1.3.0",
|
|
41
|
+
"glob": "^5.0.14",
|
|
42
|
+
"istanbul": "^0.3.19",
|
|
41
43
|
"lodash": "^3.10.0",
|
|
42
44
|
"mkdirp": "^0.5.0",
|
|
43
45
|
"rimraf": "^2.4.2",
|
|
@@ -49,9 +51,13 @@
|
|
|
49
51
|
"devDependencies": {
|
|
50
52
|
"chai": "^3.0.0",
|
|
51
53
|
"sinon": "^1.15.3",
|
|
52
|
-
"standard": "^
|
|
53
|
-
"tap": "^1.3.
|
|
54
|
+
"standard": "^5.2.1",
|
|
55
|
+
"tap": "^1.3.4"
|
|
54
56
|
},
|
|
57
|
+
"bundleDependencies": [
|
|
58
|
+
"foreground-child",
|
|
59
|
+
"spawn-wrap"
|
|
60
|
+
],
|
|
55
61
|
"repository": {
|
|
56
62
|
"type": "git",
|
|
57
63
|
"url": "git@github.com:bcoe/nyc.git"
|
package/test/nyc-test.js
CHANGED
|
@@ -15,7 +15,6 @@ describe('nyc', function () {
|
|
|
15
15
|
var fixtures = path.resolve(__dirname, './fixtures')
|
|
16
16
|
|
|
17
17
|
describe('cwd', function () {
|
|
18
|
-
|
|
19
18
|
function afterEach () {
|
|
20
19
|
delete process.env.NYC_CWD
|
|
21
20
|
rimraf.sync(path.resolve(fixtures, './nyc_output'))
|
|
@@ -33,7 +32,7 @@ describe('nyc', function () {
|
|
|
33
32
|
|
|
34
33
|
var nyc = new NYC()
|
|
35
34
|
|
|
36
|
-
nyc.cwd.should.
|
|
35
|
+
nyc.cwd.should.equal(path.resolve(__dirname, './fixtures'))
|
|
37
36
|
afterEach()
|
|
38
37
|
})
|
|
39
38
|
})
|
|
@@ -89,6 +88,14 @@ describe('nyc', function () {
|
|
|
89
88
|
it('writes coverage report when process is killed with SIGINT', function (done) {
|
|
90
89
|
testSignal('sigint', done)
|
|
91
90
|
})
|
|
91
|
+
|
|
92
|
+
it('does not output coverage for files that have not been included, by default', function (done) {
|
|
93
|
+
var reports = _.filter(nyc._loadReports(), function (report) {
|
|
94
|
+
return report['./test/fixtures/not-loaded.js']
|
|
95
|
+
})
|
|
96
|
+
reports.length.should.equal(0)
|
|
97
|
+
return done()
|
|
98
|
+
})
|
|
92
99
|
})
|
|
93
100
|
|
|
94
101
|
describe('report', function () {
|
|
@@ -241,7 +248,7 @@ describe('nyc', function () {
|
|
|
241
248
|
})
|
|
242
249
|
nyc.wrap()
|
|
243
250
|
|
|
244
|
-
istanbul.config.loadFile.calledWithMatch('test
|
|
251
|
+
istanbul.config.loadFile.calledWithMatch(path.join('test', 'fixtures', '.istanbul.yml')).should.equal(true)
|
|
245
252
|
istanbul.Instrumenter.calledWith({
|
|
246
253
|
coverageVariable: '__coverage__',
|
|
247
254
|
embedSource: false,
|
|
@@ -271,4 +278,40 @@ describe('nyc', function () {
|
|
|
271
278
|
munged.should.eql(['node', 'test/nyc-test.js'])
|
|
272
279
|
})
|
|
273
280
|
})
|
|
281
|
+
|
|
282
|
+
describe('addAllFiles', function () {
|
|
283
|
+
it('outputs an empty coverage report for all files that are not excluded', function (done) {
|
|
284
|
+
var nyc = (new NYC())
|
|
285
|
+
nyc.addAllFiles()
|
|
286
|
+
|
|
287
|
+
var reports = _.filter(nyc._loadReports(), function (report) {
|
|
288
|
+
return report['./test/fixtures/not-loaded.js']
|
|
289
|
+
})
|
|
290
|
+
var report = reports[0]['./test/fixtures/not-loaded.js']
|
|
291
|
+
|
|
292
|
+
reports.length.should.equal(1)
|
|
293
|
+
report.s['1'].should.equal(0)
|
|
294
|
+
report.s['2'].should.equal(0)
|
|
295
|
+
return done()
|
|
296
|
+
})
|
|
297
|
+
|
|
298
|
+
it('tracks coverage appropriately once the file is required', function (done) {
|
|
299
|
+
var nyc = (new NYC({
|
|
300
|
+
cwd: process.cwd()
|
|
301
|
+
})).wrap()
|
|
302
|
+
require('./fixtures/not-loaded')
|
|
303
|
+
nyc.writeCoverageFile()
|
|
304
|
+
|
|
305
|
+
var reports = _.filter(nyc._loadReports(), function (report) {
|
|
306
|
+
return report['./test/fixtures/not-loaded.js']
|
|
307
|
+
})
|
|
308
|
+
var report = reports[0]['./test/fixtures/not-loaded.js']
|
|
309
|
+
|
|
310
|
+
reports.length.should.equal(1)
|
|
311
|
+
report.s['1'].should.equal(1)
|
|
312
|
+
report.s['2'].should.equal(1)
|
|
313
|
+
|
|
314
|
+
return done()
|
|
315
|
+
})
|
|
316
|
+
})
|
|
274
317
|
})
|