From dc0452d779f4ec1f7e7572a61940d78e5745cc5b Mon Sep 17 00:00:00 2001 From: Arya Emami Date: Tue, 3 Sep 2024 21:25:08 -0500 Subject: [PATCH] Fix issues related to stubbing envs in `getDefaultMiddleware.test.ts` --- packages/toolkit/src/tests/getDefaultMiddleware.test.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/toolkit/src/tests/getDefaultMiddleware.test.ts b/packages/toolkit/src/tests/getDefaultMiddleware.test.ts index b72a959b0b..74e5e7b499 100644 --- a/packages/toolkit/src/tests/getDefaultMiddleware.test.ts +++ b/packages/toolkit/src/tests/getDefaultMiddleware.test.ts @@ -14,10 +14,8 @@ import { buildGetDefaultMiddleware } from '@internal/getDefaultMiddleware' const getDefaultMiddleware = buildGetDefaultMiddleware() describe('getDefaultMiddleware', () => { - const ORIGINAL_NODE_ENV = process.env.NODE_ENV - afterEach(() => { - process.env.NODE_ENV = ORIGINAL_NODE_ENV + vi.unstubAllEnvs() }) describe('Production behavior', () => { @@ -26,7 +24,8 @@ describe('getDefaultMiddleware', () => { }) it('returns an array with only redux-thunk in production', async () => { - process.env.NODE_ENV = 'production' + vi.stubEnv('NODE_ENV', 'production') + const { thunk } = await import('redux-thunk') const { buildGetDefaultMiddleware } = await import( '@internal/getDefaultMiddleware'