@@ -2,8 +2,9 @@ import { execFile } from 'node:child_process'
22import { promisify } from 'node:util'
33import path from 'node:path'
44import { fileURLToPath } from 'node:url'
5+ import { setTimeout } from 'node:timers/promises'
56import { describe , expect , test } from 'vitest'
6- import { port } from './serve'
7+ import { port , serverLogs } from './serve'
78import { editFile , isServe , page } from '~utils'
89
910const url = `http://localhost:${ port } `
@@ -43,6 +44,32 @@ describe.runIf(isServe)('injected inline scripts', () => {
4344 } )
4445} )
4546
47+ describe . runIf ( isServe ) ( 'trailing slash html paths' , ( ) => {
48+ test ( 'pre-transforms relative module scripts from the trailing slash directory' , async ( ) => {
49+ serverLogs . length = 0
50+
51+ const response = await fetch ( `${ url } /trailing-slash/dir/` )
52+ expect ( response . status ) . toBe ( 200 )
53+ await response . text ( )
54+
55+ await setTimeout ( 100 ) // wait for pre-transform to happen
56+ expect ( serverLogs ) . not . toEqual (
57+ expect . arrayContaining ( [ expect . stringContaining ( 'Pre-transform error' ) ] ) ,
58+ )
59+ } )
60+
61+ test ( 'loads relative module scripts from the trailing slash directory' , async ( ) => {
62+ await page . goto ( `${ url } /trailing-slash/dir/` )
63+
64+ await expect
65+ . poll ( ( ) => page . textContent ( '.relative-script' ) )
66+ . toBe ( 'relative module loaded' )
67+ await expect
68+ . poll ( ( ) => page . textContent ( '.relative-parent-script' ) )
69+ . toBe ( 'relative parent module loaded' )
70+ } )
71+ } )
72+
4673describe . runIf ( isServe ) ( 'hmr' , ( ) => {
4774 test ( 'handle virtual module updates' , async ( ) => {
4875 await page . goto ( url )
0 commit comments