chore: move implementation of Config and Project to TestConfig and TestProject (#30212)
Reference https://github.com/microsoft/playwright/issues/29768
This commit is contained in:
parent
43745210a5
commit
5c5f0d77e4
1134
packages/playwright/types/test.d.ts
vendored
1134
packages/playwright/types/test.d.ts
vendored
File diff suppressed because it is too large
Load diff
|
|
@ -493,7 +493,14 @@ class TypesGenerator {
|
||||||
const coreDocumentation = parseApi(path.join(PROJECT_DIR, 'docs', 'src', 'api'));
|
const coreDocumentation = parseApi(path.join(PROJECT_DIR, 'docs', 'src', 'api'));
|
||||||
const testDocumentation = parseApi(path.join(PROJECT_DIR, 'docs', 'src', 'test-api'), path.join(PROJECT_DIR, 'docs', 'src', 'api', 'params.md'));
|
const testDocumentation = parseApi(path.join(PROJECT_DIR, 'docs', 'src', 'test-api'), path.join(PROJECT_DIR, 'docs', 'src', 'api', 'params.md'));
|
||||||
const reporterDocumentation = parseApi(path.join(PROJECT_DIR, 'docs', 'src', 'test-reporter-api'));
|
const reporterDocumentation = parseApi(path.join(PROJECT_DIR, 'docs', 'src', 'test-reporter-api'));
|
||||||
const assertionClasses = new Set(['GenericAssertions', 'LocatorAssertions', 'PageAssertions', 'APIResponseAssertions', 'SnapshotAssertions', 'PlaywrightAssertions']);
|
const assertionClasses = new Set([
|
||||||
|
'APIResponseAssertions',
|
||||||
|
'GenericAssertions',
|
||||||
|
'LocatorAssertions',
|
||||||
|
'PageAssertions',
|
||||||
|
'PlaywrightAssertions',
|
||||||
|
'SnapshotAssertions',
|
||||||
|
]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {boolean} includeExperimental
|
* @param {boolean} includeExperimental
|
||||||
|
|
@ -503,7 +510,7 @@ class TypesGenerator {
|
||||||
const documentation = coreDocumentation.clone();
|
const documentation = coreDocumentation.clone();
|
||||||
const generator = new TypesGenerator({
|
const generator = new TypesGenerator({
|
||||||
documentation,
|
documentation,
|
||||||
doNotGenerate: new Set([...assertionClasses]),
|
doNotGenerate: assertionClasses,
|
||||||
includeExperimental,
|
includeExperimental,
|
||||||
});
|
});
|
||||||
let types = await generator.generateTypes(path.join(__dirname, 'overrides.d.ts'));
|
let types = await generator.generateTypes(path.join(__dirname, 'overrides.d.ts'));
|
||||||
|
|
@ -536,12 +543,7 @@ class TypesGenerator {
|
||||||
documentation,
|
documentation,
|
||||||
doNotGenerate: new Set([
|
doNotGenerate: new Set([
|
||||||
...coreDocumentation.classesArray.map(cls => cls.name).filter(name => !assertionClasses.has(name)),
|
...coreDocumentation.classesArray.map(cls => cls.name).filter(name => !assertionClasses.has(name)),
|
||||||
'PlaywrightAssertions',
|
|
||||||
'Test',
|
|
||||||
'Fixtures',
|
'Fixtures',
|
||||||
'TestOptions',
|
|
||||||
'TestConfig.use',
|
|
||||||
'TestProject.use',
|
|
||||||
'GenericAssertions.any',
|
'GenericAssertions.any',
|
||||||
'GenericAssertions.anything',
|
'GenericAssertions.anything',
|
||||||
'GenericAssertions.arrayContaining',
|
'GenericAssertions.arrayContaining',
|
||||||
|
|
@ -549,26 +551,29 @@ class TypesGenerator {
|
||||||
'GenericAssertions.objectContaining',
|
'GenericAssertions.objectContaining',
|
||||||
'GenericAssertions.stringContaining',
|
'GenericAssertions.stringContaining',
|
||||||
'GenericAssertions.stringMatching',
|
'GenericAssertions.stringMatching',
|
||||||
|
'PlaywrightAssertions',
|
||||||
|
'Test',
|
||||||
|
'TestOptions',
|
||||||
]),
|
]),
|
||||||
overridesToDocsClassMapping: new Map([
|
overridesToDocsClassMapping: new Map([
|
||||||
['TestType', 'Test'],
|
['AsymmetricMatchers', 'GenericAssertions'],
|
||||||
['Config', 'TestConfig'],
|
['PlaywrightTestArgs', 'Fixtures'],
|
||||||
['Project', 'TestProject'],
|
|
||||||
['PlaywrightWorkerOptions', 'TestOptions'],
|
|
||||||
['PlaywrightTestOptions', 'TestOptions'],
|
['PlaywrightTestOptions', 'TestOptions'],
|
||||||
['PlaywrightWorkerArgs', 'Fixtures'],
|
['PlaywrightWorkerArgs', 'Fixtures'],
|
||||||
['PlaywrightTestArgs', 'Fixtures'],
|
['PlaywrightWorkerOptions', 'TestOptions'],
|
||||||
['AsymmetricMatchers', 'GenericAssertions'],
|
['TestType', 'Test'],
|
||||||
]),
|
]),
|
||||||
ignoreMissing: new Set([
|
ignoreMissing: new Set([
|
||||||
|
'Config',
|
||||||
|
'ExpectMatcherUtils',
|
||||||
|
'Matchers',
|
||||||
|
'PlaywrightWorkerArgs.playwright',
|
||||||
|
'PlaywrightWorkerOptions.defaultBrowserType',
|
||||||
|
'Project',
|
||||||
'SuiteFunction',
|
'SuiteFunction',
|
||||||
'TestFunction',
|
'TestFunction',
|
||||||
'PlaywrightWorkerOptions.defaultBrowserType',
|
|
||||||
'PlaywrightWorkerArgs.playwright',
|
|
||||||
'Matchers',
|
|
||||||
'ExpectMatcherUtils',
|
|
||||||
]),
|
]),
|
||||||
doNotExportClassNames: new Set([...assertionClasses, 'TestProject']),
|
doNotExportClassNames: assertionClasses,
|
||||||
includeExperimental,
|
includeExperimental,
|
||||||
});
|
});
|
||||||
return await generator.generateTypes(path.join(__dirname, 'overrides-test.d.ts'));
|
return await generator.generateTypes(path.join(__dirname, 'overrides-test.d.ts'));
|
||||||
|
|
@ -590,8 +595,8 @@ class TypesGenerator {
|
||||||
'FullResult',
|
'FullResult',
|
||||||
'JSONReport',
|
'JSONReport',
|
||||||
'JSONReportError',
|
'JSONReportError',
|
||||||
'JSONReportSuite',
|
|
||||||
'JSONReportSpec',
|
'JSONReportSpec',
|
||||||
|
'JSONReportSuite',
|
||||||
'JSONReportTest',
|
'JSONReportTest',
|
||||||
'JSONReportTestResult',
|
'JSONReportTestResult',
|
||||||
'JSONReportTestStep',
|
'JSONReportTestStep',
|
||||||
|
|
|
||||||
13
utils/generate_types/overrides-test.d.ts
vendored
13
utils/generate_types/overrides-test.d.ts
vendored
|
|
@ -31,24 +31,27 @@ export type ReporterDescription =
|
||||||
|
|
||||||
type UseOptions<TestArgs, WorkerArgs> = Partial<WorkerArgs> & Partial<TestArgs>;
|
type UseOptions<TestArgs, WorkerArgs> = Partial<WorkerArgs> & Partial<TestArgs>;
|
||||||
|
|
||||||
export interface Project<TestArgs = {}, WorkerArgs = {}> extends TestProject {
|
interface TestProject<TestArgs = {}, WorkerArgs = {}> {
|
||||||
use?: UseOptions<TestArgs, WorkerArgs>;
|
use?: UseOptions<TestArgs, WorkerArgs>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Project<TestArgs = {}, WorkerArgs = {}> extends TestProject<TestArgs, WorkerArgs> {
|
||||||
|
}
|
||||||
|
|
||||||
export interface ProjectInWorker<TestArgs = {}, WorkerArgs = {}> {
|
export interface ProjectInWorker<TestArgs = {}, WorkerArgs = {}> {
|
||||||
use: UseOptions<PlaywrightTestOptions & TestArgs, PlaywrightWorkerOptions & WorkerArgs>;
|
use: UseOptions<PlaywrightTestOptions & TestArgs, PlaywrightWorkerOptions & WorkerArgs>;
|
||||||
}
|
}
|
||||||
|
|
||||||
type LiteralUnion<T extends U, U = string> = T | (U & { zz_IGNORE_ME?: never });
|
type LiteralUnion<T extends U, U = string> = T | (U & { zz_IGNORE_ME?: never });
|
||||||
|
|
||||||
interface TestConfig {
|
interface TestConfig<TestArgs = {}, WorkerArgs = {}> {
|
||||||
|
projects?: Project<TestArgs, WorkerArgs>[];
|
||||||
reporter?: LiteralUnion<'list'|'dot'|'line'|'github'|'json'|'junit'|'null'|'html', string> | ReporterDescription[];
|
reporter?: LiteralUnion<'list'|'dot'|'line'|'github'|'json'|'junit'|'null'|'html', string> | ReporterDescription[];
|
||||||
|
use?: UseOptions<TestArgs, WorkerArgs>;
|
||||||
webServer?: TestConfigWebServer | TestConfigWebServer[];
|
webServer?: TestConfigWebServer | TestConfigWebServer[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Config<TestArgs = {}, WorkerArgs = {}> extends TestConfig {
|
export interface Config<TestArgs = {}, WorkerArgs = {}> extends TestConfig<TestArgs, WorkerArgs> {
|
||||||
projects?: Project<TestArgs, WorkerArgs>[];
|
|
||||||
use?: UseOptions<TestArgs, WorkerArgs>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Metadata = { [key: string]: any };
|
export type Metadata = { [key: string]: any };
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue