@@ -2,7 +2,7 @@ import * as common from '../common/index.mjs';
22import { before , describe , it , run } from 'node:test' ;
33import assert from 'node:assert' ;
44import { spawnSync } from 'node:child_process' ;
5- import { cp , writeFile } from 'node:fs/promises' ;
5+ import { cp } from 'node:fs/promises' ;
66import { join , sep } from 'node:path' ;
77import tmpdir from '../common/tmpdir.js' ;
88import fixtures from '../common/fixtures.js' ;
@@ -58,30 +58,9 @@ describe('run() coverage with isolation: none', skipIfNoInspector, () => {
5858 }
5959
6060 it ( 'is idempotent when --experimental-test-coverage is also passed' , async ( ) => {
61- const runnerPath = join ( tmpdir . path , 'runner.mjs' ) ;
62- await writeFile ( runnerPath , `\
63- import { run } from 'node:test';
64- import { join } from 'node:path';
65-
66- const stream = run({
67- files: [join(import.meta.dirname, 'tests', 'foo.test.mjs')],
68- coverage: true,
69- isolation: 'none',
70- cwd: import.meta.dirname,
71- });
72- stream.on('test:fail', () => process.exit(10));
73- let summary;
74- stream.on('test:coverage', (event) => { summary = event.summary; });
75- for await (const _ of stream);
76- if (!summary || summary.files.length === 0) process.exit(11);
77- const hasSrc = summary.files.some((f) => f.path.endsWith('foo.mjs') && !f.path.endsWith('foo.test.mjs'));
78- const hasTest = summary.files.some((f) => f.path.endsWith('foo.test.mjs'));
79- if (!hasSrc) process.exit(12);
80- if (hasTest) process.exit(13);
81- ` ) ;
8261 const result = spawnSync ( process . execPath , [
8362 '--experimental-test-coverage' ,
84- runnerPath ,
63+ join ( tmpdir . path , 'runner.mjs' ) ,
8564 ] , { cwd : tmpdir . path } ) ;
8665 assert . strictEqual (
8766 result . status ,
0 commit comments