chore: remove unnecessary types from overrides-test (#13794)

This commit is contained in:
Dmitry Gozman 2022-04-27 16:14:37 +01:00 committed by GitHub
parent d97324e2bd
commit 3aba94dbef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 290 additions and 420 deletions

View File

@ -414,7 +414,7 @@ The name of the snapshot or the path segments to define the snapshot file path.
Suffix used to differentiate snapshots between multiple test configurations. For example, if snapshots depend on the platform, you can set `testInfo.snapshotSuffix` equal to `process.platform`. In this case `expect(value).toMatchSnapshot(snapshotName)` will use different snapshots depending on the platform. Learn more about [snapshots](../test-snapshots.md). Suffix used to differentiate snapshots between multiple test configurations. For example, if snapshots depend on the platform, you can set `testInfo.snapshotSuffix` equal to `process.platform`. In this case `expect(value).toMatchSnapshot(snapshotName)` will use different snapshots depending on the platform. Learn more about [snapshots](../test-snapshots.md).
## property: TestInfo.status ## property: TestInfo.status
- type: <[void]|[TestStatus]<"passed"|"failed"|"timedOut"|"skipped">> - type: ?<[TestStatus]<"passed"|"failed"|"timedOut"|"skipped">>
Actual status for the currently running test. Available after the test has finished in [`method: Test.afterEach`] hook and fixtures. Actual status for the currently running test. Available after the test has finished in [`method: Test.afterEach`] hook and fixtures.

View File

@ -15,7 +15,7 @@
*/ */
import { installTransform, setCurrentlyLoadingTestFile } from './transform'; import { installTransform, setCurrentlyLoadingTestFile } from './transform';
import type { Config, Project, ReporterDescription, PreserveOutput, FullProjectInternal, GlobalInfo } from './types'; import type { Config, Project, ReporterDescription, FullProjectInternal, GlobalInfo } from './types';
import type { FullConfigInternal } from './types'; import type { FullConfigInternal } from './types';
import { getPackageJsonPath, mergeObjects, errorWithFile } from './util'; import { getPackageJsonPath, mergeObjects, errorWithFile } from './util';
import { setCurrentlyLoadingFileSuite } from './globals'; import { setCurrentlyLoadingFileSuite } from './globals';
@ -116,7 +116,7 @@ export class Loader {
this._fullConfig.grep = takeFirst(this._configOverrides.grep, config.grep, baseFullConfig.grep); this._fullConfig.grep = takeFirst(this._configOverrides.grep, config.grep, baseFullConfig.grep);
this._fullConfig.grepInvert = takeFirst(this._configOverrides.grepInvert, config.grepInvert, baseFullConfig.grepInvert); this._fullConfig.grepInvert = takeFirst(this._configOverrides.grepInvert, config.grepInvert, baseFullConfig.grepInvert);
this._fullConfig.maxFailures = takeFirst(this._configOverrides.maxFailures, config.maxFailures, baseFullConfig.maxFailures); this._fullConfig.maxFailures = takeFirst(this._configOverrides.maxFailures, config.maxFailures, baseFullConfig.maxFailures);
this._fullConfig.preserveOutput = takeFirst<PreserveOutput>(this._configOverrides.preserveOutput, config.preserveOutput, baseFullConfig.preserveOutput); this._fullConfig.preserveOutput = takeFirst(this._configOverrides.preserveOutput, config.preserveOutput, baseFullConfig.preserveOutput);
this._fullConfig.reporter = takeFirst(toReporters(this._configOverrides.reporter as any), resolveReporters(config.reporter, configDir), baseFullConfig.reporter); this._fullConfig.reporter = takeFirst(toReporters(this._configOverrides.reporter as any), resolveReporters(config.reporter, configDir), baseFullConfig.reporter);
this._fullConfig.reportSlowTests = takeFirst(this._configOverrides.reportSlowTests, config.reportSlowTests, baseFullConfig.reportSlowTests); this._fullConfig.reportSlowTests = takeFirst(this._configOverrides.reportSlowTests, config.reportSlowTests, baseFullConfig.reportSlowTests);
this._fullConfig.quiet = takeFirst(this._configOverrides.quiet, config.quiet, baseFullConfig.quiet); this._fullConfig.quiet = takeFirst(this._configOverrides.quiet, config.quiet, baseFullConfig.quiet);

View File

@ -17,7 +17,7 @@
import type { Locator, Page } from 'playwright-core'; import type { Locator, Page } from 'playwright-core';
import type { Page as PageEx } from 'playwright-core/lib/client/page'; import type { Page as PageEx } from 'playwright-core/lib/client/page';
import type { Locator as LocatorEx } from 'playwright-core/lib/client/locator'; import type { Locator as LocatorEx } from 'playwright-core/lib/client/locator';
import type { Expect, UpdateSnapshots } from '../types'; import type { Expect } from '../types';
import { currentTestInfo } from '../globals'; import { currentTestInfo } from '../globals';
import type { ImageComparatorOptions, Comparator } from 'playwright-core/lib/utils/comparators'; import type { ImageComparatorOptions, Comparator } from 'playwright-core/lib/utils/comparators';
import { getComparator } from 'playwright-core/lib/utils/comparators'; import { getComparator } from 'playwright-core/lib/utils/comparators';
@ -51,7 +51,7 @@ class SnapshotHelper<T extends ImageComparatorOptions> {
readonly diffPath: string; readonly diffPath: string;
readonly mimeType: string; readonly mimeType: string;
readonly kind: 'Screenshot'|'Snapshot'; readonly kind: 'Screenshot'|'Snapshot';
readonly updateSnapshots: UpdateSnapshots; readonly updateSnapshots: 'all' | 'none' | 'missing';
readonly comparatorOptions: ImageComparatorOptions; readonly comparatorOptions: ImageComparatorOptions;
readonly comparator: Comparator; readonly comparator: Comparator;
readonly allOptions: T; readonly allOptions: T;

View File

@ -19,7 +19,7 @@ import https from 'https';
import net from 'net'; import net from 'net';
import { debug } from 'playwright-core/lib/utilsBundle'; import { debug } from 'playwright-core/lib/utilsBundle';
import { raceAgainstTimeout } from 'playwright-core/lib/utils/timeoutRunner'; import { raceAgainstTimeout } from 'playwright-core/lib/utils/timeoutRunner';
import type { WebServerConfig } from './types'; import type { FullConfig } from './types';
import { launchProcess } from 'playwright-core/lib/utils/processLauncher'; import { launchProcess } from 'playwright-core/lib/utils/processLauncher';
import type { Reporter } from '../types/testReporter'; import type { Reporter } from '../types/testReporter';
@ -29,6 +29,8 @@ const DEFAULT_ENVIRONMENT_VARIABLES = {
const debugWebServer = debug('pw:webserver'); const debugWebServer = debug('pw:webserver');
type WebServerConfig = NonNullable<FullConfig['webServer']>;
export class WebServer { export class WebServer {
private _isAvailable: () => Promise<boolean>; private _isAvailable: () => Promise<boolean>;
private _killProcess?: () => Promise<void>; private _killProcess?: () => Promise<void>;

View File

@ -29,11 +29,6 @@ export type ReporterDescription =
['null'] | ['null'] |
[string] | [string, any]; [string] | [string, any];
export type Shard = { total: number, current: number } | null;
export type ReportSlowTests = { max: number, threshold: number } | null;
export type PreserveOutput = 'always' | 'never' | 'failures-only';
export type UpdateSnapshots = 'all' | 'none' | 'missing';
type UseOptions<TestArgs, WorkerArgs> = { [K in keyof WorkerArgs]?: WorkerArgs[K] } & { [K in keyof TestArgs]?: TestArgs[K] }; type UseOptions<TestArgs, WorkerArgs> = { [K in keyof WorkerArgs]?: WorkerArgs[K] } & { [K in keyof TestArgs]?: TestArgs[K] };
/** /**
@ -369,46 +364,6 @@ export interface FullProject<TestArgs = {}, WorkerArgs = {}> {
use: UseOptions<PlaywrightTestOptions & TestArgs, PlaywrightWorkerOptions & WorkerArgs>; use: UseOptions<PlaywrightTestOptions & TestArgs, PlaywrightWorkerOptions & WorkerArgs>;
} }
export type WebServerConfig = {
/**
* Shell command to start. For example `npm run start`.
*/
command: string,
/**
* The port that your http server is expected to appear on. It does wait until it accepts connections.
* Exactly one of `port` or `url` is required.
*/
port?: number,
/**
* The url on your http server that is expected to return a 2xx status code when the server is ready to accept connections.
* Exactly one of `port` or `url` is required.
*/
url?: string,
/**
* Whether to ignore HTTPS errors when fetching the `url`. Defaults to `false`.
*/
ignoreHTTPSErrors?: boolean,
/**
* How long to wait for the process to start up and be available in milliseconds. Defaults to 60000.
*/
timeout?: number,
/**
* If true, it will re-use an existing server on the port or url when available. If no server is running
* on that port or url, it will run the command to start a new server.
* If false, it will throw if an existing process is listening on the port or url.
* This should commonly set to !process.env.CI to allow the local dev server when running tests locally.
*/
reuseExistingServer?: boolean
/**
* Environment variables, process.env by default
*/
env?: Record<string, string>,
/**
* Current working directory of the spawned process. Default is process.cwd().
*/
cwd?: string,
};
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 });
/** /**
@ -456,6 +411,54 @@ interface TestConfig {
* *
*/ */
reporter?: LiteralUnion<'list'|'dot'|'line'|'github'|'json'|'junit'|'null'|'html', string> | ReporterDescription[]; reporter?: LiteralUnion<'list'|'dot'|'line'|'github'|'json'|'junit'|'null'|'html', string> | ReporterDescription[];
/**
* Launch a development web server during the tests.
*
* If the port is specified, the server will wait for it to be available on `127.0.0.1` or `::1`, before running the tests.
* If the url is specified, the server will wait for the URL to return a 2xx status code before running the tests.
*
* For continuous integration, you may want to use the `reuseExistingServer: !process.env.CI` option which does not use an
* existing server on the CI. To see the stdout, you can set the `DEBUG=pw:webserver` environment variable.
*
* The `port` (but not the `url`) gets passed over to Playwright as a
* [testOptions.baseURL](https://playwright.dev/docs/api/class-testoptions#test-options-base-url). For example port `8080`
* produces `baseURL` equal `http://localhost:8080`.
*
* > NOTE: It is also recommended to specify
* [testOptions.baseURL](https://playwright.dev/docs/api/class-testoptions#test-options-base-url) in the config, so that
* tests could use relative urls.
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* const config: PlaywrightTestConfig = {
* webServer: {
* command: 'npm run start',
* port: 3000,
* timeout: 120 * 1000,
* reuseExistingServer: !process.env.CI,
* },
* use: {
* baseURL: 'http://localhost:3000/',
* },
* };
* export default config;
* ```
*
* Now you can use a relative path when navigating the page:
*
* ```ts
* // test.spec.ts
* import { test } from '@playwright/test';
*
* test('test', async ({ page }) => {
* // This will result in http://localhost:3000/foo
* await page.goto('/foo');
* });
* ```
*
*/
webServer?: TestConfigWebServer;
/** /**
* Configuration for the `expect` assertion library. Learn more about [various timeouts](https://playwright.dev/docs/test-timeouts). * Configuration for the `expect` assertion library. Learn more about [various timeouts](https://playwright.dev/docs/test-timeouts).
* *
@ -848,100 +851,6 @@ interface TestConfig {
*/ */
updateSnapshots?: "all"|"none"|"missing"; updateSnapshots?: "all"|"none"|"missing";
/**
* Launch a development web server during the tests.
*
* If the port is specified, the server will wait for it to be available on `127.0.0.1` or `::1`, before running the tests.
* If the url is specified, the server will wait for the URL to return a 2xx status code before running the tests.
*
* For continuous integration, you may want to use the `reuseExistingServer: !process.env.CI` option which does not use an
* existing server on the CI. To see the stdout, you can set the `DEBUG=pw:webserver` environment variable.
*
* The `port` (but not the `url`) gets passed over to Playwright as a
* [testOptions.baseURL](https://playwright.dev/docs/api/class-testoptions#test-options-base-url). For example port `8080`
* produces `baseURL` equal `http://localhost:8080`.
*
* > NOTE: It is also recommended to specify
* [testOptions.baseURL](https://playwright.dev/docs/api/class-testoptions#test-options-base-url) in the config, so that
* tests could use relative urls.
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* const config: PlaywrightTestConfig = {
* webServer: {
* command: 'npm run start',
* port: 3000,
* timeout: 120 * 1000,
* reuseExistingServer: !process.env.CI,
* },
* use: {
* baseURL: 'http://localhost:3000/',
* },
* };
* export default config;
* ```
*
* Now you can use a relative path when navigating the page:
*
* ```ts
* // test.spec.ts
* import { test } from '@playwright/test';
*
* test('test', async ({ page }) => {
* // This will result in http://localhost:3000/foo
* await page.goto('/foo');
* });
* ```
*
*/
webServer?: {
/**
* Shell command to start. For example `npm run start`..
*/
command: string;
/**
* The port that your http server is expected to appear on. It does wait until it accepts connections. Exactly one of
* `port` or `url` is required.
*/
port?: number;
/**
* The url on your http server that is expected to return a 2xx status code when the server is ready to accept connections.
* Exactly one of `port` or `url` is required.
*/
url?: string;
/**
* Whether to ignore HTTPS errors when fetching the `url`. Defaults to `false`.
*/
ignoreHTTPSErrors?: boolean;
/**
* How long to wait for the process to start up and be available in milliseconds. Defaults to 60000.
*/
timeout?: number;
/**
* If true, it will re-use an existing server on the `port` or `url` when available. If no server is running on that `port`
* or `url`, it will run the command to start a new server. If `false`, it will throw if an existing process is listening
* on the `port` or `url`. This should be commonly set to `!process.env.CI` to allow the local dev server when running
* tests locally.
*/
reuseExistingServer?: boolean;
/**
* Current working directory of the spawned process, defaults to the directory of the configuration file.
*/
cwd?: string;
/**
* Environment variables to set for the command, `process.env` by default.
*/
env?: { [key: string]: string; };
};
/** /**
* The maximum number of concurrent worker processes to use for parallelizing tests. * The maximum number of concurrent worker processes to use for parallelizing tests.
* *
@ -1154,7 +1063,7 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
* - `'never'` - do not preserve output for any tests; * - `'never'` - do not preserve output for any tests;
* - `'failures-only'` - only preserve output for failed tests. * - `'failures-only'` - only preserve output for failed tests.
*/ */
preserveOutput: PreserveOutput; preserveOutput: 'always' | 'never' | 'failures-only';
/** /**
* Playwright Test supports running multiple test projects at the same time. See [TestProject] for more information. * Playwright Test supports running multiple test projects at the same time. See [TestProject] for more information.
*/ */
@ -1187,7 +1096,7 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
* Test files that took more than `threshold` milliseconds are considered slow, and the slowest ones are reported, no more * Test files that took more than `threshold` milliseconds are considered slow, and the slowest ones are reported, no more
* than `max` number of them. Passing zero as `max` reports all test files that exceed the threshold. * than `max` number of them. Passing zero as `max` reports all test files that exceed the threshold.
*/ */
reportSlowTests: ReportSlowTests; reportSlowTests: { max: number, threshold: number } | null;
rootDir: string; rootDir: string;
/** /**
* Whether to suppress stdio and stderr output from the tests. * Whether to suppress stdio and stderr output from the tests.
@ -1198,7 +1107,7 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
* *
* Learn more about [parallelism and sharding](https://playwright.dev/docs/test-parallel) with Playwright Test. * Learn more about [parallelism and sharding](https://playwright.dev/docs/test-parallel) with Playwright Test.
*/ */
shard: Shard; shard: { total: number, current: number } | null;
/** /**
* Whether to update expected snapshots with the actual results produced by the test run. Defaults to `'missing'`. * Whether to update expected snapshots with the actual results produced by the test run. Defaults to `'missing'`.
* - `'all'` - All tests that are executed will update snapshots. * - `'all'` - All tests that are executed will update snapshots.
@ -1208,7 +1117,7 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
* *
* Learn more about [snapshots](https://playwright.dev/docs/test-snapshots). * Learn more about [snapshots](https://playwright.dev/docs/test-snapshots).
*/ */
updateSnapshots: UpdateSnapshots; updateSnapshots: 'all' | 'none' | 'missing';
/** /**
* The maximum number of concurrent worker processes to use for parallelizing tests. * The maximum number of concurrent worker processes to use for parallelizing tests.
* *
@ -1277,7 +1186,7 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
* ``` * ```
* *
*/ */
webServer: WebServerConfig | null; webServer: TestConfigWebServer | null;
} }
export type TestStatus = 'passed' | 'failed' | 'timedOut' | 'skipped'; export type TestStatus = 'passed' | 'failed' | 'timedOut' | 'skipped';
@ -1351,43 +1260,6 @@ export interface TestInfo {
* Processed project configuration from the [configuration file](https://playwright.dev/docs/test-configuration). * Processed project configuration from the [configuration file](https://playwright.dev/docs/test-configuration).
*/ */
project: FullProject; project: FullProject;
/**
* Expected status for the currently running test. This is usually `'passed'`, except for a few cases:
* - `'skipped'` for skipped tests, e.g. with [test.skip()](https://playwright.dev/docs/api/class-test#test-skip-2);
* - `'failed'` for tests marked as failed with [test.fail()](https://playwright.dev/docs/api/class-test#test-fail-1).
*
* Expected status is usually compared with the actual
* [testInfo.status](https://playwright.dev/docs/api/class-testinfo#test-info-status):
*
* ```ts
* import { test, expect } from '@playwright/test';
*
* test.afterEach(async ({}, testInfo) => {
* if (testInfo.status !== testInfo.expectedStatus)
* console.log(`${testInfo.title} did not run as expected!`);
* });
* ```
*
*/
expectedStatus: TestStatus;
/**
* Actual status for the currently running test. Available after the test has finished in
* [test.afterEach(hookFunction)](https://playwright.dev/docs/api/class-test#test-after-each) hook and fixtures.
*
* Status is usually compared with the
* [testInfo.expectedStatus](https://playwright.dev/docs/api/class-testinfo#test-info-expected-status):
*
* ```ts
* import { test, expect } from '@playwright/test';
*
* test.afterEach(async ({}, testInfo) => {
* if (testInfo.status !== testInfo.expectedStatus)
* console.log(`${testInfo.title} did not run as expected!`);
* });
* ```
*
*/
status?: TestStatus;
/** /**
* The list of annotations applicable to the current test. Includes annotations from the test, annotations from all * The list of annotations applicable to the current test. Includes annotations from the test, annotations from all
* [test.describe(title, callback)](https://playwright.dev/docs/api/class-test#test-describe) groups the test belongs to * [test.describe(title, callback)](https://playwright.dev/docs/api/class-test#test-describe) groups the test belongs to
@ -1511,6 +1383,26 @@ export interface TestInfo {
*/ */
errors: Array<TestError>; errors: Array<TestError>;
/**
* Expected status for the currently running test. This is usually `'passed'`, except for a few cases:
* - `'skipped'` for skipped tests, e.g. with [test.skip()](https://playwright.dev/docs/api/class-test#test-skip-2);
* - `'failed'` for tests marked as failed with [test.fail()](https://playwright.dev/docs/api/class-test#test-fail-1).
*
* Expected status is usually compared with the actual
* [testInfo.status](https://playwright.dev/docs/api/class-testinfo#test-info-status):
*
* ```ts
* import { test, expect } from '@playwright/test';
*
* test.afterEach(async ({}, testInfo) => {
* if (testInfo.status !== testInfo.expectedStatus)
* console.log(`${testInfo.title} did not run as expected!`);
* });
* ```
*
*/
expectedStatus: "passed"|"failed"|"timedOut"|"skipped";
/** /**
* Marks the currently running test as "should fail". Playwright Test runs this test and ensures that it is actually * Marks the currently running test as "should fail". Playwright Test runs this test and ensures that it is actually
* failing. This is useful for documentation purposes to acknowledge that some functionality is broken until it is fixed. * failing. This is useful for documentation purposes to acknowledge that some functionality is broken until it is fixed.
@ -1700,6 +1592,25 @@ export interface TestInfo {
*/ */
snapshotSuffix: string; snapshotSuffix: string;
/**
* Actual status for the currently running test. Available after the test has finished in
* [test.afterEach(hookFunction)](https://playwright.dev/docs/api/class-test#test-after-each) hook and fixtures.
*
* Status is usually compared with the
* [testInfo.expectedStatus](https://playwright.dev/docs/api/class-testinfo#test-info-expected-status):
*
* ```ts
* import { test, expect } from '@playwright/test';
*
* test.afterEach(async ({}, testInfo) => {
* if (testInfo.status !== testInfo.expectedStatus)
* console.log(`${testInfo.title} did not run as expected!`);
* });
* ```
*
*/
status?: "passed"|"failed"|"timedOut"|"skipped";
/** /**
* Output written to `process.stderr` or `console.error` during the test execution. * Output written to `process.stderr` or `console.error` during the test execution.
*/ */
@ -4012,4 +3923,50 @@ interface TestProject {
timeout?: number; timeout?: number;
} }
interface TestConfigWebServer {
/**
* Shell command to start. For example `npm run start`..
*/
command: string;
/**
* The port that your http server is expected to appear on. It does wait until it accepts connections. Exactly one of
* `port` or `url` is required.
*/
port?: number;
/**
* The url on your http server that is expected to return a 2xx status code when the server is ready to accept connections.
* Exactly one of `port` or `url` is required.
*/
url?: string;
/**
* Whether to ignore HTTPS errors when fetching the `url`. Defaults to `false`.
*/
ignoreHTTPSErrors?: boolean;
/**
* How long to wait for the process to start up and be available in milliseconds. Defaults to 60000.
*/
timeout?: number;
/**
* If true, it will re-use an existing server on the `port` or `url` when available. If no server is running on that `port`
* or `url`, it will run the command to start a new server. If `false`, it will throw if an existing process is listening
* on the `port` or `url`. This should be commonly set to `!process.env.CI` to allow the local dev server when running
* tests locally.
*/
reuseExistingServer?: boolean;
/**
* Current working directory of the spawned process, defaults to the directory of the configuration file.
*/
cwd?: string;
/**
* Environment variables to set for the command, `process.env` by default.
*/
env?: { [key: string]: string; };
}

View File

@ -16211,11 +16211,6 @@ export type ReporterDescription =
['null'] | ['null'] |
[string] | [string, any]; [string] | [string, any];
export type Shard = { total: number, current: number } | null;
export type ReportSlowTests = { max: number, threshold: number } | null;
export type PreserveOutput = 'always' | 'never' | 'failures-only';
export type UpdateSnapshots = 'all' | 'none' | 'missing';
type UseOptions<TestArgs, WorkerArgs> = { [K in keyof WorkerArgs]?: WorkerArgs[K] } & { [K in keyof TestArgs]?: TestArgs[K] }; type UseOptions<TestArgs, WorkerArgs> = { [K in keyof WorkerArgs]?: WorkerArgs[K] } & { [K in keyof TestArgs]?: TestArgs[K] };
/** /**
@ -16551,46 +16546,6 @@ export interface FullProject<TestArgs = {}, WorkerArgs = {}> {
use: UseOptions<PlaywrightTestOptions & TestArgs, PlaywrightWorkerOptions & WorkerArgs>; use: UseOptions<PlaywrightTestOptions & TestArgs, PlaywrightWorkerOptions & WorkerArgs>;
} }
export type WebServerConfig = {
/**
* Shell command to start. For example `npm run start`.
*/
command: string,
/**
* The port that your http server is expected to appear on. It does wait until it accepts connections.
* Exactly one of `port` or `url` is required.
*/
port?: number,
/**
* The url on your http server that is expected to return a 2xx status code when the server is ready to accept connections.
* Exactly one of `port` or `url` is required.
*/
url?: string,
/**
* Whether to ignore HTTPS errors when fetching the `url`. Defaults to `false`.
*/
ignoreHTTPSErrors?: boolean,
/**
* How long to wait for the process to start up and be available in milliseconds. Defaults to 60000.
*/
timeout?: number,
/**
* If true, it will re-use an existing server on the port or url when available. If no server is running
* on that port or url, it will run the command to start a new server.
* If false, it will throw if an existing process is listening on the port or url.
* This should commonly set to !process.env.CI to allow the local dev server when running tests locally.
*/
reuseExistingServer?: boolean
/**
* Environment variables, process.env by default
*/
env?: Record<string, string>,
/**
* Current working directory of the spawned process. Default is process.cwd().
*/
cwd?: string,
};
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 });
/** /**
@ -16638,6 +16593,54 @@ interface TestConfig {
* *
*/ */
reporter?: LiteralUnion<'list'|'dot'|'line'|'github'|'json'|'junit'|'null'|'html', string> | ReporterDescription[]; reporter?: LiteralUnion<'list'|'dot'|'line'|'github'|'json'|'junit'|'null'|'html', string> | ReporterDescription[];
/**
* Launch a development web server during the tests.
*
* If the port is specified, the server will wait for it to be available on `127.0.0.1` or `::1`, before running the tests.
* If the url is specified, the server will wait for the URL to return a 2xx status code before running the tests.
*
* For continuous integration, you may want to use the `reuseExistingServer: !process.env.CI` option which does not use an
* existing server on the CI. To see the stdout, you can set the `DEBUG=pw:webserver` environment variable.
*
* The `port` (but not the `url`) gets passed over to Playwright as a
* [testOptions.baseURL](https://playwright.dev/docs/api/class-testoptions#test-options-base-url). For example port `8080`
* produces `baseURL` equal `http://localhost:8080`.
*
* > NOTE: It is also recommended to specify
* [testOptions.baseURL](https://playwright.dev/docs/api/class-testoptions#test-options-base-url) in the config, so that
* tests could use relative urls.
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* const config: PlaywrightTestConfig = {
* webServer: {
* command: 'npm run start',
* port: 3000,
* timeout: 120 * 1000,
* reuseExistingServer: !process.env.CI,
* },
* use: {
* baseURL: 'http://localhost:3000/',
* },
* };
* export default config;
* ```
*
* Now you can use a relative path when navigating the page:
*
* ```ts
* // test.spec.ts
* import { test } from '@playwright/test';
*
* test('test', async ({ page }) => {
* // This will result in http://localhost:3000/foo
* await page.goto('/foo');
* });
* ```
*
*/
webServer?: TestConfigWebServer;
/** /**
* Configuration for the `expect` assertion library. Learn more about [various timeouts](https://playwright.dev/docs/test-timeouts). * Configuration for the `expect` assertion library. Learn more about [various timeouts](https://playwright.dev/docs/test-timeouts).
* *
@ -17115,100 +17118,6 @@ interface TestConfig {
*/ */
updateSnapshots?: "all"|"none"|"missing"; updateSnapshots?: "all"|"none"|"missing";
/**
* Launch a development web server during the tests.
*
* If the port is specified, the server will wait for it to be available on `127.0.0.1` or `::1`, before running the tests.
* If the url is specified, the server will wait for the URL to return a 2xx status code before running the tests.
*
* For continuous integration, you may want to use the `reuseExistingServer: !process.env.CI` option which does not use an
* existing server on the CI. To see the stdout, you can set the `DEBUG=pw:webserver` environment variable.
*
* The `port` (but not the `url`) gets passed over to Playwright as a
* [testOptions.baseURL](https://playwright.dev/docs/api/class-testoptions#test-options-base-url). For example port `8080`
* produces `baseURL` equal `http://localhost:8080`.
*
* > NOTE: It is also recommended to specify
* [testOptions.baseURL](https://playwright.dev/docs/api/class-testoptions#test-options-base-url) in the config, so that
* tests could use relative urls.
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* const config: PlaywrightTestConfig = {
* webServer: {
* command: 'npm run start',
* port: 3000,
* timeout: 120 * 1000,
* reuseExistingServer: !process.env.CI,
* },
* use: {
* baseURL: 'http://localhost:3000/',
* },
* };
* export default config;
* ```
*
* Now you can use a relative path when navigating the page:
*
* ```ts
* // test.spec.ts
* import { test } from '@playwright/test';
*
* test('test', async ({ page }) => {
* // This will result in http://localhost:3000/foo
* await page.goto('/foo');
* });
* ```
*
*/
webServer?: {
/**
* Shell command to start. For example `npm run start`..
*/
command: string;
/**
* The port that your http server is expected to appear on. It does wait until it accepts connections. Exactly one of
* `port` or `url` is required.
*/
port?: number;
/**
* The url on your http server that is expected to return a 2xx status code when the server is ready to accept connections.
* Exactly one of `port` or `url` is required.
*/
url?: string;
/**
* Whether to ignore HTTPS errors when fetching the `url`. Defaults to `false`.
*/
ignoreHTTPSErrors?: boolean;
/**
* How long to wait for the process to start up and be available in milliseconds. Defaults to 60000.
*/
timeout?: number;
/**
* If true, it will re-use an existing server on the `port` or `url` when available. If no server is running on that `port`
* or `url`, it will run the command to start a new server. If `false`, it will throw if an existing process is listening
* on the `port` or `url`. This should be commonly set to `!process.env.CI` to allow the local dev server when running
* tests locally.
*/
reuseExistingServer?: boolean;
/**
* Current working directory of the spawned process, defaults to the directory of the configuration file.
*/
cwd?: string;
/**
* Environment variables to set for the command, `process.env` by default.
*/
env?: { [key: string]: string; };
};
/** /**
* The maximum number of concurrent worker processes to use for parallelizing tests. * The maximum number of concurrent worker processes to use for parallelizing tests.
* *
@ -17421,7 +17330,7 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
* - `'never'` - do not preserve output for any tests; * - `'never'` - do not preserve output for any tests;
* - `'failures-only'` - only preserve output for failed tests. * - `'failures-only'` - only preserve output for failed tests.
*/ */
preserveOutput: PreserveOutput; preserveOutput: 'always' | 'never' | 'failures-only';
/** /**
* Playwright Test supports running multiple test projects at the same time. See [TestProject] for more information. * Playwright Test supports running multiple test projects at the same time. See [TestProject] for more information.
*/ */
@ -17454,7 +17363,7 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
* Test files that took more than `threshold` milliseconds are considered slow, and the slowest ones are reported, no more * Test files that took more than `threshold` milliseconds are considered slow, and the slowest ones are reported, no more
* than `max` number of them. Passing zero as `max` reports all test files that exceed the threshold. * than `max` number of them. Passing zero as `max` reports all test files that exceed the threshold.
*/ */
reportSlowTests: ReportSlowTests; reportSlowTests: { max: number, threshold: number } | null;
rootDir: string; rootDir: string;
/** /**
* Whether to suppress stdio and stderr output from the tests. * Whether to suppress stdio and stderr output from the tests.
@ -17465,7 +17374,7 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
* *
* Learn more about [parallelism and sharding](https://playwright.dev/docs/test-parallel) with Playwright Test. * Learn more about [parallelism and sharding](https://playwright.dev/docs/test-parallel) with Playwright Test.
*/ */
shard: Shard; shard: { total: number, current: number } | null;
/** /**
* Whether to update expected snapshots with the actual results produced by the test run. Defaults to `'missing'`. * Whether to update expected snapshots with the actual results produced by the test run. Defaults to `'missing'`.
* - `'all'` - All tests that are executed will update snapshots. * - `'all'` - All tests that are executed will update snapshots.
@ -17475,7 +17384,7 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
* *
* Learn more about [snapshots](https://playwright.dev/docs/test-snapshots). * Learn more about [snapshots](https://playwright.dev/docs/test-snapshots).
*/ */
updateSnapshots: UpdateSnapshots; updateSnapshots: 'all' | 'none' | 'missing';
/** /**
* The maximum number of concurrent worker processes to use for parallelizing tests. * The maximum number of concurrent worker processes to use for parallelizing tests.
* *
@ -17544,7 +17453,7 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
* ``` * ```
* *
*/ */
webServer: WebServerConfig | null; webServer: TestConfigWebServer | null;
} }
export type TestStatus = 'passed' | 'failed' | 'timedOut' | 'skipped'; export type TestStatus = 'passed' | 'failed' | 'timedOut' | 'skipped';
@ -17618,43 +17527,6 @@ export interface TestInfo {
* Processed project configuration from the [configuration file](https://playwright.dev/docs/test-configuration). * Processed project configuration from the [configuration file](https://playwright.dev/docs/test-configuration).
*/ */
project: FullProject; project: FullProject;
/**
* Expected status for the currently running test. This is usually `'passed'`, except for a few cases:
* - `'skipped'` for skipped tests, e.g. with [test.skip()](https://playwright.dev/docs/api/class-test#test-skip-2);
* - `'failed'` for tests marked as failed with [test.fail()](https://playwright.dev/docs/api/class-test#test-fail-1).
*
* Expected status is usually compared with the actual
* [testInfo.status](https://playwright.dev/docs/api/class-testinfo#test-info-status):
*
* ```ts
* import { test, expect } from '@playwright/test';
*
* test.afterEach(async ({}, testInfo) => {
* if (testInfo.status !== testInfo.expectedStatus)
* console.log(`${testInfo.title} did not run as expected!`);
* });
* ```
*
*/
expectedStatus: TestStatus;
/**
* Actual status for the currently running test. Available after the test has finished in
* [test.afterEach(hookFunction)](https://playwright.dev/docs/api/class-test#test-after-each) hook and fixtures.
*
* Status is usually compared with the
* [testInfo.expectedStatus](https://playwright.dev/docs/api/class-testinfo#test-info-expected-status):
*
* ```ts
* import { test, expect } from '@playwright/test';
*
* test.afterEach(async ({}, testInfo) => {
* if (testInfo.status !== testInfo.expectedStatus)
* console.log(`${testInfo.title} did not run as expected!`);
* });
* ```
*
*/
status?: TestStatus;
/** /**
* The list of annotations applicable to the current test. Includes annotations from the test, annotations from all * The list of annotations applicable to the current test. Includes annotations from the test, annotations from all
* [test.describe(title, callback)](https://playwright.dev/docs/api/class-test#test-describe) groups the test belongs to * [test.describe(title, callback)](https://playwright.dev/docs/api/class-test#test-describe) groups the test belongs to
@ -17778,6 +17650,26 @@ export interface TestInfo {
*/ */
errors: Array<TestError>; errors: Array<TestError>;
/**
* Expected status for the currently running test. This is usually `'passed'`, except for a few cases:
* - `'skipped'` for skipped tests, e.g. with [test.skip()](https://playwright.dev/docs/api/class-test#test-skip-2);
* - `'failed'` for tests marked as failed with [test.fail()](https://playwright.dev/docs/api/class-test#test-fail-1).
*
* Expected status is usually compared with the actual
* [testInfo.status](https://playwright.dev/docs/api/class-testinfo#test-info-status):
*
* ```ts
* import { test, expect } from '@playwright/test';
*
* test.afterEach(async ({}, testInfo) => {
* if (testInfo.status !== testInfo.expectedStatus)
* console.log(`${testInfo.title} did not run as expected!`);
* });
* ```
*
*/
expectedStatus: "passed"|"failed"|"timedOut"|"skipped";
/** /**
* Marks the currently running test as "should fail". Playwright Test runs this test and ensures that it is actually * Marks the currently running test as "should fail". Playwright Test runs this test and ensures that it is actually
* failing. This is useful for documentation purposes to acknowledge that some functionality is broken until it is fixed. * failing. This is useful for documentation purposes to acknowledge that some functionality is broken until it is fixed.
@ -17967,6 +17859,25 @@ export interface TestInfo {
*/ */
snapshotSuffix: string; snapshotSuffix: string;
/**
* Actual status for the currently running test. Available after the test has finished in
* [test.afterEach(hookFunction)](https://playwright.dev/docs/api/class-test#test-after-each) hook and fixtures.
*
* Status is usually compared with the
* [testInfo.expectedStatus](https://playwright.dev/docs/api/class-testinfo#test-info-expected-status):
*
* ```ts
* import { test, expect } from '@playwright/test';
*
* test.afterEach(async ({}, testInfo) => {
* if (testInfo.status !== testInfo.expectedStatus)
* console.log(`${testInfo.title} did not run as expected!`);
* });
* ```
*
*/
status?: "passed"|"failed"|"timedOut"|"skipped";
/** /**
* Output written to `process.stderr` or `console.error` during the test execution. * Output written to `process.stderr` or `console.error` during the test execution.
*/ */
@ -20548,6 +20459,52 @@ interface TestProject {
timeout?: number; timeout?: number;
} }
interface TestConfigWebServer {
/**
* Shell command to start. For example `npm run start`..
*/
command: string;
/**
* The port that your http server is expected to appear on. It does wait until it accepts connections. Exactly one of
* `port` or `url` is required.
*/
port?: number;
/**
* The url on your http server that is expected to return a 2xx status code when the server is ready to accept connections.
* Exactly one of `port` or `url` is required.
*/
url?: string;
/**
* Whether to ignore HTTPS errors when fetching the `url`. Defaults to `false`.
*/
ignoreHTTPSErrors?: boolean;
/**
* How long to wait for the process to start up and be available in milliseconds. Defaults to 60000.
*/
timeout?: number;
/**
* If true, it will re-use an existing server on the `port` or `url` when available. If no server is running on that `port`
* or `url`, it will run the command to start a new server. If `false`, it will throw if an existing process is listening
* on the `port` or `url`. This should be commonly set to `!process.env.CI` to allow the local dev server when running
* tests locally.
*/
reuseExistingServer?: boolean;
/**
* Current working directory of the spawned process, defaults to the directory of the configuration file.
*/
cwd?: string;
/**
* Environment variables to set for the command, `process.env` by default.
*/
env?: { [key: string]: string; };
}
} }

