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
Copy file name to clipboardExpand all lines: docs/src/test-api/class-testproject.md
+13-1
Original file line number
Diff line number
Diff line change
@@ -146,7 +146,7 @@ Filter to only run tests with a title matching one of the patterns. For example,
146
146
* since: v1.10
147
147
- type: ?<[RegExp]|[Array]<[RegExp]>>
148
148
149
-
Filter to only run tests with a title **not** matching one of the patterns. This is the opposite of [`property: TestProject.grep`]. Also available globally and in the [command line](../test-cli.md) with the `--grep-invert` option.
149
+
Filter to only run tests with a title **not** matching one of the patterns. This is the opposite of [`property: TestProject.grep`]. Also available globally and in the [command line](../test-cli.md) with the `--grep-invert` option. This filter and its command line counterpart also applies to the setup files. If all [`property: TestProject.setupMatch`] tests match the filter Playwright **will** run all setup files before running the matching tests.
150
150
151
151
`grepInvert` option is also useful for [tagging tests](../test-annotations.md#tag-tests).
152
152
@@ -162,6 +162,18 @@ Metadata that will be put directly to the test report serialized as JSON.
162
162
163
163
Project name is visible in the report and during test execution.
Project setup files that will be executed before all tests in the project.
170
+
171
+
**Details**
172
+
173
+
If project setup fails the tests in this project will be skipped. All project setup files will run in every shard if the project is sharded. [`property: TestProject.grep`] and [`property: TestProject.grepInvert`] and their command line counterparts also apply to the setup files. If such filters match only tests in the project, Playwright will run **all** setup files before running the matching tests.
174
+
175
+
If there is a file that matches both [`property: TestProject.setupMatch`] and [`property: TestProject.testMatch`] filters an error will be thrown.
Copy file name to clipboardExpand all lines: packages/playwright-test/src/runner.ts
+3-3
Original file line number
Diff line number
Diff line change
@@ -258,13 +258,13 @@ export class Runner {
258
258
if(!isTest&&!isSetup)
259
259
returnfalse;
260
260
if(isSetup&&isTest)
261
-
thrownewError(`File "${file}" matches both '_setup' and 'testMatch' filters in project "${project.name}"`);
261
+
thrownewError(`File "${file}" matches both 'setup' and 'testMatch' filters in project "${project.name}"`);
262
262
if(fileToProjectName.has(file)){
263
263
if(isSetup){
264
264
if(!setupFiles.has(file))
265
-
thrownewError(`File "${file}" matches '_setup' filter in project "${project.name}" and 'testMatch' filter in project "${fileToProjectName.get(file)}"`);
265
+
thrownewError(`File "${file}" matches 'setup' filter in project "${project.name}" and 'testMatch' filter in project "${fileToProjectName.get(file)}"`);
266
266
}elseif(setupFiles.has(file)){
267
-
thrownewError(`File "${file}" matches '_setup' filter in project "${fileToProjectName.get(file)}" and 'testMatch' filter in project "${project.name}"`);
267
+
thrownewError(`File "${file}" matches 'setup' filter in project "${fileToProjectName.get(file)}" and 'testMatch' filter in project "${project.name}"`);
// This is required to not export everything by default. See https://github.com/Microsoft/TypeScript/issues/19545#issuecomment-340490459
3350
3393
export{};
@@ -4639,7 +4682,10 @@ interface TestProject {
4639
4682
/**
4640
4683
* Filter to only run tests with a title **not** matching one of the patterns. This is the opposite of
4641
4684
* [testProject.grep](https://playwright.dev/docs/api/class-testproject#test-project-grep). Also available globally
4642
-
* and in the [command line](https://playwright.dev/docs/test-cli) with the `--grep-invert` option.
4685
+
* and in the [command line](https://playwright.dev/docs/test-cli) with the `--grep-invert` option. This filter and its command line
4686
+
* counterpart also applies to the setup files. If all
4687
+
* [testProject.setupMatch](https://playwright.dev/docs/api/class-testproject#test-project-setup-match) tests match
4688
+
* the filter Playwright **will** run all setup files before running the matching tests.
4643
4689
*
4644
4690
* `grepInvert` option is also useful for [tagging tests](https://playwright.dev/docs/test-annotations#tag-tests).
4645
4691
*/
@@ -4655,6 +4701,24 @@ interface TestProject {
4655
4701
*/
4656
4702
name?: string;
4657
4703
4704
+
/**
4705
+
* Project setup files that will be executed before all tests in the project.
4706
+
*
4707
+
* **Details**
4708
+
*
4709
+
* If project setup fails the tests in this project will be skipped. All project setup files will run in every shard
4710
+
* if the project is sharded. [testProject.grep](https://playwright.dev/docs/api/class-testproject#test-project-grep)
4711
+
* and [testProject.grepInvert](https://playwright.dev/docs/api/class-testproject#test-project-grep-invert) and their
4712
+
* command line counterparts also apply to the setup files. If such filters match only tests in the project,
4713
+
* Playwright will run **all** setup files before running the matching tests.
4714
+
*
4715
+
* If there is a file that matches both
4716
+
* [testProject.setupMatch](https://playwright.dev/docs/api/class-testproject#test-project-setup-match) and
4717
+
* [testProject.testMatch](https://playwright.dev/docs/api/class-testproject#test-project-test-match) filters an error
4718
+
* will be thrown.
4719
+
*/
4720
+
setupMatch?: string|RegExp|Array<string|RegExp>;
4721
+
4658
4722
/**
4659
4723
* The base directory, relative to the config file, for snapshot files created with `toMatchSnapshot`. Defaults to
0 commit comments