@@ -6,7 +6,6 @@ import { TestContext, test as vitestTest } from "vitest";
66import { execSync } from "node:child_process" ;
77
88const cwd = dirname ( fileURLToPath ( import . meta. url ) ) ;
9- const NODE_MAJOR_VERSION = parseInt ( process . versions . node . split ( "." ) [ 0 ] || "0" , 10 ) ;
109
1110type TestCallback = ( props : {
1211 outDir : string ;
@@ -26,37 +25,31 @@ export function test(url: string, callback: TestCallback) {
2625 // Clear the output directory before running the test
2726 rmSync ( outDir , { recursive : true , force : true } ) ;
2827
29- // Vite v8 requires Node 20+
30- if ( NODE_MAJOR_VERSION < 20 ) {
31- // eslint-disable-next-line @typescript-eslint/no-empty-function
32- vitestTest . skip ( testName ) ;
33- } else {
34- vitestTest ( `Vite v4 > ${ testName } ` , ( ctx ) =>
35- callback ( {
36- outDir,
37- runBundler : ( env ) =>
38- runBundler (
39- `vite build --config ${ testName } .config.ts` ,
40- {
41- cwd,
42- env : {
43- ...process . env ,
44- ...env ,
45- } ,
46- } ,
47- outDir
48- ) ,
49- readOutputFiles : ( ) => readAllFiles ( outDir ) ,
50- runFileInNode : ( file ) => {
51- const fullPath = join ( outDir , file ) ;
52- return execSync ( `node ${ fullPath } ` , {
28+ vitestTest ( `Vite v4 > ${ testName } ` , ( ctx ) =>
29+ callback ( {
30+ outDir,
31+ runBundler : ( env ) =>
32+ runBundler (
33+ `vite build --config ${ testName } .config.ts` ,
34+ {
5335 cwd,
54- env : { ...process . env , NO_COLOR : "1" , FORCE_COLOR : "0" } ,
55- } ) . toString ( ) ;
56- } ,
57- createTempDir : ( ) => createTempDir ( ) ,
58- ctx,
59- } )
60- ) ;
61- }
36+ env : {
37+ ...process . env ,
38+ ...env ,
39+ } ,
40+ } ,
41+ outDir
42+ ) ,
43+ readOutputFiles : ( ) => readAllFiles ( outDir ) ,
44+ runFileInNode : ( file ) => {
45+ const fullPath = join ( outDir , file ) ;
46+ return execSync ( `node ${ fullPath } ` , {
47+ cwd,
48+ env : { ...process . env , NO_COLOR : "1" , FORCE_COLOR : "0" } ,
49+ } ) . toString ( ) ;
50+ } ,
51+ createTempDir : ( ) => createTempDir ( ) ,
52+ ctx,
53+ } )
54+ ) ;
6255}
0 commit comments