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

fix(jest-config): correctly detect CI environment and update snapshots accordingly #12378

Merged
merged 10 commits into from Feb 13, 2022

Conversation

cola119
Copy link
Contributor

@cola119 cola119 commented Feb 12, 2022

Fixed #12288

Summary

The cause of this problem is that the current implementation for determining option.updateSnapshot does not take into account process.env.CI. We can know the value of process.env.CI in DEFAULT_CONFIG.ci.

Test plan

This PR added test cases for option.updateSnapshot and also fixed type issues by as assertions.

to determine option.updateSnapshot
@cola119 cola119 requested a review from SimenB Feb 13, 2022
@@ -1131,8 +1131,12 @@ export default async function normalize(
newOptions.moduleNameMapper = [];
}

if (argv.ci != null) {
newOptions.ci = argv.ci;
Copy link
Collaborator

@SimenB SimenB Feb 13, 2022

Choose a reason for hiding this comment

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

newOptions already has the default checking the env var in it, so this only overrides that if argv has a value

SimenB
SimenB approved these changes Feb 13, 2022
Copy link
Collaborator

@SimenB SimenB left a comment

thanks!

@codecov-commenter
Copy link

codecov-commenter commented Feb 13, 2022

Codecov Report

Merging #12378 (ab6db25) into main (faef0b4) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #12378      +/-   ##
==========================================
+ Coverage   68.47%   68.48%   +0.01%     
==========================================
  Files         324      324              
  Lines       16967    16969       +2     
  Branches     5060     5061       +1     
==========================================
+ Hits        11618    11622       +4     
+ Misses       5317     5315       -2     
  Partials       32       32              
Impacted Files Coverage Δ
packages/jest-config/src/index.ts 20.73% <ø> (ø)
packages/test-utils/src/config.ts 0.00% <ø> (ø)
packages/jest-config/src/normalize.ts 88.86% <100.00%> (+0.40%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update faef0b4...ab6db25. Read the comment docs.

@SimenB SimenB changed the title fix(jest-config): use the value of process.env.CI to determine option.updateSnapshot fix(jest-config): correctly detect CI environment and update snapshots accordingly Feb 13, 2022
@SimenB SimenB merged commit 4305088 into facebook:main Feb 13, 2022
21 of 26 checks passed
@cola119 cola119 deleted the issue-12288 branch Feb 14, 2022
@sayang35

This comment was marked as spam.

@github-actions
Copy link

github-actions bot commented Mar 17, 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 Mar 17, 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.

[Bug]: Jest incorrectly writes new snapshots in CI
5 participants