Skip to content

Commit 70f804f

Browse files
authored
fix: set excludeAfterRemap to false by default (#218)
1 parent a9430ec commit 70f804f

File tree

6 files changed

+19
-6
lines changed

6 files changed

+19
-6
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

+3
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,6 @@ A clear and concise description of what the bug is.
2929

3030
**Link to the repo**
3131
Bugs with a reproducible example, like an open source repo showing the bug, are the most likely to be resolved.
32+
33+
**Example**
34+
See [#217](https://github.com/cypress-io/code-coverage/issues/217) that is an excellent bug report example

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ For example, if you want to only include files in the `app` folder, but exclude
302302

303303
**Note:** if you have `all: true` NYC option set, this plugin will check the produced `.nyc_output/out.json` before generating the final report. If the `out.json` file does not have information for some files that should be there according to `include` list, then an empty placeholder will be included, see [PR 208](https://github.com/cypress-io/code-coverage/pull/208).
304304

305+
Another important option is `excludeAfterRemap`. By default it is false, which might let excluded files through. If you are excluding the files, and the instrumenter does not respect the `nyc.exclude` setting, then add `excludeAfterRemap: true` to tell `nyc report` to exclude files. See [examples/exclude-files](examples/exclude-files).
306+
305307
## Disable plugin
306308

307309
You can skip the client-side code coverage hooks by setting the environment variable `coverage` to `false`.

common-utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const defaultNycOptions = {
2828
'report-dir': './coverage',
2929
reporter: ['lcov', 'clover', 'json'],
3030
extension: ['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx'],
31-
excludeAfterRemap: true
31+
excludeAfterRemap: false
3232
}
3333

3434
module.exports = {

cypress/integration/combine-spec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('Combine NYC options', () => {
1515
'report-dir': './coverage',
1616
reporter: ['lcov', 'clover', 'json'],
1717
extension: ['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx'],
18-
excludeAfterRemap: true
18+
excludeAfterRemap: false
1919
})
2020
})
2121

@@ -31,7 +31,7 @@ describe('Combine NYC options', () => {
3131
'report-dir': './coverage',
3232
reporter: ['text'],
3333
extension: ['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx'],
34-
excludeAfterRemap: true
34+
excludeAfterRemap: false
3535
})
3636
})
3737

@@ -58,7 +58,7 @@ describe('Combine NYC options', () => {
5858
'report-dir': './coverage',
5959
reporter: ['json'],
6060
extension: ['.js'],
61-
excludeAfterRemap: true,
61+
excludeAfterRemap: false,
6262
include: ['foo.js'],
6363
exclude: ['bar.js']
6464
})

examples/exclude-files/package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
"scripts": {
55
"start": "../../node_modules/.bin/parcel serve index.html",
66
"cy:open": "../../node_modules/.bin/cypress open",
7-
"dev": "../../node_modules/.bin/start-test 1234 cy:open"
7+
"cy:run": "../../node_modules/.bin/cypress run",
8+
"dev": "../../node_modules/.bin/start-test 1234 cy:open",
9+
"e2e": "../../node_modules/.bin/start-test 1234 cy:run"
810
},
911
"nyc": {
10-
"exclude": ["second.js"]
12+
"exclude": ["second.js"],
13+
"excludeAfterRemap": true
1114
},
1215
"devDependencies": {
1316
"@babel/core": "7.9.0"

task.js

+5
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ const tasks = {
168168
// https://github.com/istanbuljs/nyc#common-configuration-options
169169
const nycReportOptions = readNycOptions(processWorkingDirectory)
170170

171+
if (nycReportOptions.exclude && !Array.isArray(nycReportOptions.exclude)) {
172+
console.error('NYC options: %o', nycReportOptions)
173+
throw new Error('Expected "exclude" to by an array')
174+
}
175+
171176
// override a couple of options
172177
nycReportOptions.tempDir = coverageFolder
173178
if (nycReportOptions['report-dir']) {

0 commit comments

Comments
 (0)