11import * as path from "@std/path" ;
22import { expect } from "@std/expect" ;
33import { waitForText , withBrowser } from "../../fresh/tests/test_utils.tsx" ;
4- import { updateFile , withDevServer } from "./test_utils.ts" ;
4+ import {
5+ DEMO_DIR ,
6+ FIXTURE_DIR ,
7+ updateFile ,
8+ withDevServer ,
9+ } from "./test_utils.ts" ;
510
611Deno . test ( {
712 name : "vite dev - launches" ,
813 fn : async ( ) => {
9- await withDevServer ( async ( address ) => {
14+ await withDevServer ( DEMO_DIR , async ( address ) => {
1015 const res = await fetch ( `${ address } /tests/it_works` ) ;
1116 const text = await res . text ( ) ;
1217 expect ( text ) . toContain ( "it works" ) ;
@@ -19,7 +24,7 @@ Deno.test({
1924Deno . test ( {
2025 name : "vite dev - serves static files" ,
2126 fn : async ( ) => {
22- await withDevServer ( async ( address ) => {
27+ await withDevServer ( DEMO_DIR , async ( address ) => {
2328 const res = await fetch ( `${ address } /test_static/foo.txt` ) ;
2429 const text = await res . text ( ) ;
2530 expect ( text ) . toContain ( "it works" ) ;
@@ -32,7 +37,7 @@ Deno.test({
3237Deno . test ( {
3338 name : "vite dev - loads islands" ,
3439 fn : async ( ) => {
35- await withDevServer ( async ( address ) => {
40+ await withDevServer ( DEMO_DIR , async ( address ) => {
3641 await withBrowser ( async ( page ) => {
3742 await page . goto ( `${ address } /tests/island_hooks` , {
3843 waitUntil : "networkidle2" ,
@@ -48,11 +53,53 @@ Deno.test({
4853 sanitizeOps : false ,
4954} ) ;
5055
56+ Deno . test ( {
57+ name : "vite dev - starts without static/ dir" ,
58+ fn : async ( ) => {
59+ const fixture = path . join ( FIXTURE_DIR , "no_static" ) ;
60+ await withDevServer ( fixture , async ( address ) => {
61+ const res = await fetch ( `${ address } /` ) ;
62+ const text = await res . text ( ) ;
63+ expect ( text ) . toContain ( "ok" ) ;
64+ } ) ;
65+ } ,
66+ sanitizeResources : false ,
67+ sanitizeOps : false ,
68+ } ) ;
69+
70+ Deno . test ( {
71+ name : "vite dev - starts without islands/ dir" ,
72+ fn : async ( ) => {
73+ const fixture = path . join ( FIXTURE_DIR , "no_islands" ) ;
74+ await withDevServer ( fixture , async ( address ) => {
75+ const res = await fetch ( `${ address } /` ) ;
76+ const text = await res . text ( ) ;
77+ expect ( text ) . toContain ( "ok" ) ;
78+ } ) ;
79+ } ,
80+ sanitizeResources : false ,
81+ sanitizeOps : false ,
82+ } ) ;
83+
84+ Deno . test ( {
85+ name : "vite dev - starts without routes/ dir" ,
86+ fn : async ( ) => {
87+ const fixture = path . join ( FIXTURE_DIR , "no_routes" ) ;
88+ await withDevServer ( fixture , async ( address ) => {
89+ const res = await fetch ( `${ address } /` ) ;
90+ const text = await res . text ( ) ;
91+ expect ( text ) . toContain ( "ok" ) ;
92+ } ) ;
93+ } ,
94+ sanitizeResources : false ,
95+ sanitizeOps : false ,
96+ } ) ;
97+
5198Deno . test ( {
5299 name : "vite dev - can apply HMR to islands (hooks)" ,
53100 ignore : true , // Test is very flaky
54101 fn : async ( ) => {
55- await withDevServer ( async ( address , dir ) => {
102+ await withDevServer ( DEMO_DIR , async ( address , dir ) => {
56103 await withBrowser ( async ( page ) => {
57104 await page . goto ( `${ address } /tests/island_hooks` , {
58105 waitUntil : "networkidle2" ,
0 commit comments