Skip to content

Commit 67ceb9c

Browse files
committed
chore: ensure correct cwd is mocked when run build plugin steps in tests
1 parent c31a440 commit 67ceb9c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tests/utils/fixture.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ export async function runPluginStep(
199199
step: 'onPreBuild' | 'onBuild' | 'onPostBuild' | 'onEnd',
200200
constants: Partial<NetlifyPluginConstants> = {},
201201
) {
202+
// `invokeFunction` also does cwd mocking (to function directory in that case),
203+
// so in case `runPluginStep` is executed after `invokeFunction`,
204+
// we ensure the cwd is set to fixture root again
205+
vi.spyOn(process, 'cwd').mockReturnValue(ctx.cwd)
206+
202207
const stepFunction = (await import('../../src/index.js'))[step]
203208

204209
let netlifyConfig = {

0 commit comments

Comments
 (0)