jestjs/jest

Inconsistent output with --coverage

Open

#7,176 opened on Oct 16, 2018

View on GitHub
 (16 comments) (0 reactions) (0 assignees)TypeScript (45,361 stars) (6,653 forks)batch import
:rocket: EnhancementHelp WantedPinned

Description

🐛 Bug Report

When code-covered files exist in the root directory, the --coverage output will include the name of the directory. This is not desirable in CI scenarios where the working directory will vary.

Actual

https://github.com/azz/jest-istanbul-issue/tree/master

When a file exists at root (above), the output is:

$ jest --coverage
 PASS  ./index.test.js
 PASS  src/file.test.js
-------------------------|----------|----------|----------|----------|-------------------|
File                     |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
-------------------------|----------|----------|----------|----------|-------------------|
All files                |      100 |      100 |      100 |      100 |                   |
 jest-istanbul-issue     |      100 |      100 |      100 |      100 |                   |
  index.js               |      100 |      100 |      100 |      100 |                   |
 jest-istanbul-issue/src |      100 |      100 |      100 |      100 |                   |
  file.js                |      100 |      100 |      100 |      100 |                   |
-------------------------|----------|----------|----------|----------|-------------------|

Test Suites: 2 passed, 2 total
Tests:       2 passed, 2 total
Snapshots:   0 total
Time:        1.983s
Ran all test suites.
Done in 2.98s.

Note the jest-istanbul-issue above.

Expected

https://github.com/azz/jest-istanbul-issue/tree/good-case

When it doesn't:

$ jest --coverage
 PASS  src/file.test.js
  √ it works (1ms)

----------|----------|----------|----------|----------|-------------------|
File      |  % Stmts | % Branch |  % Funcs |  % Lines | Uncovered Line #s |
----------|----------|----------|----------|----------|-------------------|
All files |      100 |      100 |      100 |      100 |                   |
 file.js  |      100 |      100 |      100 |      100 |                   |
----------|----------|----------|----------|----------|-------------------|
Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        1.708s
Ran all test suites.
Done in 2.76s.

Contributor guide