Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Considering this file tree:
app/services/
├── categories
│ ├── Parser.js
│ ├── __mocks__
│ │ └── Parser.js
│ ├── actions.js
│ ├── constants.js
│ ├── reducer
│ │ ├── data.js
│ │ ├── index.js
│ │ ├── list.js
│ │ └── tests
│ │ ├── data.test.js
│ │ └── list.test.js
│ ├── sagas.js
│ ├── selectors.js
│ └── tests
│ ├── Parser.test.js
│ ├── actions.test.js
│ └── selectors.test.js
├── index.js
├── items
│ ├── Parser.js
│ ├── __mocks__
│ │ └── Parser.js
│ ├── actions.js
│ ├── constants.js
│ ├── reducer
│ │ ├── data.js
│ │ ├── delete.js
│ │ ├── fetch.js
│ │ ├── index.js
│ │ ├── list.js
│ │ ├── next.js
│ │ ├── tests
│ │ │ ├── data.test.js
│ │ │ ├── delete.test.js
│ │ │ ├── fetch.test.js
│ │ │ ├── list.test.js
│ │ │ ├── next.test.js
│ │ │ └── update.test.js
│ │ └── update.js
│ ├── sagas.js
│ ├── selectors.js
│ └── tests
│ ├── Parser.test.js
│ ├── actions.test.js
│ └── selectors.test.js
└── router
├── reducer.js
├── selectors.js
└── tests
├── reducer.test.js
└── selectors.test.js
And my coverage when I run the npm run jest -- --coverage app/services/items/reducer/tests/list.test.js command:
---------------------------------|----------|----------|----------|----------|----------------|
File | % Stmts | % Branch | % Funcs | % Lines |Uncovered Lines |
---------------------------------|----------|----------|----------|----------|----------------|
All files | 5.98 | 8.41 | 10.75 | 9.14 | |
services/categories | 0 | 0 | 0 | 0 | |
Parser.js | 0 | 0 | 0 | 0 |1,3,22,27,28,30 |
actions.js | 0 | 100 | 0 | 0 |... 20,27,34,38 |
constants.js | 0 | 100 | 100 | 0 | 1,7,13 |
selectors.js | 0 | 100 | 0 | 0 |1,7,12,20,23,25 |
services/categories/reducer | 33.33 | 45.83 | 33.33 | 42.11 | |
data.js | 0 | 0 | 0 | 0 |... 26,30,32,34 |
list.js | 100 | 100 | 100 | 100 | |
services/items/reducer | 70 | 80.82 | 87.5 | 73.21 | |
data.js | 100 | 100 | 100 | 100 | |
delete.js | 100 | 100 | 100 | 100 | |
fetch.js | 100 | 100 | 100 | 100 | |
list.js | 0 | 0 | 0 | 0 |... 40,42,44,46 |
next.js | 100 | 100 | 100 | 100 | |
update.js | 100 | 100 | 100 | 100 | |
services/router | 0 | 0 | 0 | 0 | |
reducer.js | 0 | 0 | 0 | 0 |... 32,39,41,43 |
selectors.js | 0 | 100 | 0 | 0 |1,7,12,20,23,25 |
---------------------------------|----------|----------|----------|----------|----------------|
(I removed some unrelated part of the coverage and file tree).
Jest coverage targets the services/categories/reducer/list file when running the tests on services/items/reducer/list. I import the right file and it is actually testing the right file, meaning that voluntarily changing something in services/items/reducer/list makes the tests fail.
If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test.
This comes from a private repository and I don't think I can give you a runnable example 😞
What is the expected behavior?
The coverage should target the right file.
Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
OS: MacOS Sierra 10.12.5 (16F73)
Node: v7.10.0
Yarn: v0.24.6
Jest: v20.0.4
Jest configuration:
"jest": {
"collectCoverageFrom": [
"app/components/**/*.{js,jsx}",
"app/services/**/*.{js,jsx}",
"app/utils/**/*.{js,jsx}",
"app/containers/**/reducer.js",
"app/containers/**/selectors.js",
"app/containers/**/actions.js",
"app/containers/**/constants.js",
"!app/**/*.test.{js,jsx}",
"!app/*/RbGenerated*/*.{js,jsx}",
"!app/app.js",
"!app/routes.js",
"!app/themes.js",
"!app/global-styles.js",
"!app/**/sagas.js",
"!app/services/form/intlForm.js",
"!app/services/**/index.js"
],
"coverageThreshold": {
"global": {
"statements": 98,
"branches": 91,
"functions": 98,
"lines": 98
}
},
"moduleDirectories": [
"node_modules",
"app"
],
"moduleNameMapper": {
".*\\.(css|less|styl|scss|sass)$": "<rootDir>/internals/mocks/cssModule.js",
".*\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/internals/mocks/image.js"
},
"setupTestFrameworkScriptFile": "<rootDir>/internals/testing/test-bundler.js",
"testRegex": "tests/.*\\.test\\.js$"
},
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
Considering this file tree:
And my coverage when I run the
npm run jest -- --coverage app/services/items/reducer/tests/list.test.jscommand:(I removed some unrelated part of the coverage and file tree).
Jest coverage targets the
services/categories/reducer/listfile when running the tests onservices/items/reducer/list. I import the right file and it is actually testing the right file, meaning that voluntarily changing something inservices/items/reducer/listmakes the tests fail.If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can
yarn installandyarn test.This comes from a private repository and I don't think I can give you a runnable example 😞
What is the expected behavior?
The coverage should target the right file.
Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
OS: MacOS Sierra 10.12.5 (16F73)
Node: v7.10.0
Yarn: v0.24.6
Jest: v20.0.4
Jest configuration: