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

Check threshold only for changed files #10082

Closed

Conversation

7rulnik
Copy link

@7rulnik 7rulnik commented May 25, 2020

Summary

Currently if we use findRelatedTests jest will check thresholds for every group from coverageThreshold. So it always fails and it's impossible to run tests only for changed files on CI for example.

This fix filters thresholdGroups by files from coveredFilesSortedIntoThresholdGroup if findRelatedTests set and checks only filtered groups.

If it looks good, I will add tests and changelog entry.

Also we can add same logic for all changes-related options: --onlyChanged, --changedFilesWithAncestor, --changedSince.

Test plan

Add coverageThreshold in jest config

  coverageThreshold: {
    'packages/jest-each': {
      branches: 100,
    },
  }

and then run some tests with coverage not related to one in threshold configuration. For example: yarn jest --findRelatedTests packages/jest-snapshot/src/dedentLines.ts --coverage --collectCoverageFrom packages/jest-snapshot/src/dedentLines.ts (collectCoverageFrom is required beacuse of #10083 issue). It should pass

@7rulnik 7rulnik force-pushed the collect-coverage-from-threshold-fix branch from 787472f to 89c77fb Compare May 25, 2020 00:31
@7rulnik 7rulnik changed the title Check threshold only for files passed via collectCoverageFrom WIP: Check threshold only for files passed via collectCoverageFrom May 25, 2020
@7rulnik 7rulnik force-pushed the collect-coverage-from-threshold-fix branch from 89c77fb to 0764e83 Compare May 25, 2020 00:59
@7rulnik 7rulnik changed the title WIP: Check threshold only for files passed via collectCoverageFrom Check threshold only for files passed via collectCoverageFrom May 25, 2020
@7rulnik 7rulnik changed the title Check threshold only for files passed via collectCoverageFrom Check threshold only for changed files May 25, 2020
@jeysal
Copy link
Contributor

jeysal commented Oct 19, 2020

I'm sorry this was left lying around so long until I found it in my inbox 😬
This looks good to me - obviously a run with findRelatedTests is stilly likely to produce lower coverage and thus miss the coverage target, but with this it may in some cases hit the thresholds...
If you add test and changelog I'd merge :)

@jeysal jeysal requested a review from SimenB October 19, 2020 22:44
@7rulnik
Copy link
Author

7rulnik commented Oct 19, 2020

Wow! I almost forgot about this PR. Yeah, for sure, will try to find some time on this or next week.

What about other's changed-related flags?

@github-actions
Copy link

github-actions bot commented Sep 8, 2022

This PR is stale because it has been open 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Sep 8, 2022
@github-actions
Copy link

github-actions bot commented Oct 8, 2022

This PR was closed because it has been stalled for 30 days with no activity. Please open a new PR if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this Oct 8, 2022
@github-actions
Copy link

github-actions bot commented Nov 8, 2022

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants