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

Testing: Not possible to set collectCoverageFrom (and possibly other options) #2557

Closed
charlieTheBotDev opened this issue Jul 7, 2020 · 1 comment · Fixed by #2613
Closed
Labels

Comments

@charlieTheBotDev
Copy link
Contributor

Stencil version:

 @stencil/core@1.16.0

I'm submitting a:

[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://stencil-worldwide.herokuapp.com/ or https://forum.ionicframework.com/

Current behavior:

Setting testing.collectCoverageFrom is not passed to Jest.

Expected behavior:

It should pass it through

Steps to reproduce:

Add collectCoverageFrom with a value (i.e. with a single file, or a set with negation) and set collectCoverage to true. The coverage generated will not match the expectation passed in.

Related code:
https://github.com/ionic-team/stencil/blob/master/src/testing/jest/jest-config.ts#L39
https://github.com/ionic-team/stencil/blob/master/src/testing/jest/jest-config.ts#L45-L49

Other information:

https://github.com/ionic-team/stencil/blob/master/src/testing/jest/jest-config.ts#L39

There is no default defined for this option (see collectCoverageFrom docs and, being undefined means that it is not looped over in the function here:
https://github.com/ionic-team/stencil/blob/master/src/testing/jest/jest-config.ts#L45-L49

It's also worth noting that collectCoverageFrom is potentially not the only option affected by this as anything set to undefined in the defaults will not be set (unless set in the subsequent block of if statements)

I'll raise a PR for this if I get a chance

Workaround
Assume that all files loaded by Jest will be covered and use coveragePathIgnorePatterns to negate anything you don't want.

If a file is not covered in your output, it means you have not loaded it in any of your tests.

Note: Puppeteer doesn't contribute to coverage so don't expect e2e tests to add to coverage 😉

@irega
Copy link
Contributor

irega commented Aug 5, 2020

We need this for our project too. Created PR for it #2613

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants