Skip to content

Commit 59e8bbf

Browse files
JaKXzbcoe
authored andcommitted
feat: add coverage to default excludes (#23)
BREAKING CHANGE: additional coverage folder is now excluded
1 parent cf979c7 commit 59e8bbf

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

index.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ TestExclude.prototype.shouldInstrument = function (filename, relFile) {
6060
// Don't instrument files that are outside of the current working directory.
6161
if (/^\.\./.test(path.relative(this.cwd, filename))) return false
6262

63-
relFile = relFile.replace(/^\.[\\\/]/, '') // remove leading './' or '.\'.
63+
relFile = relFile.replace(/^\.[\\/]/, '') // remove leading './' or '.\'.
6464
return (!this.include || micromatch.any(relFile, this.include, {dotfiles: true})) && !micromatch.any(relFile, this.exclude, {dotfiles: true})
6565
}
6666

@@ -98,6 +98,7 @@ var exportFunc = function (opts) {
9898
}
9999

100100
exportFunc.defaultExclude = [
101+
'coverage/**',
101102
'test/**',
102103
'test{,-*}.js',
103104
'**/*.test.js',

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"main": "index.js",
66
"scripts": {
77
"pretest": "standard",
8-
"test": "nyc mocha ./test/*.js",
8+
"test": "nyc mocha",
99
"release": "standard-version"
1010
},
1111
"repository": {
@@ -43,7 +43,7 @@
4343
"nyc": {
4444
"check-coverage": true,
4545
"statements": 100,
46-
"branches": 96,
46+
"branches": 97,
4747
"lines": 100,
4848
"functions": 100,
4949
"reporter": [

test/test-exclude.js

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ describe('testExclude', function () {
2323
exclude().shouldInstrument('../foo.js').should.equal(false)
2424
})
2525

26+
it('does not instrument files in the coverage folder by default', function () {
27+
exclude().shouldInstrument('coverage/foo.js').should.equal(false)
28+
})
29+
2630
it('applies exclude rule ahead of include rule', function () {
2731
const e = exclude({
2832
include: ['test.js', 'foo.js'],
@@ -84,6 +88,7 @@ describe('testExclude', function () {
8488

8589
it('exports defaultExclude', function () {
8690
exclude.defaultExclude.should.deep.equal([
91+
'coverage/**',
8792
'test/**',
8893
'test{,-*}.js',
8994
'**/*.test.js',

0 commit comments

Comments
 (0)