1- import { mustCall , mustCallAtLeast , skip } from '../common/index.mjs' ;
1+ import { mustCall , mustCallAtLeast } from '../common/index.mjs' ;
22import * as fixtures from '../common/fixtures.mjs' ;
33import { describe , it , beforeEach , run } from 'node:test' ;
44import assert from 'node:assert' ;
@@ -8,9 +8,7 @@ import path from 'node:path';
88import { spawn } from 'node:child_process' ;
99import { once } from 'node:events' ;
1010
11- if ( ! process . config . variables . node_use_amaro ) {
12- skip ( 'Requires Amaro' ) ;
13- }
11+ const onlyWithAmaro = { skip : ! process . config . variables . node_use_amaro } ;
1412
1513const testFixtures = fixtures . path ( 'test-runner' , 'global-setup-teardown' ) ;
1614const runnerFixture = fixtures . path ( 'test-runner' , 'test-runner-global-hooks.mjs' ) ;
@@ -166,31 +164,29 @@ describe('require(\'node:test\').run with global hooks', { concurrency: false },
166164 assert . strictEqual ( content , 'Setup part, Teardown part' ) ;
167165 } ) ;
168166
169- it ( 'should run TypeScript globalSetup and globalTeardown functions' ,
170- onlyWithAmaro ,
171- async ( ) => {
172- const setupFlagPath = tmpdir . resolve ( 'setup-executed-ts.tmp' ) ;
173- const teardownFlagPath = tmpdir . resolve ( 'teardown-executed-ts.tmp' ) ;
174-
175- const { results } = await runTestWithGlobalHooks ( {
176- globalSetupFile : 'basic-setup-teardown.ts' ,
177- runnerEnv : {
178- SETUP_FLAG_PATH : setupFlagPath ,
179- TEARDOWN_FLAG_PATH : teardownFlagPath
180- } ,
181- isolation
182- } ) ;
183-
184- assert . strictEqual ( results . passed , 2 ) ;
185- assert . strictEqual ( results . failed , 0 ) ;
186- // After all tests complete, the teardown should have run
187- assert . ok ( fs . existsSync ( teardownFlagPath ) , 'Teardown flag file should exist' ) ;
188- const content = fs . readFileSync ( teardownFlagPath , 'utf8' ) ;
189- assert . strictEqual ( content , 'Teardown was executed' ) ;
190-
191- // Setup flag should have been removed by teardown
192- assert . ok ( ! fs . existsSync ( setupFlagPath ) , 'Setup flag file should have been removed' ) ;
193- } ) ;
167+ it ( 'should run TypeScript globalSetup and globalTeardown functions' , onlyWithAmaro , async ( ) => {
168+ const setupFlagPath = tmpdir . resolve ( 'setup-executed-ts.tmp' ) ;
169+ const teardownFlagPath = tmpdir . resolve ( 'teardown-executed-ts.tmp' ) ;
170+
171+ const { results } = await runTestWithGlobalHooks ( {
172+ globalSetupFile : 'basic-setup-teardown.ts' ,
173+ runnerEnv : {
174+ SETUP_FLAG_PATH : setupFlagPath ,
175+ TEARDOWN_FLAG_PATH : teardownFlagPath
176+ } ,
177+ isolation
178+ } ) ;
179+
180+ assert . strictEqual ( results . passed , 2 ) ;
181+ assert . strictEqual ( results . failed , 0 ) ;
182+ // After all tests complete, the teardown should have run
183+ assert . ok ( fs . existsSync ( teardownFlagPath ) , 'Teardown flag file should exist' ) ;
184+ const content = fs . readFileSync ( teardownFlagPath , 'utf8' ) ;
185+ assert . strictEqual ( content , 'Teardown was executed' ) ;
186+
187+ // Setup flag should have been removed by teardown
188+ assert . ok ( ! fs . existsSync ( setupFlagPath ) , 'Setup flag file should have been removed' ) ;
189+ } ) ;
194190
195191 it ( 'should run ESM globalSetup and globalTeardown functions' , async ( ) => {
196192 const setupFlagPath = tmpdir . resolve ( 'setup-executed-esm.tmp' ) ;
0 commit comments