Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(api): hide `TestConfig.groups` (#17853)

Dmitry Gozman6750a025061d
diff --git a/docs/src/test-api/class-testconfig.md b/docs/src/test-api/class-testconfig.md
index eaac181dbe..7eace0f88a 100644
--- a/docs/src/test-api/class-testconfig.md
+++ b/docs/src/test-api/class-testconfig.md
@@ -84,12 +84,6 @@ const config: PlaywrightTestConfig = {
export default config;
```
-## property: TestConfig.configFile
-* since: v1.27
-- type: ?<[string]>
-
-Path to config file, if any.
-
## property: TestConfig.forbidOnly
* since: v1.10
- type: ?<[boolean]>
@@ -232,17 +226,6 @@ Filter to only run tests with a title **not** matching one of the patterns. This
`grepInvert` option is also useful for [tagging tests](../test-annotations.md#tag-tests).
-## property: TestConfig.groups
-* since: v1.27
-- type: ?<[Object]<[string],[Array]<[string]|[Array]<[string]|[Object]>>>>
- - `project` <[string]|[Array]<[string]>> Project name(s).
- - `grep` ?<[RegExp]|[Array]<[RegExp]>> Filter to only run tests with a title matching one of the patterns.
- - `grepInvert` ?<[RegExp]|[Array]<[RegExp]>> Filter to only run tests with a title **not** matching one of the patterns.
- - `testMatch` ?<[string]|[RegExp]|[Array]<[string]|[RegExp]>> Only the files matching one of these patterns are executed as test files. Matching is performed against the absolute file path. Strings are treated as glob patterns.
- - `testIgnore` ?<[string]|[RegExp]|[Array]<[string]|[RegExp]>> Files matching one of these patterns are not executed as test files. Matching is performed against the absolute file path. Strings are treated as glob patterns.
-
-Project groups that control project execution order.
-
## property: TestConfig.ignoreSnapshots
* since: v1.26
- type: ?<[boolean]>
diff --git a/packages/playwright-test/src/loader.ts b/packages/playwright-test/src/loader.ts
index 69de3509e5..6d3faebab9 100644
--- a/packages/playwright-test/src/loader.ts
+++ b/packages/playwright-test/src/loader.ts
@@ -165,7 +165,10 @@ export class Loader {
this._fullConfig.metadata = takeFirst(config.metadata, baseFullConfig.metadata);
this._fullConfig.projects = (config.projects || [config]).map(p => this._resolveProject(config, this._fullConfig, p, throwawayArtifactsPath));
this._assignUniqueProjectIds(this._fullConfig.projects);
- this._fullConfig.groups = config.groups;
+
+ // TODO: restore or remove once groups are decided upon.
+ this._fullConfig.groups = (config as any).groups;
+ validateProjectGroups(this._configFile || '<default config>', this._fullConfig);
}
private _assignUniqueProjectIds(projects: FullProjectInternal[]) {
@@ -533,8 +536,6 @@ function validateConfig(file: string, config: Config) {
});
}
- validateProjectGroups(file, config);
-
if ('quiet' in config && config.quiet !== undefined) {
if (typeof config.quiet !== 'boolean')
throw errorWithFile(file, `config.quiet must be a boolean`);
@@ -641,7 +642,7 @@ function validateProject(file: string, project: Project, title: string) {
}
}
-function validateProjectGroups(file: string, config: Config) {
+function validateProjectGroups(file: string, config: FullConfigInternal) {
if (config.groups === undefined)
return;
const projectNames = new Set(config.projects?.filter(p => !!p.name).map(p => p.name));
diff --git a/packages/playwright-test/types/test.d.ts b/packages/playwright-test/types/test.d.ts
index 84853d1c92..108c3a205f 100644
--- a/packages/playwright-test/types/test.d.ts
+++ b/packages/playwright-test/types/test.d.ts
@@ -578,11 +578,6 @@ interface TestConfig {
};
};
- /**
- * Path to config file, if any.
- */
- configFile?: string;
-
/**
* Whether to exit with an error if any tests or groups are marked as
* [test.only(title, testFunction)](https://playwright.dev/docs/api/class-test#test-only) or
@@ -683,38 +678,6 @@ interface TestConfig {
*/
grepInvert?: RegExp|Array<RegExp>;
- /**
- * Project groups that control project execution order.
- */
- groups?: { [key: string]: Array<string|Array<string|{
- /**
- * Project name(s).
- */
- project: string|Array<string>;
-
- /**
- * Filter to only run tests with a title matching one of the patterns.
- */
- grep?: RegExp|Array<RegExp>;
-
- /**
- * Filter to only run tests with a title **not** matching one of the patterns.
- */
- grepInvert?: RegExp|Array<RegExp>;
-
- /**
- * Only the files matching one of these patterns are executed as test files. Matching is performed against the absolute
- * file path. Strings are treated as glob patterns.
- */
- testMatch?: string|RegExp|Array<string|RegExp>;
-
- /**
- * Files matching one of these patterns are not executed as test files. Matching is performed against the absolute file
- * path. Strings are treated as glob patterns.
- */
- testIgnore?: string|RegExp|Array<string|RegExp>;
- }>>; };
-
/**
* Whether to skip snapshot expectations, such as `expect(value).toMatchSnapshot()` and `await
* expect(page).toHaveScreenshot()`.
@@ -1337,9 +1300,6 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
*
*/
webServer: TestConfigWebServer | null;
- /**
- * Path to config file, if any.
- */
configFile?: string;
}
diff --git a/utils/generate_types/index.js b/utils/generate_types/index.js
index 00af2ed13c..1ba526933a 100644
--- a/utils/generate_types/index.js
+++ b/utils/generate_types/index.js
@@ -573,6 +573,7 @@ class TypesGenerator {
['PlaywrightTestArgs', 'Fixtures'],
]),
ignoreMissing: new Set([
+ 'FullConfig.configFile',
'FullConfig.version',
'FullConfig.rootDir',
'SuiteFunction',