-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Reapply #7089 and handle arrays of primitives/arrays #8408
Conversation
Can you call out what changed? I expected (maybe wrong) to see an additional reference to (Of course, if the regression tests pass, happy to merge.) |
Ah yes - sorry about that! Description updated.. There is a new |
Codecov Report
@@ Coverage Diff @@
## master #8408 +/- ##
==========================================
+ Coverage 60.58% 60.61% +0.03%
==========================================
Files 269 269
Lines 11052 11066 +14
Branches 2695 2699 +4
==========================================
+ Hits 6696 6708 +12
- Misses 3771 3772 +1
- Partials 585 586 +1
Continue to review full report at Codecov.
|
Could you merge in/rebase on master just to verify CI is happy? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like CI is happy, I left 2 nits. I'll also repeat my comment that was not answered about reusing deepCyclicCopy
: #7089 (comment). Is there anything preventing us from that?
packages/jest-snapshot/src/utils.ts
Outdated
@@ -178,13 +178,37 @@ export const saveSnapshotFile = ( | |||
); | |||
}; | |||
|
|||
const deepMergeArray = (target: Array<any>, source: Array<any>) => { | |||
// Clone target | |||
const mergedOutput = target.slice(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using Array.from(target)
would be more obvious and wouldn't require a comment
packages/jest-snapshot/src/utils.ts
Outdated
// Target is an array | ||
mergedOutput[index] = deepMergeArray(target[index], sourceElement); | ||
} else if (isObject(targetElement)) { | ||
// Target is a (non-array) object - recursively merge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need these comments (line 192 & 188), can you remove these?
@thymikee I was under the impression that your comment referred to the original method:
It does not do that anymore - can you outline what is expensive with the current implementation? |
I'm not concerned about perf in current implementation, sorry if that wasn't clear. I only want to know if we can reuse |
Sorry if I'm being dense, but I'm still not sure I understand. Do you mean using |
Instead of deepMerge altogether |
I might be misunderstanding |
Ok that's fine. @SimenB feel free to merge it :) |
Thanks for being patient with us, @timtrinidad! |
No problem - happy to help! |
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. |
Summary
See #7089 (comment)
The first commit is the simple revert so the second commit outlines the changes from #7089.
deepMergeArray
assumed that the array elements were all objects.deepMerge
again)deepMerge
(which would convert the array into an object) and instead callsdeepMergeArray
directly.Test plan