Skip to content

Commit

Permalink
Fix issues related to stubbing envs in createReducer.test.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
aryaemami59 committed May 16, 2024
1 parent 8625470 commit c1c42eb
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions packages/toolkit/src/tests/createReducer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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)(
Expand All @@ -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 () => {
Expand Down

0 comments on commit c1c42eb

Please sign in to comment.