You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 143ab3c
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/src/test-api/class-testconfig.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -736,6 +736,9 @@ export default defineConfig({
736
736
737
737
Launch a development web server (or multiple) during the tests.
738
738
739
+
Top-level servers start before `globalSetup` and stop after `globalTeardown`, regardless of project
740
+
selection. To start servers only for particular projects, use [`property: TestProject.webServer`].
741
+
739
742
**Details**
740
743
741
744
If the port is specified, Playwright Test will wait for it to be available on `127.0.0.1` or `::1`, before running the tests. If the url is specified, Playwright Test will wait for the URL to return a 2xx, 3xx, 400, 401, 402, or 403 status code before running the tests.
Copy file name to clipboardExpand all lines: docs/src/test-api/class-testproject.md
+48-1Lines changed: 48 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
Playwright Test supports running multiple test projects at the same time. This is useful for running tests in multiple configurations. For example, consider running tests against multiple browsers. This type describes format of a project in the configuration file, to access resolved configuration parameters at run time use [FullProject].
6
6
7
-
`TestProject` encapsulates configuration specific to a single project. Projects are configured in [`property: TestConfig.projects`] specified in the [configuration file](../test-configuration.md). Note that all properties of [TestProject] are available in the top-level [TestConfig], in which case they are shared between all projects.
7
+
`TestProject` encapsulates configuration specific to a single project. Projects are configured in [`property: TestConfig.projects`] specified in the [configuration file](../test-configuration.md). Note that all properties of [TestProject] are available in the top-level [TestConfig], in which case they are shared between all projects. The exception is [`property: TestProject.webServer`]: top-level servers are started separately, for the whole run.
8
8
9
9
Here is an example configuration that runs every test in Chromium, Firefox and WebKit, both Desktop and Mobile versions.
Copy file name to clipboardExpand all lines: docs/src/test-webserver-js.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,10 @@ title: "Web server"
7
7
8
8
Playwright comes with a `webServer` option in the config file which gives you the ability to launch a local dev server before running your tests. This is ideal for when writing your tests during development and when you don't have a staging or production url to test against.
9
9
10
+
To start a server only when a particular project runs, configure
11
+
[`property: TestProject.webServer`] inside that project. Top-level servers start regardless of the
12
+
selected projects. Put servers shared by multiple projects at the top level.
13
+
10
14
## Configuring a web server
11
15
12
16
Use the `webServer` property in your Playwright config to launch a development web server during the tests.
@@ -99,11 +102,11 @@ export class WebServerPlugin implements TestRunnerPlugin {
99
102
if(this._options.reuseExistingServer)
100
103
return;
101
104
constport=newURL(this._options.url!).port;
102
-
thrownewError(`${this._options.url??`http://localhost${port ? ':'+port : ''}`} is already used, make sure that nothing is running on the port/url or set reuseExistingServer:true in config.webServer.`);
105
+
thrownewError(`${this._options.url??`http://localhost${port ? ':'+port : ''}`} is already used, make sure that nothing is running on the port/url or set reuseExistingServer:true in ${this._configLabel}.`);
103
106
}
104
107
105
108
if(!this._options.command)
106
-
thrownewError('config.webServer.command cannot be empty');
109
+
thrownewError(`${this._configLabel}.command cannot be empty`);
107
110
108
111
debugWebServer(`Starting WebServer process ${this._options.command}...`);
@@ -139,7 +142,7 @@ export class WebServerPlugin implements TestRunnerPlugin {
139
142
});
140
143
},
141
144
log: ()=>{},
142
-
onExit: code=>processExitedReject(newError(code ? `Process from config.webServer was not able to start. Exit code: ${code}` : 'Process from config.webServer exited early.')),
145
+
onExit: code=>processExitedReject(newError(code ? `Process from ${this._configLabel} was not able to start. Exit code: ${code}` : `Process from ${this._configLabel} exited early.`)),
143
146
tempDirectories: [],
144
147
});
145
148
this._killProcess=gracefullyClose;
@@ -205,7 +208,7 @@ export class WebServerPlugin implements TestRunnerPlugin {
0 commit comments