Skip to content

Commit

Permalink
fix(api): hide TestConfig.groups (#17853)
Browse files Browse the repository at this point in the history
Also fix types for `FullConfig.configFile`.
  • Loading branch information
dgozman authored Oct 5, 2022
1 parent 795730f commit 6750a02
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 61 deletions.
17 changes: 0 additions & 17 deletions docs/src/test-api/class-testconfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]>
Expand Down Expand Up @@ -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]>
Expand Down
9 changes: 5 additions & 4 deletions packages/playwright-test/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]) {
Expand Down Expand Up @@ -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`);
Expand Down Expand Up @@ -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));
Expand Down
40 changes: 0 additions & 40 deletions packages/playwright-test/types/test.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()`.
Expand Down Expand Up @@ -1337,9 +1300,6 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
*
*/
webServer: TestConfigWebServer | null;
/**
* Path to config file, if any.
*/
configFile?: string;
}

Expand Down
1 change: 1 addition & 0 deletions utils/generate_types/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ class TypesGenerator {
['PlaywrightTestArgs', 'Fixtures'],
]),
ignoreMissing: new Set([
'FullConfig.configFile',
'FullConfig.version',
'FullConfig.rootDir',
'SuiteFunction',
Expand Down

0 comments on commit 6750a02

Please sign in to comment.