View File

@ -28,11 +28,6 @@ export type ReporterDescription =
['null'] | ['null'] |
[string] | [string, any]; [string] | [string, any];
export type Shard = { total: number, current: number } | null;
export type ReportSlowTests = { max: number, threshold: number } | null;
export type PreserveOutput = 'always' | 'never' | 'failures-only';
export type UpdateSnapshots = 'all' | 'none' | 'missing';
type UseOptions<TestArgs, WorkerArgs> = { [K in keyof WorkerArgs]?: WorkerArgs[K] } & { [K in keyof TestArgs]?: TestArgs[K] }; type UseOptions<TestArgs, WorkerArgs> = { [K in keyof WorkerArgs]?: WorkerArgs[K] } & { [K in keyof TestArgs]?: TestArgs[K] };
export interface Project<TestArgs = {}, WorkerArgs = {}> extends TestProject { export interface Project<TestArgs = {}, WorkerArgs = {}> extends TestProject {
@ -59,50 +54,11 @@ export interface FullProject<TestArgs = {}, WorkerArgs = {}> {
// [internal] !!! DO NOT ADD TO THIS !!! See prior note. // [internal] !!! DO NOT ADD TO THIS !!! See prior note.
} }
export type WebServerConfig = {
/**
* Shell command to start. For example `npm run start`.
*/
command: string,
/**
* The port that your http server is expected to appear on. It does wait until it accepts connections.
* Exactly one of `port` or `url` is required.
*/
port?: number,
/**
* The url on your http server that is expected to return a 2xx status code when the server is ready to accept connections.
* Exactly one of `port` or `url` is required.
*/
url?: string,
/**
* Whether to ignore HTTPS errors when fetching the `url`. Defaults to `false`.
*/
ignoreHTTPSErrors?: boolean,
/**
* How long to wait for the process to start up and be available in milliseconds. Defaults to 60000.
*/
timeout?: number,
/**
* If true, it will re-use an existing server on the port or url when available. If no server is running
* on that port or url, it will run the command to start a new server.
* If false, it will throw if an existing process is listening on the port or url.
* This should commonly set to !process.env.CI to allow the local dev server when running tests locally.
*/
reuseExistingServer?: boolean
/**
* Environment variables, process.env by default
*/
env?: Record<string, string>,
/**
* Current working directory of the spawned process. Default is process.cwd().
*/
cwd?: string,
};
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 {
reporter?: LiteralUnion<'list'|'dot'|'line'|'github'|'json'|'junit'|'null'|'html', string> | ReporterDescription[]; reporter?: LiteralUnion<'list'|'dot'|'line'|'github'|'json'|'junit'|'null'|'html', string> | ReporterDescription[];
webServer?: TestConfigWebServer;
} }
export interface Config<TestArgs = {}, WorkerArgs = {}> extends TestConfig { export interface Config<TestArgs = {}, WorkerArgs = {}> extends TestConfig {
@ -123,16 +79,16 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
grepInvert: RegExp | RegExp[] | null; grepInvert: RegExp | RegExp[] | null;
maxFailures: number; maxFailures: number;
version: string; version: string;
preserveOutput: PreserveOutput; preserveOutput: 'always' | 'never' | 'failures-only';
projects: FullProject<TestArgs, WorkerArgs>[]; projects: FullProject<TestArgs, WorkerArgs>[];
reporter: ReporterDescription[]; reporter: ReporterDescription[];
reportSlowTests: ReportSlowTests; reportSlowTests: { max: number, threshold: number } | null;
rootDir: string; rootDir: string;
quiet: boolean; quiet: boolean;
shard: Shard; shard: { total: number, current: number } | null;
updateSnapshots: UpdateSnapshots; updateSnapshots: 'all' | 'none' | 'missing';
workers: number; workers: number;
webServer: WebServerConfig | null; webServer: TestConfigWebServer | null;
// [internal] !!! DO NOT ADD TO THIS !!! See prior note. // [internal] !!! DO NOT ADD TO THIS !!! See prior note.
} }
@ -146,8 +102,6 @@ export interface WorkerInfo {
export interface TestInfo { export interface TestInfo {
config: FullConfig; config: FullConfig;
project: FullProject; project: FullProject;
expectedStatus: TestStatus;
status?: TestStatus;
} }
interface SuiteFunction { interface SuiteFunction {