test: stabilize smoke web server
This commit is contained in:
@@ -30,7 +30,7 @@ export default defineConfig({
|
|||||||
},
|
},
|
||||||
projects: [{ name: 'chromium', use: { browserName: 'chromium' } }],
|
projects: [{ name: 'chromium', use: { browserName: 'chromium' } }],
|
||||||
webServer: {
|
webServer: {
|
||||||
command: `pnpm dev --host 127.0.0.1 --port ${port} --strictPort`,
|
command: `node scripts/playwright-smoke-server.mjs ${port}`,
|
||||||
url: baseURL,
|
url: baseURL,
|
||||||
reuseExistingServer,
|
reuseExistingServer,
|
||||||
timeout: 30_000,
|
timeout: 30_000,
|
||||||
|
|||||||
32
scripts/playwright-smoke-server.mjs
Normal file
32
scripts/playwright-smoke-server.mjs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
import { spawn } from 'node:child_process'
|
||||||
|
|
||||||
|
const port = process.argv[2] ?? process.env.PORT ?? '41741'
|
||||||
|
|
||||||
|
const child = spawn(
|
||||||
|
'pnpm',
|
||||||
|
['dev', '--host', '127.0.0.1', '--port', port, '--strictPort'],
|
||||||
|
{
|
||||||
|
cwd: process.cwd(),
|
||||||
|
env: process.env,
|
||||||
|
stdio: ['pipe', 'inherit', 'inherit'],
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
function forwardSignal(signal) {
|
||||||
|
if (child.killed) return
|
||||||
|
child.kill(signal)
|
||||||
|
}
|
||||||
|
|
||||||
|
process.on('SIGINT', () => forwardSignal('SIGINT'))
|
||||||
|
process.on('SIGTERM', () => forwardSignal('SIGTERM'))
|
||||||
|
|
||||||
|
child.on('exit', (code, signal) => {
|
||||||
|
if (signal) {
|
||||||
|
process.kill(process.pid, signal)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
process.exit(code ?? 1)
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user