From ec60b9a28aca13f78493ad62d0f7915293fdaf8d 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 | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/packages/toolkit/src/tests/createReducer.test.ts b/packages/toolkit/src/tests/createReducer.test.ts index 78c8a25eec..c45c645100 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 () => { @@ -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 () => {