1
- import { access , readFile , writeFile } from "fs/promises" ;
2
- import { execSync , type SpawnSyncReturns } from "child_process" ;
3
1
import assert from "node:assert" ;
2
+ import { spawnSync } from "node:child_process" ;
3
+ import { access , readFile , writeFile } from "node:fs/promises" ;
4
4
import { after , describe , test } from "node:test" ;
5
5
6
- const attw = `node ${ new URL ( "../../dist/ index.js " , import . meta. url ) . pathname } ` ;
6
+ const attw = new URL ( "../src/ index.ts " , import . meta. url ) . pathname ;
7
7
const updateSnapshots = process . env . UPDATE_SNAPSHOTS || process . env . U ;
8
8
const testFilter = ( process . env . TEST_FILTER || process . env . T ) ?. toLowerCase ( ) ;
9
9
@@ -34,11 +34,11 @@ const tests = [
34
34
35
35
[
36
36
37
- `--definitely-typed ${ new URL ( "../../../ core/test/fixtures/@[email protected] " , import . meta. url ) . pathname } ` ,
37
+ `--definitely-typed ${ new URL ( "../../core/test/fixtures/@[email protected] " , import . meta. url ) . pathname } ` ,
38
38
] ,
39
39
[
40
40
41
- `--definitely-typed ${ new URL ( "../../../ core/test/fixtures/@[email protected] " , import . meta. url ) . pathname } ` ,
41
+ `--definitely-typed ${ new URL ( "../../core/test/fixtures/@[email protected] " , import . meta. url ) . pathname } ` ,
42
42
] ,
43
43
44
44
[ "[email protected] " , "--entrypoints-legacy --ignore-rules=cjs-only-exports-default" ] ,
@@ -68,21 +68,22 @@ describe("snapshots", async () => {
68
68
}
69
69
70
70
test ( fixture , async ( ) => {
71
- const tarballPath = new URL ( `../../../core/test/fixtures/${ tarball } ` , import . meta. url ) . pathname ;
72
- let stdout ;
73
- let stderr = "" ;
74
- let exitCode = 0 ;
75
- try {
76
- stdout = execSync ( `${ attw } ${ tarballPath } ${ options ?? defaultOpts } ` , {
71
+ const tarballPath = new URL ( `../../core/test/fixtures/${ tarball } ` , import . meta. url ) . pathname ;
72
+ const {
73
+ stdout,
74
+ stderr,
75
+ status = 1 ,
76
+ } = spawnSync (
77
+ process . execPath ,
78
+ [ ...process . execArgv , attw , tarballPath , ...( options ?? defaultOpts ) . split ( " " ) ] ,
79
+ {
77
80
encoding : "utf8" ,
78
- env : { ...process . env , FORCE_COLOR : "0" } ,
79
- } ) ;
80
- } catch ( error ) {
81
- stdout = ( error as SpawnSyncReturns < string > ) . stdout ;
82
- stderr = ( error as SpawnSyncReturns < string > ) . stderr ;
83
- exitCode = ( error as SpawnSyncReturns < string > ) . status ?? 1 ;
84
- }
85
- const snapshotURL = new URL ( `../snapshots/${ fixture } .md` , import . meta. url ) ;
81
+ stdio : "pipe" ,
82
+ env : { ...process . env , FORCE_COLOR : "0" , NODE_OPTIONS : "--no-warnings" } ,
83
+ } ,
84
+ ) ;
85
+
86
+ const snapshotURL = new URL ( `snapshots/${ fixture } .md` , import . meta. url ) ;
86
87
// prettier-ignore
87
88
const expectedSnapshot = [
88
89
`# ${ fixture } ` ,
@@ -94,7 +95,7 @@ describe("snapshots", async () => {
94
95
"" ,
95
96
"```" ,
96
97
"" ,
97
- `Exit code: ${ exitCode } ` ,
98
+ `Exit code: ${ status } ` ,
98
99
] . join ( "\n" ) ;
99
100
100
101
if (
0 commit comments