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

empty coverage on v14 #1111

Closed
1 task done
bjornstar opened this issue May 10, 2019 · 3 comments
Closed
1 task done

empty coverage on v14 #1111

bjornstar opened this issue May 10, 2019 · 3 comments

Comments

@bjornstar
Copy link

Link to bug demonstration repository

https://github.com/bjornstar/tslint/tree/update-nyc-again

npm i
npm run coverage

Expected Behavior

Report coverage correctly.

With nyc@v13 we get:

=============================== Coverage summary ===============================
Statements   : 37.08% ( 4245/11449 )
Branches     : 24.12% ( 1646/6823 )
Functions    : 33.96% ( 868/2556 )
Lines        : 36.78% ( 3756/10212 )
================================================================================

Observed Behavior

=============================== Coverage summary ===============================
Statements   : Unknown% ( 0/0 )
Branches     : Unknown% ( 0/0 )
Functions    : Unknown% ( 0/0 )
Lines        : Unknown% ( 0/0 )
================================================================================

Troubleshooting steps

  • still occurrring when I put cache: false in my nyc config

Environment Information

  System:
    OS: macOS 10.14.3
    CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
    Memory: 422.64 MB / 16.00 GB
  Binaries:
    Node: 10.15.3 - ~/.nvm/versions/node/v10.15.3/bin/node
    npm: 6.4.1 - ~/.nvm/versions/node/v10.15.3/bin/npm
  npmPackages:
    @babel/code-frame: ^7.0.0 => 7.0.0 
    @types/babel__code-frame: ^7.0.1 => 7.0.1 
    nyc: ^14.1.1 => 14.1.1 
    ts-node: ^3.3.0 => 3.3.0 
    typescript: ~3.4.0 => 3.4.5 

.nycrc:

{
    "include": [
        "build/**/*.js"
    ],
    "extension": [
        ".js"
    ],
    "exclude": [
        "build/test"
    ],
    "reporter": [
        "text-summary",
        "html"
    ],
    "sourceMap": true,
    "all": true
}
@coreyfarrell
Copy link
Member

coreyfarrell commented May 10, 2019

nyc@14 requires that include/exclude/extension settings allow the original source locations. I suspect the following .nycrc will fix your coverage:

{
    "include": [
        "build/**/*.js",
        "src/**/*.ts"
    ],
    "extension": [
        ".js",
        ".ts"
    ],
    "exclude": [
        "**/test"
    ],
    "reporter": [
        "text-summary",
        "html"
    ],
    "sourceMap": true,
    "all": true
}

@bjornstar
Copy link
Author

Thanks a bunch! I'm not sure why I couldn't get it to work when I first tried on v14.0.0

=============================== Coverage summary ===============================
Statements   : 46.31% ( 5007/10812 )
Branches     : 39.94% ( 2664/6670 )
Functions    : 45.46% ( 881/1938 )
Lines        : 46.22% ( 4445/9617 )
================================================================================

@coreyfarrell
Copy link
Member

14.0.0 had a bug that caused havoc when all: true was combined with source-maps.

Conaclos added a commit to coast-team/dotted-logootsplit that referenced this issue Jul 17, 2019
- Separate coverage report and test report
    - npm run test: test only
    - npm run coverage: test + coverage report

nyc 14.x has a "bug" that excludes TypeScript files from the report.
The "bug" is fixed by adding "ts" as extension in the nyc config.
See istanbuljs/nyc#1111 for more details.

nyc 15.x should include "ts" extension by default.
See istanbuljs/nyc#1122 (comment)
Conaclos added a commit to coast-team/dotted-logootsplit that referenced this issue Feb 3, 2023
- Separate coverage report and test report
    - npm run test: test only
    - npm run coverage: test + coverage report

nyc 14.x has a "bug" that excludes TypeScript files from the report.
The "bug" is fixed by adding "ts" as extension in the nyc config.
See istanbuljs/nyc#1111 for more details.

nyc 15.x should include "ts" extension by default.
See istanbuljs/nyc#1122 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants