diff --git a/docs/src/test-advanced-js.md b/docs/src/test-advanced-js.md index 78add78467..51ed0649d0 100644 --- a/docs/src/test-advanced-js.md +++ b/docs/src/test-advanced-js.md @@ -139,7 +139,7 @@ export const test = base.extend<{ saveLogs: void }>({ To launch a server during the tests, use the `webServer` option in the [configuration file](#configuration-object). -You can specify a port via `port` or additional environment variables, see [here](#configuration-object). The server will wait for it to be available (on `127.0.0.1` or `::1`) before running the tests. For continuous integration, you may want to use the `reuseExistingServer: !process.env.CI` option which does not use an existing server on the CI. +You can specify a port via `port` or additional environment variables, see [here](#configuration-object). The server will wait for it to be available (on `127.0.0.1` or `::1`) before running the tests. For continuous integration, you may want to use the `reuseExistingServer: !process.env.CI` option which does not use an existing server on the CI. To see the stdout, you can set the `DEBUG=pw:webserver` environment variable. The port gets then passed over to Playwright as a [`param: baseURL`] when creating the context [`method: Browser.newContext`]. diff --git a/docs/src/test-api/class-testconfig.md b/docs/src/test-api/class-testconfig.md index 7053adb519..392a4fea16 100644 --- a/docs/src/test-api/class-testconfig.md +++ b/docs/src/test-api/class-testconfig.md @@ -567,7 +567,7 @@ export default config; Launch a development web server during the tests. -The server will wait for it to be available on `127.0.0.1` or `::1` before running the tests. For continuous integration, you may want to use the `reuseExistingServer: !process.env.CI` option which does not use an existing server on the CI. +The server will wait for it to be available on `127.0.0.1` or `::1` before running the tests. For continuous integration, you may want to use the `reuseExistingServer: !process.env.CI` option which does not use an existing server on the CI. To see the stdout, you can set the `DEBUG=pw:webserver` environment variable. The port gets then passed over to Playwright as a `baseURL` when creating the context [`method: Browser.newContext`]. For example `8080` ends up in `baseURL` to be `http://localhost:8080`. If you want to use `https://` you need to manually specify diff --git a/packages/playwright-test/src/webServer.ts b/packages/playwright-test/src/webServer.ts index bb98d441b1..db1d89ae7a 100644 --- a/packages/playwright-test/src/webServer.ts +++ b/packages/playwright-test/src/webServer.ts @@ -17,6 +17,7 @@ import net from 'net'; import os from 'os'; import stream from 'stream'; +import debug from 'debug'; import { monotonicTime } from './util'; import { raceAgainstDeadline } from 'playwright-core/lib/utils/async'; import { WebServerConfig } from './types'; @@ -33,6 +34,8 @@ const newProcessLogPrefixer = () => new stream.Transform({ }, }); +const debugWebServer = debug('pw:webserver'); + export class WebServer { private _killProcess?: () => Promise; private _processExitedPromise!: Promise; @@ -79,7 +82,7 @@ export class WebServer { this._killProcess = kill; launchedProcess.stderr!.pipe(newProcessLogPrefixer()).pipe(process.stderr); - launchedProcess.stdout!.on('data', () => {}); + launchedProcess.stdout!.on('data', (line: Buffer) => debugWebServer(line.toString())); } private async _waitForProcess() { diff --git a/packages/playwright-test/types/test.d.ts b/packages/playwright-test/types/test.d.ts index e76aa9956d..2412b8a496 100644 --- a/packages/playwright-test/types/test.d.ts +++ b/packages/playwright-test/types/test.d.ts @@ -572,7 +572,7 @@ interface TestConfig { * * The server will wait for it to be available on `127.0.0.1` or `::1` before running the tests. For continuous * integration, you may want to use the `reuseExistingServer: !process.env.CI` option which does not use an existing server - * on the CI. + * on the CI. To see the stdout, you can set the `DEBUG=pw:webserver` environment variable. * * The port gets then passed over to Playwright as a `baseURL` when creating the context * [browser.newContext([options])](https://playwright.dev/docs/api/class-browser#browser-new-context). For example `8080` @@ -1061,7 +1061,7 @@ export interface FullConfig { * * The server will wait for it to be available on `127.0.0.1` or `::1` before running the tests. For continuous * integration, you may want to use the `reuseExistingServer: !process.env.CI` option which does not use an existing server - * on the CI. + * on the CI. To see the stdout, you can set the `DEBUG=pw:webserver` environment variable. * * The port gets then passed over to Playwright as a `baseURL` when creating the context * [browser.newContext([options])](https://playwright.dev/docs/api/class-browser#browser-new-context). For example `8080`