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

Instrumenter should ignore excluded files and folders #890

Closed
AndrewFinlay opened this issue Jul 16, 2018 · 2 comments · Fixed by #1007
Closed

Instrumenter should ignore excluded files and folders #890

AndrewFinlay opened this issue Jul 16, 2018 · 2 comments · Fixed by #1007
Labels

Comments

@AndrewFinlay
Copy link
Contributor

AndrewFinlay commented Jul 16, 2018

Expected Behavior

The instrumenter should ignore files specified in the list of exclude globs

$ nyc instrument content instrumented

with .nycrc

{
    "exclude": [
        "**/dist/**",
        "**/3rd-party/**"
    ]
}

Observed Behavior

The instrumenter ignores files specified in the defaultExclude instead, (istanbuljs/packages/test-exclude/index.js)

Bonus Points! Code (or Repository) that Reproduces Issue

https://github.com/AndrewFinlay/nyc-instrument-exclude-example

Forensic Information

Operating System: macOS High Sierra
Environment Information:
node v8.11.1
npm v6.1.0
├── angular-mocks@1.4.9
├── findup-sync@2.0.0
├── istanbul@0.4.5
├── jest-cli@23.0.0
├── jest-localstorage-mock@2.2.0
├── jsdom@11.11.0
├── lodash@4.17.10
├── nyc@13.0.0
├── protractor-istanbul-plugin@2.0.0
├── protractor-jasmine2-screenshot-reporter@0.5.0
├── sinon@5.0.10
├── slug@0.9.1
└── source-map-support@0.5.6

After doing some digging it seems that the nyc instrumenter simply isn't using the include/exclude parameters from the config. I'm pretty certain that it's the same issue referenced in #596, and related to #573

When NYC is configured in "commands/instrument.js" it excludes any configuration setup in "config-util.js". This means that it will fallback onto the defaults set in "istanbul/test-exclude/index.js".

The good news is it looks like a pretty easy fix, the bad news is I'm assuming that specifying exclude/include paths in the instrument code is desired behaviour. So I have no idea what would break by changing this. It may be best to play it safe and add a pair of new config options, instrumentInclude and instrumentExclude.

Let me know what you think of this PR #893.

@AndrewFinlay AndrewFinlay changed the title Instrumenter ignores excluded files and folders Instrumenter doesn't ignore excluded files and folders Jul 16, 2018
@AndrewFinlay AndrewFinlay changed the title Instrumenter doesn't ignore excluded files and folders Instrumenter should ignore excluded files and folders Jul 16, 2018
@felixfbecker
Copy link

I think I am seeing the same issue. I am trying to exclude test files because the instrumentation breaks Puppeteer's page.evaluate() (because it calls function.toString() and sends it to the browser to evaluate, which is missing the coverage globals). nyc is properly ignoring the files from the final report, but they are still being instrumented, which breaks Puppeteer. /* istanbul ignore file */ at the top of the file doesn't work either.

@AndrewFinlay
Copy link
Contributor Author

Bump, stale bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants