Skip to content

Commit 29dfb33

Browse files
authored
chore: ensure tests correctly mock environment variables before loading opts.js (#222)
Move `t.mock()` inside `t.beforeEach()` to ensure `opts.js` reads the correct environment variables after `backupEnv()` clears them. This prevents tests from failing locally due to pre-existing environment variables like `GIT_ASKPASS`. I noticed while running the tests locally, mine was failing, but passing for the CI.
1 parent 0fc4208 commit 29dfb33

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

test/opts.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ const mockFs = {
77
readFileSync: () => '',
88
}
99

10-
const gitOpts = t.mock('../lib/opts.js', {
11-
'node:fs': mockFs,
12-
})
10+
let gitOpts
1311

1412
t.beforeEach(() => {
1513
backupEnv()
14+
gitOpts = t.mock('../lib/opts.js', {
15+
'node:fs': mockFs,
16+
})
1617
})
1718

1819
t.afterEach(() => {

0 commit comments

Comments
 (0)