From e86ce47ac5a333b1ca94a86b950f87789dedc855 Mon Sep 17 00:00:00 2001 From: gwansikk Date: Tue, 3 Dec 2024 16:29:00 +0900 Subject: [PATCH] test: simplify console mocks --- .../react-query/src/bin/utils/switchVersion.spec.ts | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/react-query/src/bin/utils/switchVersion.spec.ts b/packages/react-query/src/bin/utils/switchVersion.spec.ts index 0870d0ee6..cd17028a1 100644 --- a/packages/react-query/src/bin/utils/switchVersion.spec.ts +++ b/packages/react-query/src/bin/utils/switchVersion.spec.ts @@ -1,4 +1,3 @@ -import type { MockInstance } from 'vitest' import { copy } from './copy' import { switchVersion } from './switchVersion' @@ -7,16 +6,12 @@ vi.mock('./copy', () => ({ })) describe('switchVersion', () => { - let consoleLogSpy: MockInstance - let consoleWarnSpy: MockInstance + const consoleLogSpy = vi.spyOn(console, 'log').mockClear() + const consoleWarnSpy = vi.spyOn(console, 'warn').mockClear() beforeEach(() => { - consoleLogSpy = vi.spyOn(console, 'log').mockImplementation(() => {}) - consoleWarnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {}) - }) - - afterEach(() => { - vi.restoreAllMocks() + vi.resetModules() + vi.clearAllMocks() }) it('should log success message when copy function returns true', () => {