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

The Coverage Report contains test files #1058

Closed
mateuszsokola opened this issue May 24, 2016 · 6 comments
Closed

The Coverage Report contains test files #1058

mateuszsokola opened this issue May 24, 2016 · 6 comments

Comments

@mateuszsokola
Copy link

mateuszsokola commented May 24, 2016

I'm trying to implement code coverage to my project. Unfortunately i have a problem: I see all test files on my code coverage report and I end up with incorrect code coverage rate.

{
  "name": "blablabla",
  "version": "0.1.0",
  "description": "",
  "homepage": "",
  "main": "index.js",
  "devDependencies": {
    "babel-cli": "^6.9.0",
    "babel-core": "^6.9.0",
    "babel-jest": "^12.1.0",
    "babel-plugin-inline-package-json": "git+http://...",
    "babel-plugin-transform-runtime": "^6.9.0",
    "babel-polyfill": "^6.9.0",
    "babel-preset-es2015": "^6.8.0",
    "babel-preset-es2015-ie": "^6.6.2",
    "babel-runtime": "^6.6.1",
    "babelify": "^7.3.0",
    "browserify": "^13.0.0",
    "graceful-fs": "^4.1.4",
    "gulp": "^3.9.1",
    "gulp-babel": "^6.1.2",
    "gulp-cli": "^1.2.1",
    "gulp-insert": "^0.5.0",
    "gulp-rename": "^1.2.2",
    "gulp-uglify": "^1.5.3",
    "jasmine-reporters": "^2.1.1",
    "jest-cli": "^12.1.0"
  },
  "scripts": {
    "build": "./build.sh",
    "release": "./build.sh && npm publish",
    "test": "./node_modules/.bin/jest",
    "integration": "./integration.sh"
  },
  "jest": {
    "collectCoverage": true,
    "cacheDirectory": "./jest-cache",
    "unmockedModulePathPatterns": [
      "<rootDir>/node_modules/"
    ]
  }
}
Using Jest CLI v12.1.0, jasmine2, babel-jest
 PASS  __tests__/Iterator.test.js (0.843s)
8 tests passed (8 total in 1 test suite, run time 2.385s)
-------------------|----------|----------|----------|----------|----------------|
File               |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
-------------------|----------|----------|----------|----------|----------------|
 src/              |    93.75 |     87.5 |     87.5 |    95.24 |                |
  Iterator.js      |    93.75 |     87.5 |     87.5 |    95.24 |             30 |
 src/__tests__/    |      100 |       75 |      100 |      100 |                |
  Iterator.test.js |      100 |       75 |      100 |      100 |                |
-------------------|----------|----------|----------|----------|----------------|
All files          |    97.59 |    83.33 |    96.15 |    98.55 |                |
-------------------|----------|----------|----------|----------|----------------|

I don't want to use collectCoverageOnlyFrom, because it requires to specify all files one by one

Do you know how to resolve that issue?

VERSION: 12.1.0

@mateuszsokola
Copy link
Author

Version 11.0.2

> jest

Using Jest CLI v11.0.2, jasmine2, babel-jest
 PASS  src/__tests__/Iterator-test.js (0.511s)
8 tests passed (8 total in 1 test suite, run time 2.029s)
--------------|----------|----------|----------|----------|----------------|
File          |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
--------------|----------|----------|----------|----------|----------------|
 src/         |    93.75 |     87.5 |     87.5 |    95.24 |                |
  Iterator.js |    93.75 |     87.5 |     87.5 |    95.24 |             30 |
--------------|----------|----------|----------|----------|----------------|
All files     |    93.75 |     87.5 |     87.5 |    95.24 |                |
--------------|----------|----------|----------|----------|----------------|

@quantizor
Copy link
Contributor

This was fixed in #1039, release date is pending.

@mateuszsokola
Copy link
Author

@yaycmyk Thank you :)

@dcramer
Copy link

dcramer commented Jan 6, 2018

I realize this is quite old at this point, but tracking coverage of test files isn't a bug, but rather a feature. It lets you indicate if a test is actually being executed. It seems with the changes made by this it would be quite complex to include tests in coverage at this point, as you'd likely not want the tests being part of the module paths.

For example, in Python we use this to identify tests which may not have been executed due to e.g. a duplicate name or an invalid name.

@SimenB
Copy link
Member

SimenB commented Jan 6, 2018

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants