Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set excludeAfterRemap to false by default #218

Merged
merged 2 commits into from
Apr 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,6 @@ A clear and concise description of what the bug is.

**Link to the repo**
Bugs with a reproducible example, like an open source repo showing the bug, are the most likely to be resolved.

**Example**
See [#217](https://github.com/cypress-io/code-coverage/issues/217) that is an excellent bug report example
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ For example, if you want to only include files in the `app` folder, but exclude

**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).

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).

## Disable plugin

You can skip the client-side code coverage hooks by setting the environment variable `coverage` to `false`.
Expand Down
2 changes: 1 addition & 1 deletion common-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const defaultNycOptions = {
'report-dir': './coverage',
reporter: ['lcov', 'clover', 'json'],
extension: ['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx'],
excludeAfterRemap: true
excludeAfterRemap: false
}

module.exports = {
Expand Down
6 changes: 3 additions & 3 deletions cypress/integration/combine-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Combine NYC options', () => {
'report-dir': './coverage',
reporter: ['lcov', 'clover', 'json'],
extension: ['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx'],
excludeAfterRemap: true
excludeAfterRemap: false
})
})

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

Expand All @@ -58,7 +58,7 @@ describe('Combine NYC options', () => {
'report-dir': './coverage',
reporter: ['json'],
extension: ['.js'],
excludeAfterRemap: true,
excludeAfterRemap: false,
include: ['foo.js'],
exclude: ['bar.js']
})
Expand Down
7 changes: 5 additions & 2 deletions examples/exclude-files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
"scripts": {
"start": "../../node_modules/.bin/parcel serve index.html",
"cy:open": "../../node_modules/.bin/cypress open",
"dev": "../../node_modules/.bin/start-test 1234 cy:open"
"cy:run": "../../node_modules/.bin/cypress run",
"dev": "../../node_modules/.bin/start-test 1234 cy:open",
"e2e": "../../node_modules/.bin/start-test 1234 cy:run"
},
"nyc": {
"exclude": ["second.js"]
"exclude": ["second.js"],
"excludeAfterRemap": true
},
"devDependencies": {
"@babel/core": "7.9.0"
Expand Down
5 changes: 5 additions & 0 deletions task.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ const tasks = {
// https://github.com/istanbuljs/nyc#common-configuration-options
const nycReportOptions = readNycOptions(processWorkingDirectory)

if (nycReportOptions.exclude && !Array.isArray(nycReportOptions.exclude)) {
console.error('NYC options: %o', nycReportOptions)
throw new Error('Expected "exclude" to by an array')
}

// override a couple of options
nycReportOptions.tempDir = coverageFolder
if (nycReportOptions['report-dir']) {
Expand Down