11import { expect } from "@std/expect" ;
2+ import { waitForText , withBrowser } from "../../fresh/tests/test_utils.tsx" ;
23import {
3- waitForText ,
4- withBrowser ,
5- withChildProcessServer ,
6- } from "../../fresh/tests/test_utils.tsx" ;
7- import { buildVite , DEMO_DIR , FIXTURE_DIR , usingEnv } from "./test_utils.ts" ;
4+ buildVite ,
5+ DEMO_DIR ,
6+ FIXTURE_DIR ,
7+ launchProd ,
8+ usingEnv ,
9+ } from "./test_utils.ts" ;
810import * as path from "@std/path" ;
911
1012Deno . test ( {
1113 name : "vite build - launches" ,
1214 fn : async ( ) => {
1315 await using res = await buildVite ( DEMO_DIR ) ;
1416
15- await withChildProcessServer (
16- {
17- cwd : res . tmp ,
18- args : [ "serve" , "-A" , "--port" , "0" , "_fresh/server.js" ] ,
19- } ,
17+ await launchProd (
18+ { cwd : res . tmp } ,
2019 async ( address ) => {
2120 const res = await fetch ( address ) ;
2221 const text = await res . text ( ) ;
@@ -33,11 +32,8 @@ Deno.test({
3332 fn : async ( ) => {
3433 await using viteResult = await buildVite ( DEMO_DIR ) ;
3534
36- await withChildProcessServer (
37- {
38- cwd : viteResult . tmp ,
39- args : [ "serve" , "-A" , "--port" , "0" , "_fresh/server.js" ] ,
40- } ,
35+ await launchProd (
36+ { cwd : viteResult . tmp } ,
4137 async ( address ) => {
4238 const res = await fetch ( `${ address } /test_static/foo.txt` ) ;
4339 const text = await res . text ( ) ;
@@ -54,11 +50,8 @@ Deno.test({
5450 fn : async ( ) => {
5551 await using res = await buildVite ( DEMO_DIR ) ;
5652
57- await withChildProcessServer (
58- {
59- cwd : res . tmp ,
60- args : [ "serve" , "-A" , "--port" , "0" , "_fresh/server.js" ] ,
61- } ,
53+ await launchProd (
54+ { cwd : res . tmp } ,
6255 async ( address ) => {
6356 await withBrowser ( async ( page ) => {
6457 await page . goto ( `${ address } /tests/island_hooks` , {
@@ -83,11 +76,8 @@ Deno.test({
8376 const fixture = path . join ( FIXTURE_DIR , "no_static" ) ;
8477 await using res = await buildVite ( fixture ) ;
8578
86- await withChildProcessServer (
87- {
88- cwd : res . tmp ,
89- args : [ "serve" , "-A" , "--port" , "0" , "_fresh/server.js" ] ,
90- } ,
79+ await launchProd (
80+ { cwd : res . tmp } ,
9181 async ( address ) => {
9282 const res = await fetch ( `${ address } /ok` ) ;
9383 const text = await res . text ( ) ;
@@ -105,11 +95,8 @@ Deno.test({
10595 const fixture = path . join ( FIXTURE_DIR , "no_islands" ) ;
10696 await using res = await buildVite ( fixture ) ;
10797
108- await withChildProcessServer (
109- {
110- cwd : res . tmp ,
111- args : [ "serve" , "-A" , "--port" , "0" , "_fresh/server.js" ] ,
112- } ,
98+ await launchProd (
99+ { cwd : res . tmp } ,
113100 async ( address ) => {
114101 const res = await fetch ( `${ address } ` ) ;
115102 const text = await res . text ( ) ;
@@ -127,11 +114,8 @@ Deno.test({
127114 const fixture = path . join ( FIXTURE_DIR , "no_routes" ) ;
128115 await using res = await buildVite ( fixture ) ;
129116
130- await withChildProcessServer (
131- {
132- cwd : res . tmp ,
133- args : [ "serve" , "-A" , "--port" , "0" , "_fresh/server.js" ] ,
134- } ,
117+ await launchProd (
118+ { cwd : res . tmp } ,
135119 async ( address ) => {
136120 const res = await fetch ( `${ address } ` ) ;
137121 const text = await res . text ( ) ;
@@ -148,11 +132,8 @@ Deno.test({
148132 fn : async ( ) => {
149133 await using res = await buildVite ( DEMO_DIR ) ;
150134
151- await withChildProcessServer (
152- {
153- cwd : res . tmp ,
154- args : [ "serve" , "-A" , "--port" , "0" , "_fresh/server.js" ] ,
155- } ,
135+ await launchProd (
136+ { cwd : res . tmp } ,
156137 async ( address ) => {
157138 await withBrowser ( async ( page ) => {
158139 await page . goto ( `${ address } /tests/mime` , {
@@ -173,11 +154,8 @@ Deno.test({
173154 fn : async ( ) => {
174155 await using res = await buildVite ( DEMO_DIR ) ;
175156
176- await withChildProcessServer (
177- {
178- cwd : res . tmp ,
179- args : [ "serve" , "-A" , "--port" , "0" , "_fresh/server.js" ] ,
180- } ,
157+ await launchProd (
158+ { cwd : res . tmp } ,
181159 async ( address ) => {
182160 await withBrowser ( async ( page ) => {
183161 await page . goto ( `${ address } /tests/assets` , {
@@ -207,11 +185,8 @@ Deno.test({
207185 const fixture = path . join ( FIXTURE_DIR , "tailwind_no_app" ) ;
208186 await using res = await buildVite ( fixture ) ;
209187
210- await withChildProcessServer (
211- {
212- cwd : res . tmp ,
213- args : [ "serve" , "-A" , "--port" , "0" , "_fresh/server.js" ] ,
214- } ,
188+ await launchProd (
189+ { cwd : res . tmp } ,
215190 async ( address ) => {
216191 await withBrowser ( async ( page ) => {
217192 await page . goto ( `${ address } ` , {
@@ -240,11 +215,8 @@ Deno.test({
240215 const fixture = path . join ( FIXTURE_DIR , "tailwind_app" ) ;
241216 await using res = await buildVite ( fixture ) ;
242217
243- await withChildProcessServer (
244- {
245- cwd : res . tmp ,
246- args : [ "serve" , "-A" , "--port" , "0" , "_fresh/server.js" ] ,
247- } ,
218+ await launchProd (
219+ { cwd : res . tmp } ,
248220 async ( address ) => {
249221 await withBrowser ( async ( page ) => {
250222 await page . goto ( `${ address } ` , {
@@ -272,11 +244,8 @@ Deno.test({
272244 fn : async ( ) => {
273245 await using res = await buildVite ( DEMO_DIR ) ;
274246
275- await withChildProcessServer (
276- {
277- cwd : res . tmp ,
278- args : [ "serve" , "-A" , "--port" , "0" , "_fresh/server.js" ] ,
279- } ,
247+ await launchProd (
248+ { cwd : res . tmp } ,
280249 async ( address ) => {
281250 await withBrowser ( async ( page ) => {
282251 await page . goto ( `${ address } /tests/partial` , {
@@ -315,15 +284,10 @@ Deno.test({
315284 ]
316285 ) {
317286 using _ = usingEnv ( key , revision ) ;
318- // deno-lint-ignore no-console
319- console . log ( "Checking..." , key , Deno . env . get ( key ) ) ;
320287 await using res = await buildVite ( DEMO_DIR ) ;
321288
322- await withChildProcessServer (
323- {
324- cwd : res . tmp ,
325- args : [ "serve" , "-A" , "--port" , "0" , "_fresh/server.js" ] ,
326- } ,
289+ await launchProd (
290+ { cwd : res . tmp } ,
327291 async ( address ) => {
328292 const res = await fetch ( `${ address } /tests/build_id` ) ;
329293 const text = await res . text ( ) ;
@@ -346,11 +310,8 @@ Deno.test({
346310 fn : async ( ) => {
347311 await using res = await buildVite ( DEMO_DIR ) ;
348312
349- await withChildProcessServer (
350- {
351- cwd : res . tmp ,
352- args : [ "serve" , "-A" , "--port" , "0" , "_fresh/server.js" ] ,
353- } ,
313+ await launchProd (
314+ { cwd : res . tmp } ,
354315 async ( address ) => {
355316 const res = await fetch ( `${ address } /tests/dep_json` ) ;
356317 const json = await res . json ( ) ;
0 commit comments