From 89f0a0dd37b2892abcd6cbec2e8bcecd29c641a3 Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 8 Mar 2024 08:43:23 -0800 Subject: [PATCH] make run tests pass with global-singleton TAP root obj --- src/run/test/run.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/run/test/run.ts b/src/run/test/run.ts index 58d5a7052..e557e1dbf 100644 --- a/src/run/test/run.ts +++ b/src/run/test/run.ts @@ -28,6 +28,15 @@ type Result = { stderr: string } +// make sure we keep getting a fresh TAP when we re-import fresh +const privSym = Symbol.for('TAP private constructor') +const g = globalThis as typeof globalThis & { + [privSym]?: typeof t +} +t.beforeEach(() => { + delete g[privSym] +}) + const run = async ( cwd: string, args: string[] = [], @@ -429,7 +438,6 @@ ok 1 - this is standard input t.test('build before run if plugins mismatch', async t => { const cwd = process.cwd() t.teardown(() => process.chdir(cwd)) - const { run } = await t.mockImport< typeof import('../dist/esm/run.js') >('../dist/esm/run.js', {