diff --git a/docs/src/test-api/class-testconfig.md b/docs/src/test-api/class-testconfig.md index 48d809d127..90425fcf4c 100644 --- a/docs/src/test-api/class-testconfig.md +++ b/docs/src/test-api/class-testconfig.md @@ -629,7 +629,7 @@ export default defineConfig({ - `stdout` ?<["pipe"|"ignore"]> If `"pipe"`, it will pipe the stdout of the command to the process stdout. If `"ignore"`, it will ignore the stdout of the command. Default to `"ignore"`. - `stderr` ?<["pipe"|"ignore"]> Whether to pipe the stderr of the command to the process stderr or ignore it. Defaults to `"pipe"`. - `timeout` ?<[int]> How long to wait for the process to start up and be available in milliseconds. Defaults to 60000. - - `kill` ?<[Object]> How to shut down the process gracefully. If unspecified, the process group is forcefully `SIGKILL`ed. If set to `{ signal: "SIGINT", timeout: 500 }`, the process group is sent a `SIGINT` signal, followed by `SIGKILL` if it doesn't exit within 500ms. You can also use `SIGTERM` instead. A `0` timeout means no `SIGKILL` will be sent. Windows doesn't support `SIGINT` and `SIGTERM` signals, so this option is ignored. + - `gracefulShutdown` ?<[Object]> How to shut down the process. If unspecified, the process group is forcefully `SIGKILL`ed. If set to `{ signal: 'SIGINT', timeout: 500 }`, the process group is sent a `SIGINT` signal, followed by `SIGKILL` if it doesn't exit within 500ms. You can also use `SIGTERM` instead. A `0` timeout means no `SIGKILL` will be sent. Windows doesn't support `SIGINT` and `SIGTERM` signals, so this option is ignored. - `signal` <["SIGINT"|"SIGTERM"]> - `timeout` <[int]> - `url` ?<[string]> The url on your http server that is expected to return a 2xx, 3xx, 400, 401, 402, or 403 status code when the server is ready to accept connections. Redirects (3xx status codes) are being followed and the new location is checked. Either `port` or `url` should be specified. diff --git a/docs/src/test-webserver-js.md b/docs/src/test-webserver-js.md index fa1113b3b3..f4c86197c0 100644 --- a/docs/src/test-webserver-js.md +++ b/docs/src/test-webserver-js.md @@ -37,7 +37,7 @@ export default defineConfig({ | `stdout` | If `"pipe"`, it will pipe the stdout of the command to the process stdout. If `"ignore"`, it will ignore the stdout of the command. Default to `"ignore"`. | | `stderr` | Whether to pipe the stderr of the command to the process stderr or ignore it. Defaults to `"pipe"`. | | `timeout` | How long to wait for the process to start up and be available in milliseconds. Defaults to 60000. | -| `kill` | How to shut down the process gracefully. If unspecified, the process group is forcefully `SIGKILL`ed. If set to `{ SIGINT: 500 }`, the process group is sent a `SIGINT` signal, followed by `SIGKILL` if it doesn't exit within 500ms. You can also use `SIGTERM` instead. A `0` timeout means no `SIGKILL` will be sent. Windows doesn't support `SIGINT` and `SIGTERM` signals, so this option is ignored. | +| `gracefulShutdown` | How to shut down the process. If unspecified, the process group is forcefully `SIGKILL`ed. If set to `{ signal: 'SIGINT', timeout: 500 }`, the process group is sent a `SIGINT` signal, followed by `SIGKILL` if it doesn't exit within 500ms. You can also use `SIGTERM` instead. A `0` timeout means no `SIGKILL` will be sent. Windows doesn't support `SIGINT` and `SIGTERM` signals, so this option is ignored. | ## Adding a server timeout diff --git a/packages/playwright/src/plugins/webServerPlugin.ts b/packages/playwright/src/plugins/webServerPlugin.ts index a4a2943618..002ad235bd 100644 --- a/packages/playwright/src/plugins/webServerPlugin.ts +++ b/packages/playwright/src/plugins/webServerPlugin.ts @@ -30,7 +30,7 @@ export type WebServerPluginOptions = { url?: string; ignoreHTTPSErrors?: boolean; timeout?: number; - kill?: { signal: 'SIGINT' | 'SIGTERM', timeout?: number }; + gracefulShutdown?: { signal: 'SIGINT' | 'SIGTERM', timeout?: number }; reuseExistingServer?: boolean; cwd?: string; env?: { [key: string]: string; }; @@ -106,10 +106,10 @@ export class WebServerPlugin implements TestRunnerPlugin { attemptToGracefullyClose: async () => { if (process.platform === 'win32') throw new Error('Graceful shutdown is not supported on Windows'); - if (!this._options.kill) + if (!this._options.gracefulShutdown) throw new Error('skip graceful shutdown'); - const { signal, timeout = 0 } = this._options.kill; + const { signal, timeout = 0 } = this._options.gracefulShutdown; // proper usage of SIGINT is to send it to the entire process group, see https://www.cons.org/cracauer/sigint.html // there's no such convention for SIGTERM, so we decide what we want. signaling the process group for consistency. diff --git a/packages/playwright/types/test.d.ts b/packages/playwright/types/test.d.ts index 80c7b7d49c..c551abb864 100644 --- a/packages/playwright/types/test.d.ts +++ b/packages/playwright/types/test.d.ts @@ -9630,12 +9630,12 @@ interface TestConfigWebServer { timeout?: number; /** - * How to shut down the process gracefully. If unspecified, the process group is forcefully `SIGKILL`ed. If set to `{ - * signal: "SIGINT", timeout: 500 }`, the process group is sent a `SIGINT` signal, followed by `SIGKILL` if it doesn't - * exit within 500ms. You can also use `SIGTERM` instead. A `0` timeout means no `SIGKILL` will be sent. Windows - * doesn't support `SIGINT` and `SIGTERM` signals, so this option is ignored. + * How to shut down the process. If unspecified, the process group is forcefully `SIGKILL`ed. If set to `{ signal: + * 'SIGINT', timeout: 500 }`, the process group is sent a `SIGINT` signal, followed by `SIGKILL` if it doesn't exit + * within 500ms. You can also use `SIGTERM` instead. A `0` timeout means no `SIGKILL` will be sent. Windows doesn't + * support `SIGINT` and `SIGTERM` signals, so this option is ignored. */ - kill?: { + gracefulShutdown?: { signal: "SIGINT"|"SIGTERM"; timeout: number; diff --git a/tests/playwright-test/web-server.spec.ts b/tests/playwright-test/web-server.spec.ts index 6474287a87..6caed12a42 100644 --- a/tests/playwright-test/web-server.spec.ts +++ b/tests/playwright-test/web-server.spec.ts @@ -746,7 +746,7 @@ test('should forward stdout when set to "pipe" before server is ready', async ({ expect(result.output).not.toContain('Timed out waiting 3000ms'); }); -test.describe('kill option', () => { +test.describe('gracefulShutdown option', () => { test.skip(process.platform === 'win32', 'No sending SIGINT on Windows'); const files = (additionalOptions = {}) => { @@ -799,12 +799,12 @@ test.describe('kill option', () => { }); test('can be configured to send SIGTERM', async ({ runInlineTest }) => { - const result = await runInlineTest(files({ kill: { signal: 'SIGTERM', timeout: 500 } }), { workers: 1 }); + const result = await runInlineTest(files({ gracefulShutdown: { signal: 'SIGTERM', timeout: 500 } }), { workers: 1 }); expect(parseOutputLines(result).sort()).toEqual(['childprocess received SIGTERM', 'webserver received SIGTERM but stubbornly refuses to wind down']); }); test('can be configured to send SIGINT', async ({ runInlineTest }) => { - const result = await runInlineTest(files({ kill: { signal: 'SIGINT', timeout: 500 } }), { workers: 1 }); + const result = await runInlineTest(files({ gracefulShutdown: { signal: 'SIGINT', timeout: 500 } }), { workers: 1 }); expect(parseOutputLines(result).sort()).toEqual(['childprocess received SIGINT', 'webserver received SIGINT but stubbornly refuses to wind down']); }); });