Update generate_types script
This commit is contained in:
parent
993c9a480c
commit
364aba8e32
72
packages/playwright/types/test.d.ts
vendored
72
packages/playwright/types/test.d.ts
vendored
|
|
@ -586,56 +586,6 @@ interface TestProject<TestArgs = {}, WorkerArgs = {}> {
|
|||
timeout?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* `TestProject` encapsulates configuration specific to a single project. Projects are configured in
|
||||
* [testConfig.projects](https://playwright.dev/docs/api/class-testconfig#test-config-projects) specified in the
|
||||
* [configuration file](https://playwright.dev/docs/test-configuration). Note that all properties of {@link TestProject} are available in
|
||||
* the top-level {@link TestConfig}, in which case they are shared between all projects.
|
||||
*
|
||||
* Here is an example configuration that runs every test in Chromium, Firefox and WebKit, both Desktop and Mobile
|
||||
* versions.
|
||||
*
|
||||
* ```js
|
||||
* // playwright.config.ts
|
||||
* import { defineConfig, devices } from '@playwright/test';
|
||||
*
|
||||
* export default defineConfig({
|
||||
* // Options shared for all projects.
|
||||
* timeout: 30000,
|
||||
* use: {
|
||||
* ignoreHTTPSErrors: true,
|
||||
* },
|
||||
*
|
||||
* // Options specific to each project.
|
||||
* projects: [
|
||||
* {
|
||||
* name: 'chromium',
|
||||
* use: devices['Desktop Chrome'],
|
||||
* },
|
||||
* {
|
||||
* name: 'firefox',
|
||||
* use: devices['Desktop Firefox'],
|
||||
* },
|
||||
* {
|
||||
* name: 'webkit',
|
||||
* use: devices['Desktop Safari'],
|
||||
* },
|
||||
* {
|
||||
* name: 'Mobile Chrome',
|
||||
* use: devices['Pixel 5'],
|
||||
* },
|
||||
* {
|
||||
* name: 'Mobile Safari',
|
||||
* use: devices['iPhone 12'],
|
||||
* },
|
||||
* ],
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
export interface Project<TestArgs = {}, WorkerArgs = {}> extends TestProject<TestArgs, WorkerArgs> {
|
||||
}
|
||||
|
||||
|
|
@ -1674,28 +1624,6 @@ interface TestConfig<TestArgs = {}, WorkerArgs = {}> {
|
|||
workers?: number|string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Playwright Test provides many options to configure how your tests are collected and executed, for example `timeout`
|
||||
* or `testDir`. These options are described in the {@link TestConfig} object in the
|
||||
* [configuration file](https://playwright.dev/docs/test-configuration).
|
||||
*
|
||||
* Playwright Test supports running multiple test projects at the same time. Project-specific options should be put to
|
||||
* [testConfig.projects](https://playwright.dev/docs/api/class-testconfig#test-config-projects), but top-level {@link
|
||||
* TestConfig} can also define base options shared between all projects.
|
||||
*
|
||||
* ```js
|
||||
* // playwright.config.ts
|
||||
* import { defineConfig } from '@playwright/test';
|
||||
*
|
||||
* export default defineConfig({
|
||||
* timeout: 30000,
|
||||
* globalTimeout: 600000,
|
||||
* reporter: 'list',
|
||||
* testDir: './tests',
|
||||
* });
|
||||
* ```
|
||||
*
|
||||
*/
|
||||
export interface Config<TestArgs = {}, WorkerArgs = {}> extends TestConfig<TestArgs, WorkerArgs> {
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -493,7 +493,14 @@ class TypesGenerator {
|
|||
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 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
|
||||
|
|
@ -503,7 +510,7 @@ class TypesGenerator {
|
|||
const documentation = coreDocumentation.clone();
|
||||
const generator = new TypesGenerator({
|
||||
documentation,
|
||||
doNotGenerate: new Set([...assertionClasses]),
|
||||
doNotGenerate: assertionClasses,
|
||||
includeExperimental,
|
||||
});
|
||||
let types = await generator.generateTypes(path.join(__dirname, 'overrides.d.ts'));
|
||||
|
|
@ -536,12 +543,7 @@ class TypesGenerator {
|
|||
documentation,
|
||||
doNotGenerate: new Set([
|
||||
...coreDocumentation.classesArray.map(cls => cls.name).filter(name => !assertionClasses.has(name)),
|
||||
'PlaywrightAssertions',
|
||||
'Test',
|
||||
'Fixtures',
|
||||
'TestOptions',
|
||||
'TestConfig.use',
|
||||
'TestProject.use',
|
||||
'GenericAssertions.any',
|
||||
'GenericAssertions.anything',
|
||||
'GenericAssertions.arrayContaining',
|
||||
|
|
@ -549,26 +551,31 @@ class TypesGenerator {
|
|||
'GenericAssertions.objectContaining',
|
||||
'GenericAssertions.stringContaining',
|
||||
'GenericAssertions.stringMatching',
|
||||
'PlaywrightAssertions',
|
||||
'Test',
|
||||
'TestConfig.use',
|
||||
'TestOptions',
|
||||
'TestProject.use',
|
||||
]),
|
||||
overridesToDocsClassMapping: new Map([
|
||||
['TestType', 'Test'],
|
||||
['Config', 'TestConfig'],
|
||||
['Project', 'TestProject'],
|
||||
['PlaywrightWorkerOptions', 'TestOptions'],
|
||||
['AsymmetricMatchers', 'GenericAssertions'],
|
||||
['PlaywrightTestArgs', 'Fixtures'],
|
||||
['PlaywrightTestOptions', 'TestOptions'],
|
||||
['PlaywrightWorkerArgs', 'Fixtures'],
|
||||
['PlaywrightTestArgs', 'Fixtures'],
|
||||
['AsymmetricMatchers', 'GenericAssertions'],
|
||||
['PlaywrightWorkerOptions', 'TestOptions'],
|
||||
['TestType', 'Test'],
|
||||
]),
|
||||
ignoreMissing: new Set([
|
||||
'Config',
|
||||
'ExpectMatcherUtils',
|
||||
'Matchers',
|
||||
'PlaywrightWorkerArgs.playwright',
|
||||
'PlaywrightWorkerOptions.defaultBrowserType',
|
||||
'Project',
|
||||
'SuiteFunction',
|
||||
'TestFunction',
|
||||
'PlaywrightWorkerOptions.defaultBrowserType',
|
||||
'PlaywrightWorkerArgs.playwright',
|
||||
'Matchers',
|
||||
'ExpectMatcherUtils',
|
||||
]),
|
||||
doNotExportClassNames: new Set([...assertionClasses, 'TestProject']),
|
||||
doNotExportClassNames: assertionClasses,
|
||||
includeExperimental,
|
||||
});
|
||||
return await generator.generateTypes(path.join(__dirname, 'overrides-test.d.ts'));
|
||||
|
|
@ -590,8 +597,8 @@ class TypesGenerator {
|
|||
'FullResult',
|
||||
'JSONReport',
|
||||
'JSONReportError',
|
||||
'JSONReportSuite',
|
||||
'JSONReportSpec',
|
||||
'JSONReportSuite',
|
||||
'JSONReportTest',
|
||||
'JSONReportTestResult',
|
||||
'JSONReportTestStep',
|
||||
|
|
|
|||
Loading…
Reference in a new issue