@@ -4,14 +4,18 @@ import { waitForText, withBrowser } from "../../fresh/tests/test_utils.tsx";
44import {
55 DEMO_DIR ,
66 FIXTURE_DIR ,
7+ launchDevServer ,
8+ prepareDevServer ,
79 updateFile ,
810 withDevServer ,
911} from "./test_utils.ts" ;
1012
13+ const tmp = await prepareDevServer ( DEMO_DIR ) ;
14+
1115Deno . test ( {
1216 name : "vite dev - launches" ,
1317 fn : async ( ) => {
14- await withDevServer ( DEMO_DIR , async ( address ) => {
18+ await launchDevServer ( tmp . dir , async ( address ) => {
1519 const res = await fetch ( `${ address } /tests/it_works` ) ;
1620 const text = await res . text ( ) ;
1721 expect ( text ) . toContain ( "it works" ) ;
@@ -24,7 +28,7 @@ Deno.test({
2428Deno . test ( {
2529 name : "vite dev - serves static files" ,
2630 fn : async ( ) => {
27- await withDevServer ( DEMO_DIR , async ( address ) => {
31+ await launchDevServer ( tmp . dir , async ( address ) => {
2832 const res = await fetch ( `${ address } /test_static/foo.txt` ) ;
2933 const text = await res . text ( ) ;
3034 expect ( text ) . toContain ( "it works" ) ;
@@ -37,7 +41,7 @@ Deno.test({
3741Deno . test ( {
3842 name : "vite dev - loads islands" ,
3943 fn : async ( ) => {
40- await withDevServer ( DEMO_DIR , async ( address ) => {
44+ await launchDevServer ( tmp . dir , async ( address ) => {
4145 await withBrowser ( async ( page ) => {
4246 await page . goto ( `${ address } /tests/island_hooks` , {
4347 waitUntil : "networkidle2" ,
@@ -99,7 +103,7 @@ Deno.test({
99103 name : "vite dev - can apply HMR to islands (hooks)" ,
100104 ignore : true , // Test is very flaky
101105 fn : async ( ) => {
102- await withDevServer ( DEMO_DIR , async ( address , dir ) => {
106+ await launchDevServer ( tmp . dir , async ( address , dir ) => {
103107 await withBrowser ( async ( page ) => {
104108 await page . goto ( `${ address } /tests/island_hooks` , {
105109 waitUntil : "networkidle2" ,
@@ -132,7 +136,7 @@ Deno.test({
132136Deno . test ( {
133137 name : "vite dev - can import json in npm package" ,
134138 fn : async ( ) => {
135- await withDevServer ( DEMO_DIR , async ( address ) => {
139+ await launchDevServer ( tmp . dir , async ( address ) => {
136140 await withBrowser ( async ( page ) => {
137141 await page . goto ( `${ address } /tests/mime` , {
138142 waitUntil : "networkidle2" ,
@@ -148,7 +152,7 @@ Deno.test({
148152Deno . test ( {
149153 name : "vite dev - inline env vars" ,
150154 fn : async ( ) => {
151- await withDevServer ( DEMO_DIR , async ( address ) => {
155+ await launchDevServer ( tmp . dir , async ( address ) => {
152156 await withBrowser ( async ( page ) => {
153157 await page . goto ( `${ address } /tests/env` , {
154158 waitUntil : "networkidle2" ,
@@ -171,7 +175,7 @@ Deno.test({
171175Deno . test ( {
172176 name : "vite dev - serves imported assets" ,
173177 fn : async ( ) => {
174- await withDevServer ( DEMO_DIR , async ( address ) => {
178+ await launchDevServer ( tmp . dir , async ( address ) => {
175179 const res = await fetch ( `${ address } /assets/deno-logo.png` ) ;
176180 expect ( res . status ) . toEqual ( 200 ) ;
177181 expect ( res . headers . get ( "Content-Type" ) ) . toEqual ( "image/png" ) ;
@@ -220,7 +224,7 @@ Deno.test({
220224Deno . test ( {
221225 name : "vite dev - partial island" ,
222226 fn : async ( ) => {
223- await withDevServer ( DEMO_DIR , async ( address ) => {
227+ await launchDevServer ( tmp . dir , async ( address ) => {
224228 await withBrowser ( async ( page ) => {
225229 await page . goto ( `${ address } /tests/partial` , {
226230 waitUntil : "networkidle2" ,
@@ -242,7 +246,7 @@ Deno.test({
242246Deno . test ( {
243247 name : "vite dev - json from jsr dependency" ,
244248 fn : async ( ) => {
245- await withDevServer ( DEMO_DIR , async ( address ) => {
249+ await launchDevServer ( tmp . dir , async ( address ) => {
246250 const res = await fetch ( `${ address } /tests/dep_json` ) ;
247251 const json = await res . json ( ) ;
248252 expect ( json . name ) . toEqual ( "@marvinh-test/import-json" ) ;
@@ -255,7 +259,7 @@ Deno.test({
255259Deno . test ( {
256260 name : "vite dev - import node:*" ,
257261 fn : async ( ) => {
258- await withDevServer ( DEMO_DIR , async ( address ) => {
262+ await launchDevServer ( tmp . dir , async ( address ) => {
259263 const res = await fetch ( `${ address } /tests/feed` ) ;
260264 await res . body ?. cancel ( ) ;
261265 expect ( res . status ) . toEqual ( 200 ) ;
0 commit comments