From 2f2a943740d5c666367fc2eeb8acb9abe0dd50c9 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Mon, 1 Apr 2024 16:04:31 -0700 Subject: [PATCH] move classes to test-reporter --- .../class-fullconfig.md | 0 .../class-fullproject.md | 2 +- packages/playwright/types/testReporter.d.ts | 223 +++++++++++++++++- 3 files changed, 223 insertions(+), 2 deletions(-) rename docs/src/{test-api => test-reporter-api}/class-fullconfig.md (100%) rename docs/src/{test-api => test-reporter-api}/class-fullproject.md (98%) diff --git a/docs/src/test-api/class-fullconfig.md b/docs/src/test-reporter-api/class-fullconfig.md similarity index 100% rename from docs/src/test-api/class-fullconfig.md rename to docs/src/test-reporter-api/class-fullconfig.md diff --git a/docs/src/test-api/class-fullproject.md b/docs/src/test-reporter-api/class-fullproject.md similarity index 98% rename from docs/src/test-api/class-fullproject.md rename to docs/src/test-reporter-api/class-fullproject.md index 2ddf343323..9a744115df 100644 --- a/docs/src/test-api/class-fullproject.md +++ b/docs/src/test-reporter-api/class-fullproject.md @@ -5,7 +5,7 @@ Runtime representation of the test project configuration that is passed to [Reporter]. It exposes some of the resolved fields declared in [TestProject]. You can get [FullProject] instance from [`property: FullConfig.projects`] -or [`property: Suite.project`]. +or [`method: Suite.project`]. ## property: FullProject.dependencies * since: v1.31 diff --git a/packages/playwright/types/testReporter.d.ts b/packages/playwright/types/testReporter.d.ts index 987d51e004..fa4403201c 100644 --- a/packages/playwright/types/testReporter.d.ts +++ b/packages/playwright/types/testReporter.d.ts @@ -20,7 +20,7 @@ export type { FullConfig, TestStatus, FullProject } from './test'; /** * `Suite` is a group of tests. All tests in Playwright Test form the following hierarchy: - * - Root suite has a child suite for each {@link TestProject}. + * - Root suite has a child suite for each {@link FullProject}. * - Project suite #1. Has a child suite for each test file in the project. * - File suite #1 * - {@link TestCase} #1 @@ -624,6 +624,227 @@ export type JSONReportSTDIOEntry = { text: string } | { buffer: string }; export {}; +/** + * Resolved configuration passed to + * [reporter.onBegin(config, suite)](https://playwright.dev/docs/api/class-reporter#reporter-on-begin). + */ +export interface FullConfig { + /** + * Path to the configuration file (if any) used to run the tests. + */ + configFile?: string; + + /** + * See [testConfig.forbidOnly](https://playwright.dev/docs/api/class-testconfig#test-config-forbid-only). + */ + forbidOnly: boolean; + + /** + * See [testConfig.fullyParallel](https://playwright.dev/docs/api/class-testconfig#test-config-fully-parallel). + */ + fullyParallel: boolean; + + /** + * See [testConfig.globalSetup](https://playwright.dev/docs/api/class-testconfig#test-config-global-setup). + */ + globalSetup: null|string; + + /** + * See [testConfig.globalTeardown](https://playwright.dev/docs/api/class-testconfig#test-config-global-teardown). + */ + globalTeardown: null|string; + + /** + * See [testConfig.globalTimeout](https://playwright.dev/docs/api/class-testconfig#test-config-global-timeout). + */ + globalTimeout: number; + + /** + * See [testConfig.grep](https://playwright.dev/docs/api/class-testconfig#test-config-grep). + */ + grep: RegExp|Array; + + /** + * See [testConfig.grepInvert](https://playwright.dev/docs/api/class-testconfig#test-config-grep-invert). + */ + grepInvert: null|RegExp|Array; + + /** + * See [testConfig.maxFailures](https://playwright.dev/docs/api/class-testconfig#test-config-max-failures). + */ + maxFailures: number; + + /** + * See [testConfig.metadata](https://playwright.dev/docs/api/class-testconfig#test-config-metadata). + */ + metadata: Metadata; + + /** + * See [testConfig.preserveOutput](https://playwright.dev/docs/api/class-testconfig#test-config-preserve-output). + */ + preserveOutput: "always"|"never"|"failures-only"; + + /** + * List of resolved projects. + */ + projects: Array; + + /** + * See [testConfig.quiet](https://playwright.dev/docs/api/class-testconfig#test-config-quiet). + */ + quiet: boolean; + + /** + * See [testConfig.reporter](https://playwright.dev/docs/api/class-testconfig#test-config-reporter). + */ + reporter: string|Array<{ + /** + * Reporter name or module or file path + */ + 0: string; + + /** + * An object with reporter options if any + */ + 1: Object; + }>|"list"|"dot"|"line"|"github"|"json"|"junit"|"null"|"html"; + + /** + * See [testConfig.reportSlowTests](https://playwright.dev/docs/api/class-testconfig#test-config-report-slow-tests). + */ + reportSlowTests: null|{ + /** + * The maximum number of slow test files to report. Defaults to `5`. + */ + max: number; + + /** + * Test duration in milliseconds that is considered slow. Defaults to 15 seconds. + */ + threshold: number; + }; + + rootDir: string; + + /** + * See [testConfig.shard](https://playwright.dev/docs/api/class-testconfig#test-config-shard). + */ + shard: null|{ + /** + * The total number of shards. + */ + total: number; + + /** + * The index of the shard to execute, one-based. + */ + current: number; + }; + + /** + * See [testConfig.updateSnapshots](https://playwright.dev/docs/api/class-testconfig#test-config-update-snapshots). + */ + updateSnapshots: "all"|"none"|"missing"; + + /** + * Playwright version. + */ + version: string; + + /** + * See [testConfig.webServer](https://playwright.dev/docs/api/class-testconfig#test-config-web-server). + */ + webServer: null|Object; + + /** + * See [testConfig.workers](https://playwright.dev/docs/api/class-testconfig#test-config-workers). + */ + workers: number; +} + +/** + * Runtime representation of the test project configuration that is passed to {@link Reporter}. It exposes some of the + * resolved fields declared in {@link TestProject}. You can get {@link FullProject} instance from + * [fullConfig.projects](https://playwright.dev/docs/api/class-fullconfig#full-config-projects) or + * [suite.project()](https://playwright.dev/docs/api/class-suite#suite-project). + */ +export interface FullProject { + /** + * See [testProject.dependencies](https://playwright.dev/docs/api/class-testproject#test-project-dependencies). + */ + dependencies: Array; + + /** + * See [testProject.grep](https://playwright.dev/docs/api/class-testproject#test-project-grep). + */ + grep: RegExp|Array; + + /** + * See [testProject.grepInvert](https://playwright.dev/docs/api/class-testproject#test-project-grep-invert). + */ + grepInvert: null|RegExp|Array; + + /** + * See [testProject.metadata](https://playwright.dev/docs/api/class-testproject#test-project-metadata). + */ + metadata: Metadata; + + /** + * See [testProject.name](https://playwright.dev/docs/api/class-testproject#test-project-name). + */ + name: string; + + /** + * See [testProject.outputDir](https://playwright.dev/docs/api/class-testproject#test-project-output-dir). + */ + outputDir: string; + + /** + * See [testProject.repeatEach](https://playwright.dev/docs/api/class-testproject#test-project-repeat-each). + */ + repeatEach: number; + + /** + * See [testProject.retries](https://playwright.dev/docs/api/class-testproject#test-project-retries). + */ + retries: number; + + /** + * See [testProject.snapshotDir](https://playwright.dev/docs/api/class-testproject#test-project-snapshot-dir). + */ + snapshotDir: string; + + /** + * See [testProject.teardown](https://playwright.dev/docs/api/class-testproject#test-project-teardown). + */ + teardown?: string; + + /** + * See [testProject.testDir](https://playwright.dev/docs/api/class-testproject#test-project-test-dir). + */ + testDir: string; + + /** + * See [testProject.testIgnore](https://playwright.dev/docs/api/class-testproject#test-project-test-ignore). + */ + testIgnore: string|RegExp|Array; + + /** + * See [testProject.testMatch](https://playwright.dev/docs/api/class-testproject#test-project-test-match). + */ + testMatch: string|RegExp|Array; + + /** + * See [testProject.timeout](https://playwright.dev/docs/api/class-testproject#test-project-timeout). + */ + timeout: number; + + /** + * See [testProject.use](https://playwright.dev/docs/api/class-testproject#test-project-use). + */ + use: Fixtures; +} + /** * Represents a location in the source code where {@link TestCase} or {@link Suite} is defined. */