Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions test/config/store.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { describe, it, afterEach } from 'node:test'
import { describe, it, beforeEach, afterEach } from 'node:test'
import assert from 'node:assert/strict'
import { setResolvedConfig, getResolvedConfig } from '../../src/config/store.ts'
import { setResolvedConfig, getResolvedConfig, _testResetConfig } from '../../src/config/store.ts'
import type { ResolvedConfig } from '../../src/config/types.ts'

const sampleConfig: ResolvedConfig = {
Expand All @@ -14,9 +14,15 @@ const sampleConfig: ResolvedConfig = {
},
}

// The store is a module-level singleton. Under `bun test` all files share one
// process, so other suites can leave state behind; reset before each test (not
// just after) so assertions about the initial state are order-independent.
beforeEach(() => {
_testResetConfig()
})

afterEach(() => {
// reset singleton state between tests
setResolvedConfig(undefined as unknown as ResolvedConfig)
_testResetConfig()
})

describe('store', () => {
Expand Down
Loading