Vscode-jest: Code coverage not shown even though `runAllTestsFirst` is set without uncommited changes

Created on 2 Jan 2018  路  2Comments  路  Source: jest-community/vscode-jest

Environment

  1. node -v: 9.3.0
  2. npm -v: 5.5.1
  3. npm ls react-scripts (if you haven鈥檛 ejected): -

  4. Operating system: Windows 10

Steps to Reproduce

  1. Create a git project and setup jest to collect code coverage
  2. Keep vscode's "jest.runAllTestsFirst": true
  3. Commit all changes
  4. Reload jest runner (which starts the initial full test run)

Expected Behavior

Code coverage overlay should be available for the whole time and the whole project.

Actual Behavior

Code coverage overlay works during the initial full test run, but disappears as soon as jest shows No tests found related to files changed since last commit..

As soon as one saves an edit in a covered file code coverage reappears for all tested files (not just the edited one).


If necessary, I could provide a sample repository and further instructions.

bug coverage

All 2 comments

Good timing @stephtr, I've been working on this issue this morning.

When we handle new JSON results from Jest with the updateWithData method, most of the updates are performed by iterating over the empty testResults array (which causes no action). Unlike the test results, the coverage map is empty and causes (or at least should cause) the overlay to be removed. To prevent this, we need to bypass the coverage overlay update when the JSON update was preceeded by "No tests found" is on stderr.

@orta, are you OK with a PR to fix this in jest-editor-support? I'm just cleaning up the tests that add an argument when we emit the JSON data:

this.emit('executableJSON', JSON.parse(data), {noTestsFound});

Yep, makes sense to me

Was this page helpful?
0 / 5 - 0 ratings