@@ -14,6 +14,7 @@ import type {
1414} from 'vite'
1515import {
1616 build ,
17+ createBuilder ,
1718 createServer ,
1819 loadConfigFromFile ,
1920 mergeConfig ,
@@ -253,6 +254,7 @@ export async function startDefaultServe(): Promise<void> {
253254 viteTestUrl = `http://localhost:${ server . config . server . port } ${
254255 devBase === '/' ? '' : devBase
255256 } `
257+ setViteUrl ( viteTestUrl )
256258 await page . goto ( viteTestUrl )
257259 } else {
258260 process . env . VITE_INLINE = 'inline-build'
@@ -267,12 +269,17 @@ export async function startDefaultServe(): Promise<void> {
267269 const testConfig = mergeConfig ( options , config || { } )
268270 viteConfig = testConfig
269271 process . chdir ( rootDir )
270- const rollupOutput = await build ( testConfig )
271- const isWatch = ! ! resolvedConfig ! . build . watch
272- // in build watch,call startStaticServer after the build is complete
273- if ( isWatch ) {
274- watcher = rollupOutput as Rollup . RollupWatcher
275- await notifyRebuildComplete ( watcher )
272+ if ( testConfig . builder ) {
273+ const builder = await createBuilder ( testConfig )
274+ await builder . buildApp ( )
275+ } else {
276+ const rollupOutput = await build ( testConfig )
277+ const isWatch = ! ! resolvedConfig ! . build . watch
278+ // in build watch,call startStaticServer after the build is complete
279+ if ( isWatch ) {
280+ watcher = rollupOutput as Rollup . RollupWatcher
281+ await notifyRebuildComplete ( watcher )
282+ }
276283 }
277284 // @ts -ignore
278285 if ( config && config . __test__ ) {
@@ -284,6 +291,8 @@ export async function startDefaultServe(): Promise<void> {
284291 // prevent preview change NODE_ENV
285292 process . env . NODE_ENV = _nodeEnv
286293 viteTestUrl = previewServer . resolvedUrls . local [ 0 ]
294+ viteTestUrl = viteTestUrl . replace ( / \/ + $ / , '' )
295+ setViteUrl ( viteTestUrl )
287296 await page . goto ( viteTestUrl )
288297 }
289298}
0 commit comments