From c092d76260fb752eb6b7c735278c083e7227a805 Mon Sep 17 00:00:00 2001 From: Daishi Kato Date: Sat, 9 Mar 2024 08:51:05 +0900 Subject: [PATCH] chore(tests): suppress expected warnings (#2398) --- tests/devtools.test.tsx | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/tests/devtools.test.tsx b/tests/devtools.test.tsx index 71d4f9cc88..6e44e1a81c 100644 --- a/tests/devtools.test.tsx +++ b/tests/devtools.test.tsx @@ -636,26 +636,37 @@ describe('with redux middleware', () => { }) }) -it('works in non-browser env', async () => { - const originalWindow = global.window - global.window = undefined as any +describe('different envs', () => { + let savedConsoleWarn: any + beforeEach(() => { + savedConsoleWarn = console.warn + console.warn = vi.fn() + }) + afterEach(() => { + console.warn = savedConsoleWarn + }) - expect(() => { - createStore(devtools(() => ({ count: 0 }), { enabled: true })) - }).not.toThrow() + it('works in non-browser env', async () => { + const originalWindow = global.window + global.window = undefined as any - global.window = originalWindow -}) + expect(() => { + createStore(devtools(() => ({ count: 0 }), { enabled: true })) + }).not.toThrow() -it('works in react native env', async () => { - const originalWindow = global.window - global.window = {} as any + global.window = originalWindow + }) - expect(() => { - createStore(devtools(() => ({ count: 0 }), { enabled: true })) - }).not.toThrow() + it('works in react native env', async () => { + const originalWindow = global.window + global.window = {} as any - global.window = originalWindow + expect(() => { + createStore(devtools(() => ({ count: 0 }), { enabled: true })) + }).not.toThrow() + + global.window = originalWindow + }) }) it('preserves isRecording after setting from devtools', async () => {