Skip to content

Commit

Permalink
fix: do not merge arrays (fix #725) (#728)
Browse files Browse the repository at this point in the history
  • Loading branch information
DerYeger committed Feb 11, 2022
1 parent 506cc20 commit 92fb244
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
6 changes: 0 additions & 6 deletions packages/vitest/src/utils/base.ts
Expand Up @@ -87,12 +87,6 @@ export function deepMerge<T extends object = object, S extends object = T>(targe

deepMerge(target[key] as any, source[key] as any)
}
else if (Array.isArray(source[key])) {
if (!target[key])
target[key] = [] as any

(target[key] as any).push(...source[key] as any)
}
else {
target[key] = source[key] as any
}
Expand Down
4 changes: 2 additions & 2 deletions test/core/test/utils.spec.ts
Expand Up @@ -3,7 +3,7 @@ import { deepMerge } from '../../../packages/vitest/src/utils'
import { deepMergeSnapshot } from '../../../packages/vitest/src/integrations/snapshot/port/utils'

describe('deepMerge', () => {
test('non plain objects retain their prototype, arrays are merging, plain objects are merging', () => {
test('non plain objects retain their prototype, arrays are not merging, plain objects are merging', () => {
class Test {
baz = 'baz'

Expand Down Expand Up @@ -37,7 +37,7 @@ describe('deepMerge', () => {

expect(merged.test instanceof Test).toBe(true)
expect(merged.num).toBe(40)
expect(merged.array).toEqual([1, 2, 3, 4])
expect(merged.array).toEqual([3, 4])
expect(merged.obj).toEqual({
foo: 'foo',
baz: 'baz',
Expand Down

0 comments on commit 92fb244

Please sign in to comment.