-
Notifications
You must be signed in to change notification settings - Fork 778
/
Copy pathnyc.js
45 lines (41 loc) · 1.48 KB
/
nyc.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
43
44
45
const cp = require('child_process');
const path = require('path');
const DIR = path.join(__dirname, 'nyc');
// Fast re-runs
process.env.npm_config_prefer_offline = 'true';
process.env.npm_config_update_notifier = 'false';
process.env.npm_config_audit = 'false';
QUnit.module('nyc', {
before: () => {
cp.execSync('npm install', { cwd: DIR, encoding: 'utf8' });
}
});
QUnit.test('test', assert => {
const expected = `
TAP version 13
ok 1 add > two numbers
1..1
# pass 1
# skip 0
# todo 0
# fail 0
--------------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
--------------|---------|----------|---------|---------|-------------------
All files | 85.71 | 100 | 50 | 85.71 |
nyc | 100 | 100 | 100 | 100 |
index.js | 100 | 100 | 100 | 100 |
nyc/src | 75 | 100 | 50 | 75 |
add.js | 100 | 100 | 100 | 100 |
subtract.js | 50 | 100 | 0 | 50 | 2
--------------|---------|----------|---------|---------|-------------------
`.trim();
const actual = cp.execSync('npm test', {
cwd: DIR,
env: Object.assign({}, process.env, {
FORCE_COLOR: '0'
}),
encoding: 'utf8'
});
assert.pushResult({ result: actual.includes(expected), actual, expected });
});