MCPcopy
hub / github.com/vitejs/vite / withServe

Function withServe

playground/css-dynamic-import/__tests__/css-dynamic-import.spec.ts:33–45  ·  view source on GitHub ↗
(base: string, fn: () => Promise<void>)

Source from the content-addressed store, hash-verified

31}
32
33async function withServe(base: string, fn: () => Promise<void>) {
34 const config = getConfig(base)
35 const server = await createServer(config)
36 await server.listen()
37
38 try {
39 await page.goto(server.resolvedUrls.local[0])
40 await fn()
41 } finally {
42 await page.goto('about:blank') // move to a different page to avoid auto-refresh after server start
43 await server.close()
44 }
45}
46
47async function getLinks() {
48 const links = await page.$$('link')

Callers 1

Calls 5

createServerFunction · 0.90
getConfigFunction · 0.70
listenMethod · 0.65
closeMethod · 0.65
fnFunction · 0.50

Tested by

no test coverage detected