From c1c42ebc5dbf0cd9be32673487dedccada33f688 Mon Sep 17 00:00:00 2001 From: Arya Emami Date: Thu, 16 May 2024 06:51:00 -0500 Subject: [PATCH] Fix issues related to stubbing envs in `createReducer.test.ts` --- packages/toolkit/src/tests/createReducer.test.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/packages/toolkit/src/tests/createReducer.test.ts b/packages/toolkit/src/tests/createReducer.test.ts index 78c8a25eec..0c69ec9db9 100644 --- a/packages/toolkit/src/tests/createReducer.test.ts +++ b/packages/toolkit/src/tests/createReducer.test.ts @@ -64,14 +64,12 @@ describe('createReducer', () => { }) describe('Deprecation warnings', () => { - let originalNodeEnv = process.env.NODE_ENV - beforeEach(() => { vi.resetModules() }) afterEach(() => { - process.env.NODE_ENV = originalNodeEnv + vi.unstubAllEnvs() }) it('Throws an error if the legacy object notation is used', async () => { @@ -94,7 +92,7 @@ describe('createReducer', () => { }) it('Crashes in production', async () => { - process.env.NODE_ENV = 'production' + vi.stubEnv('NODE_ENV', 'production') const { createReducer } = await import('../createReducer') const wrapper = () => { const dummyReducer = (createReducer as CreateReducer)( @@ -109,15 +107,13 @@ describe('createReducer', () => { }) describe('Immer in a production environment', () => { - let originalNodeEnv = process.env.NODE_ENV - beforeEach(() => { vi.resetModules() - process.env.NODE_ENV = 'production' + vi.stubEnv('NODE_ENV', 'production') }) afterEach(() => { - process.env.NODE_ENV = originalNodeEnv + vi.unstubAllEnvs() }) test('Freezes data in production', async () => {