Skip to content

Nyc processing files not covered by include when all is enabled. #913

Description

@AGrzes

Link to bug demonstration repository.

https://github.com/AGrzes/nyc-include-issue

Expected Behavior

When include is specified in nyc configuration it instrument only files matching include.

Observed Behavior

Nyc processes all files then discards those that not match include. In conjunction with ts-node it leads to compilation of unnecessary files and unexpected failures.

For example in demonstration repository

$ npm test

> nyc-issue@1.0.0 test /home/agrzes/git/nyc-issue
> nyc mocha test/**/*.{ts,tsx}


/home/agrzes/git/nyc-issue/node_modules/ts-node/src/index.ts:261
    return new TSError(diagnosticText, diagnosticCodes)
           ^
TSError: ⨯ Unable to compile TypeScript:
bad/bad.ts(1,6): error TS1005: ';' expected.
bad/bad.ts(1,9): error TS1005: ';' expected.
bad/bad.ts(1,13): error TS1005: ';' expected.
bad/bad.ts(1,15): error TS1005: ';' expected.
bad/bad.ts(1,23): error TS1005: ';' expected.
bad/bad.ts(1,26): error TS1005: ';' expected.
bad/bad.ts(1,1): error TS2304: Cannot find name 'This'.
bad/bad.ts(1,6): error TS2304: Cannot find name 'is'.
bad/bad.ts(1,9): error TS2304: Cannot find name 'not'.
bad/bad.ts(1,13): error TS2304: Cannot find name 'a'.
bad/bad.ts(1,15): error TS2304: Cannot find name 'correct'.
bad/bad.ts(1,23): error TS2304: Cannot find name 'ts'.
bad/bad.ts(1,26): error TS2552: Cannot find name 'file'. Did you mean 'File'?

    at createTSError (/home/agrzes/git/nyc-issue/node_modules/ts-node/src/index.ts:261:12)
    at getOutput (/home/agrzes/git/nyc-issue/node_modules/ts-node/src/index.ts:367:40)
    at Object.compile (/home/agrzes/git/nyc-issue/node_modules/ts-node/src/index.ts:558:11)
    at Object.m._compile (/home/agrzes/git/nyc-issue/node_modules/ts-node/src/index.ts:439:43)
    at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Object.require.extensions.(anonymous function) [as .ts] (/home/agrzes/git/nyc-issue/node_modules/ts-node/src/index.ts:442:12)
    at NYC._readTranspiledSource (/home/agrzes/git/nyc-issue/node_modules/nyc/index.js:165:26)
    at NYC.addFile (/home/agrzes/git/nyc-issue/node_modules/nyc/index.js:149:21)
    at /home/agrzes/git/nyc-issue/node_modules/nyc/index.js:181:11
    at /home/agrzes/git/nyc-issue/node_modules/nyc/index.js:250:5
npm ERR! Test failed.  See above for more details.

Forensic Information

Operating System: Linux agrzes-desktop 4.15.0-33-generic #36~16.04.1-Ubuntu SMP Wed Aug 15 17:21:05 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Environment Information: https://gist.github.com/AGrzes/a3e87bbb58f592b499f005bdd2ad2a21

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions