Skip to content

Commit ef0a328

Browse files
committed
chore: Troubleshoot windows
1 parent 674bb7c commit ef0a328

File tree

3 files changed

+81
-3
lines changed

3 files changed

+81
-3
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
language: node_js
22
os:
33
- windows
4-
- linux
5-
- osx
4+
# - linux
5+
# - osx
66
node_js:
77
- "node"
88
- 10

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"lint": "standard",
88
"pretest": "npm run lint && npm run clean && npm run instrument",
9-
"test": "tap",
9+
"test": "tap test/should-instrument.js",
1010
"snap": "npm test -- --snapshot",
1111
"posttest": "npm run report",
1212
"clean": "rimraf ./.nyc_output ./node_modules/.cache ./.self_coverage ./test/fixtures/.nyc_output ./test/fixtures/node_modules/.cache ./test/fixtures/cli/foo-cache ./test/temp-dir-* ./self-coverage",

test/should-instrument.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
const path = require('path')
2+
const NYC = require('../self-coverage')
3+
const configUtil = require('../self-coverage/lib/config-util')
4+
const fixtures = path.resolve(__dirname, './fixtures')
5+
6+
const t = require('tap')
7+
8+
const rootDir = path.resolve('/')
9+
t.test('should exclude appropriately with defaults', t => {
10+
const nyc = new NYC(configUtil.buildYargs(rootDir).parse([
11+
'--exclude=test/**',
12+
'--exclude=test{,-*}.js',
13+
'--exclude=**/*.test.js',
14+
'--exclude=**/__tests__/**'
15+
]))
16+
17+
// nyc always excludes "node_modules/**"
18+
t.true(nyc.exclude.shouldInstrument(path.join(rootDir, 'foo.js'), 'foo.js'))
19+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'node_modules/bar.js'), 'node_modules/bar.js'))
20+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'foo/node_modules/bar.js'), 'foo/node_modules/bar.js'))
21+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'test.js'), 'test.js'))
22+
t.true(nyc.exclude.shouldInstrument(path.join(rootDir, 'testfoo.js'), 'testfoo.js'))
23+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'test-foo.js'), 'test-foo.js'))
24+
t.true(nyc.exclude.shouldInstrument(path.join(rootDir, 'lib/test.js'), 'lib/test.js'))
25+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'foo/bar/test.js'), './test.js'))
26+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'foo/bar/test.js'), '.\\test.js'))
27+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'foo/bar/foo.test.js'), './foo.test.js'))
28+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'foo/bar/__tests__/foo.js'), './__tests__/foo.js'))
29+
t.done()
30+
})
31+
32+
t.test('should exclude appropriately with config.exclude', t => {
33+
const nyc = new NYC(configUtil.buildYargs(fixtures).parse())
34+
35+
// fixtures/package.json configures excludes: "blarg", "blerg"
36+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'blarg.js'), 'blarg.js'))
37+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'blarg/foo.js'), 'blarg/foo.js'))
38+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'blerg.js'), 'blerg.js'))
39+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'blerg.js'), './blerg.js'))
40+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'blerg.js'), '.\\blerg.js'))
41+
t.done()
42+
})
43+
44+
t.test('should exclude outside of the current working directory', t => {
45+
const nyc = new NYC(configUtil.buildYargs(path.join(rootDir, 'foo')).parse())
46+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'bar.js'), '../bar.js'))
47+
t.done()
48+
})
49+
50+
t.test('should not exclude if the current working directory is inside node_modules', t => {
51+
const cwd = path.join(rootDir, 'node_modules', 'foo')
52+
const nyc = new NYC(configUtil.buildYargs(cwd).parse())
53+
t.true(nyc.exclude.shouldInstrument(path.join(cwd, 'bar.js'), './bar.js'))
54+
t.true(nyc.exclude.shouldInstrument(path.join(cwd, 'bar.js'), '.\\bar.js'))
55+
t.done()
56+
})
57+
58+
t.test('allows files to be explicitly included, rather than excluded', t => {
59+
const nyc = new NYC(configUtil.buildYargs(rootDir).parse(['--include=foo.js']))
60+
61+
t.true(nyc.exclude.shouldInstrument(path.join(rootDir, 'foo.js'), 'foo.js'))
62+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'index.js'), 'index.js'))
63+
t.done()
64+
})
65+
66+
t.test('exclude overrides include', t => {
67+
const nyc = new NYC(configUtil.buildYargs(rootDir).parse([
68+
'--include=foo.js',
69+
'--include=test.js',
70+
'--exclude=**/node_modules/**',
71+
'--exclude=test/**',
72+
'--exclude=test{,-*}.js'
73+
]))
74+
75+
t.true(nyc.exclude.shouldInstrument(path.join(rootDir, 'foo.js'), 'foo.js'))
76+
t.false(nyc.exclude.shouldInstrument(path.join(rootDir, 'test.js'), 'test.js'))
77+
t.done()
78+
})

0 commit comments

Comments
 (0)