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

[v4.0] coverage map #588

Merged
merged 7 commits into from
Jun 7, 2020
Merged

Conversation

connectdotz
Copy link
Collaborator

@connectdotz connectdotz commented May 26, 2020

reference v4 #576 coverage map issue

change summary

  • upgraded istanbul dependencies
  • fixed coverage map merge issue.
  • adapt to the latest istanbul API. The major change is mapStore.transformCoverage has become async operation, therefore we need a way to refresh the coverage codeLens and overlay asynchronously (see JestExt. _updateCoverageMap)
  • fixed a few lint warnings
  • a bit optimization: remove coverage maps when coverage is off

fix #559
fix #551
fix #524

@coveralls
Copy link

coveralls commented May 26, 2020

Pull Request Test Coverage Report for Build 783

  • 27 of 28 (96.43%) changed or added relevant lines in 7 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.1%) to 90.623%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/JestExt.ts 7 8 87.5%
Files with Coverage Reduction New Missed Lines %
src/Coverage/Formatters/GutterFormatter/index.ts 1 97.87%
Totals Coverage Status
Change from base Build 773: 0.1%
Covered Lines: 932
Relevant Lines: 1004

💛 - Coveralls

@connectdotz connectdotz changed the title upgrade istanbul dependencies [v4.0] coverage map May 26, 2020
@connectdotz connectdotz mentioned this pull request May 26, 2020
15 tasks
@connectdotz connectdotz added this to the v4.0 milestone May 26, 2020
@connectdotz connectdotz requested a review from seanpoulter May 26, 2020 16:44
@connectdotz
Copy link
Collaborator Author

ping @seanpoulter

Copy link
Member

@seanpoulter seanpoulter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, sorry for the slow review. I still haven't taken time to run it :/.

It looks good. The optimization when the visibility changes looks a bit backwards to me, but otherwise another job well done. 👏 Ship it!

Should we notify the folks on the issues to beta test it for you?

Comment on lines 48 to 50
if (!visible) {
this.init();
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm probably overlooking something, but it seems funny to reset the coverage and source map when the document is no longer visible. I would have expected that we remove the entry from the map.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the visibility here means the coverage, it is not visible when people toggle the coverage off. And when that happens we remove all maps in the init method by reinitializing the map. Maybe the name is confusing? it might be more accurate to call it reset.

src/Coverage/Formatters/helpers.ts Outdated Show resolved Hide resolved
src/JestExt.ts Outdated Show resolved Hide resolved
});
});

describe('getFileCoverage()', () => {
it('should return the file coverage if found', () => {
it('should return the file coverage if found', async () => {
expect.hasAssertions();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

{ pattern: '**/*.{ts,tsx,js,jsx}' },
new CoverageCodeLensProvider((uri) => extensionManager.getByDocUri(uri))
),
vscode.languages.registerCodeLensProvider(languages, extensionManager.coverageCodeLensProvider),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I appreciate that you've cleaned this up.

tests/Coverage/CoverageMapProvider.test.ts Show resolved Hide resolved
tests/Coverage/CoverageMapProvider.test.ts Show resolved Hide resolved
});
it('visibility = true => no-op', () => {
const sut = new CoverageMapProvider();
jest.clearAllMocks();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we pull these two clearAllMocks() out into one beforeEach?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the following 2 methods are called in both the constructor and the onVisiblityChange, thus reset the mock after constructor, but there is another way to clear the confusion, I will just call the expect in both places...

expect(coverageCodeLensProvider.coverageChanged).toBeCalled();
expect(sut.coverageOverlay.updateVisibleEditors).toBeCalled();
});
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah, that's a lot of nulls changing. At some point (not in this PR) we should consider wrapping the constructor and using default parameters:

const extension = ({
  context = null,
  coverageCodeLensProvider = null,
  debugCodeLensProvider = null,
  debugConfigurationProvider = null,
  failDiagnostics = null,
  instanceSettings = null,
  jestWorkspace = null,
  outputChannel = null,
  pluginSettings = null,
  workspaceFolder = null,
}) => new JestExt(
  context
  workspaceFolder,
  jestWorkspace,
  outputChannel,
  pluginSettings,
  debugCodeLensProvider,
  debugConfigurationProvider,
  failDiagnostics,
  instanceSettings,
  coverageCodeLensProvider,
);

so we end up with an idea what's null or renamed:

      const sut = extension({
         coverageCodeLensProvider
         debugCodeLensProvider,
         debugConfigurationProvider,
         jestWorkspace: projectWorkspace,
         outputChannel: channelStub,
         pluginSettings: extensionSettings,
         workspaceFolder,
       });

tests/JestExt.test.ts Show resolved Hide resolved
@connectdotz
Copy link
Collaborator Author

@seanpoulter nice to see you reviewing this, I will take a look tomorrow, thanks.

connectdotz and others added 5 commits June 7, 2020 11:48
Co-authored-by: Sean Poulter <sean.poulter+gh@gmail.com>
Co-authored-by: Sean Poulter <sean.poulter+gh@gmail.com>
@connectdotz connectdotz merged commit d84d24f into jest-community:master Jun 7, 2020
@connectdotz connectdotz deleted the coverage-upgrade branch June 7, 2020 16:31
@connectdotz
Copy link
Collaborator Author

Should we notify the folks on the issues to beta test it for you?

yeah, we should build a beta soon so people can test it, but I want to include the matching logic as that is a much bigger change, don't want people to test it too many times...

legend1202 pushed a commit to legend1202/vscode-jest that referenced this pull request Jun 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants