Browse Source

docs: make ts snippets esm-friendly (#14451)

pull/9535/merge
Pavel Feldman 4 weeks ago committed by GitHub
parent
commit
f724fa570f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      docs/src/browsers.md
  2. 2
      docs/src/intro-js.md
  3. 2
      docs/src/release-notes-js.md
  4. 10
      docs/src/test-advanced-js.md
  5. 2
      docs/src/test-api-testing-js.md
  6. 2
      docs/src/test-api/class-test.md
  7. 34
      docs/src/test-api/class-testconfig.md
  8. 4
      docs/src/test-api/class-testoptions.md
  9. 6
      docs/src/test-api/class-testproject.md
  10. 2
      docs/src/test-auth-js.md
  11. 20
      docs/src/test-configuration-js.md
  12. 2
      docs/src/test-fixtures-js.md
  13. 8
      docs/src/test-parallel-js.md
  14. 6
      docs/src/test-parameterize-js.md
  15. 2
      docs/src/test-reporter-api/class-reporter.md
  16. 24
      docs/src/test-reporters-js.md
  17. 2
      docs/src/test-retries-js.md
  18. 2
      docs/src/test-snapshots-js.md
  19. 8
      docs/src/test-timeouts-js.md
  20. 2
      docs/src/trace-viewer.md
  21. 2
      examples/github-api/playwright.config.ts
  22. 2
      examples/svgomg/playwright.config.ts
  23. 2
      examples/todomvc/playwright.config.ts
  24. 76
      packages/playwright-test/types/test.d.ts
  25. 2
      packages/playwright-test/types/testReporter.d.ts
  26. 78
      tests/config/experimental.d.ts

2
docs/src/browsers.md

@ -48,7 +48,7 @@ module.exports = config;
```
```js js-flavor=ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
use: {
channel: 'chrome',

2
docs/src/intro-js.md

@ -138,7 +138,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig, devices } from '@playwright/test';
import { type PlaywrightTestConfig, devices } from '@playwright/test';
const config: PlaywrightTestConfig = {
forbidOnly: !!process.env.CI,

2
docs/src/release-notes-js.md

@ -752,7 +752,7 @@ To launch a server during the tests, use the [`webServer`](./test-advanced#launc
```ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
webServer: {
command: 'npm run start', // command to launch

10
docs/src/test-advanced-js.md

@ -15,7 +15,7 @@ Here is an example that defines a common timeout and two projects. The "Smoke" p
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
timeout: 60000, // Timeout is shared between all tests.
projects: [
@ -152,7 +152,7 @@ It is also recommended to specify [`property: TestOptions.baseURL`] in the confi
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
webServer: {
command: 'npm run start',
@ -269,7 +269,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
globalSetup: require.resolve('./global-setup'),
@ -392,7 +392,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig, devices } from '@playwright/test';
import { type PlaywrightTestConfig, devices } from '@playwright/test';
const config: PlaywrightTestConfig = {
projects: [
@ -430,7 +430,7 @@ Here is an example that runs projects with different tests and configurations. T
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
timeout: 60000, // Timeout is shared between all tests.
projects: [

2
docs/src/test-api-testing-js.md

@ -31,7 +31,7 @@ GitHub API requires authorization, so we'll configure the token once for all tes
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
use: {

2
docs/src/test-api/class-test.md

@ -601,7 +601,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
import { Options } from './my-test';
const config: PlaywrightTestConfig<Options> = {

34
docs/src/test-api/class-testconfig.md

@ -22,7 +22,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
timeout: 30000,
@ -69,7 +69,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
expect: {
@ -101,7 +101,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
forbidOnly: !!process.env.CI,
@ -138,7 +138,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig, devices } from '@playwright/test';
import { type PlaywrightTestConfig, devices } from '@playwright/test';
const config: PlaywrightTestConfig = {
globalSetup: './global-setup',
@ -167,7 +167,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig, devices } from '@playwright/test';
import { type PlaywrightTestConfig, devices } from '@playwright/test';
const config: PlaywrightTestConfig = {
globalTeardown: './global-teardown',
@ -194,7 +194,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
globalTimeout: process.env.CI ? 60 * 60 * 1000 : undefined,
@ -239,7 +239,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
maxFailures: process.env.CI ? 1 : 0,
@ -276,7 +276,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig, devices } from '@playwright/test';
import { type PlaywrightTestConfig, devices } from '@playwright/test';
const config: PlaywrightTestConfig = {
outputDir: './test-results',
@ -371,7 +371,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
reporter: 'line',
@ -407,7 +407,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
retries: 2,
@ -479,7 +479,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
testDir: './tests/playwright',
@ -508,7 +508,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig, devices } from '@playwright/test';
import { type PlaywrightTestConfig, devices } from '@playwright/test';
const config: PlaywrightTestConfig = {
testIgnore: '**/test-assets/**',
@ -537,7 +537,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig, devices } from '@playwright/test';
import { type PlaywrightTestConfig, devices } from '@playwright/test';
const config: PlaywrightTestConfig = {
testMatch: /.*\.e2e\.js/,
@ -566,7 +566,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
timeout: 5 * 60 * 1000,
@ -605,7 +605,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
use: {
@ -640,7 +640,7 @@ It is also recommended to specify [`property: TestOptions.baseURL`] in the confi
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
webServer: {
command: 'npm run start',
@ -718,7 +718,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
workers: 3,

4
docs/src/test-api/class-testoptions.md

@ -22,7 +22,7 @@ module.exports = config;
```
```js js-flavor=ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
use: {
headless: false,
@ -85,7 +85,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig, devices } from '@playwright/test';
import { type PlaywrightTestConfig, devices } from '@playwright/test';
const config: PlaywrightTestConfig = {
use: {

6
docs/src/test-api/class-testproject.md

@ -59,7 +59,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig, devices } from '@playwright/test';
import { type PlaywrightTestConfig, devices } from '@playwright/test';
const config: PlaywrightTestConfig = {
// Options shared for all projects.
@ -298,7 +298,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
projects: [
@ -391,7 +391,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
projects: [

2
docs/src/test-auth-js.md

@ -109,7 +109,7 @@ Register global setup script in the Playwright configuration file:
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
globalSetup: require.resolve('./global-setup'),

20
docs/src/test-configuration-js.md

@ -34,7 +34,7 @@ module.exports = config;
```
```js js-flavor=ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
use: {
headless: false,
@ -145,7 +145,7 @@ module.exports = config;
```
```js js-flavor=ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
use: {
baseURL: 'http://localhost:3000',
@ -188,7 +188,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig, devices } from '@playwright/test';
import { type PlaywrightTestConfig, devices } from '@playwright/test';
const config: PlaywrightTestConfig = {
projects: [
@ -272,7 +272,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig, devices } from '@playwright/test';
import { type PlaywrightTestConfig, devices } from '@playwright/test';
const config: PlaywrightTestConfig = {
projects: [
@ -327,7 +327,7 @@ module.exports = config;
```
```js js-flavor=ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
use: {
locale: 'fr-FR',
@ -435,7 +435,7 @@ module.exports = config;
```
```js js-flavor=ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
use: {
screenshot: 'only-on-failure',
@ -469,7 +469,7 @@ module.exports = config;
```
```js js-flavor=ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
use: {
video: 'on-first-retry',
@ -503,7 +503,7 @@ module.exports = config;
```
```js js-flavor=ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
use: {
trace: 'retain-on-failure',
@ -532,7 +532,7 @@ module.exports = config;
```
```js js-flavor=ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
use: {
launchOptions: {
@ -593,7 +593,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
// Look for test files in the "tests" directory, relative to this configuration file

2
docs/src/test-fixtures-js.md

@ -592,7 +592,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
import { MyOptions } from './my-test';
const config: PlaywrightTestConfig<MyOptions> = {

8
docs/src/test-parallel-js.md

@ -47,7 +47,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
// Limit the number of workers on CI, use default locally
@ -104,7 +104,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
fullyParallel: true,
@ -214,7 +214,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
// Limit the number of failures on CI to save resources
@ -318,7 +318,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
workers: 1,

6
docs/src/test-parameterize-js.md

@ -112,7 +112,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
import { TestOptions } from './my-test';
const config: PlaywrightTestConfig<TestOptions> = {
@ -243,7 +243,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
use: {
@ -295,7 +295,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
import dotenv from 'dotenv';
import path from 'path';

2
docs/src/test-reporter-api/class-reporter.md

@ -71,7 +71,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
reporter: './my-awesome-reporter.ts',

24
docs/src/test-reporters-js.md

@ -30,7 +30,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
reporter: 'line',
@ -59,7 +59,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
reporter: [
@ -89,7 +89,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
// Concise 'dot' for CI, default 'list' when running locally
@ -124,7 +124,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
reporter: 'list',
@ -171,7 +171,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
reporter: 'line',
@ -215,7 +215,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
reporter: 'dot',
@ -256,7 +256,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
reporter: [ ['html', { open: 'never' }] ],
@ -282,7 +282,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
reporter: [ ['html', { outputFolder: 'my-report' }] ],
@ -338,7 +338,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
reporter: [ ['json', { outputFile: 'results.json' }] ],
@ -381,7 +381,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
reporter: [ ['junit', { outputFile: 'results.xml' }] ],
@ -411,7 +411,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
// 'github' for GitHub Actions CI to generate annotations, plus a concise 'dot'
@ -491,7 +491,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
reporter: './my-awesome-reporter.ts',

2
docs/src/test-retries-js.md

@ -85,7 +85,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
// Give failing tests 3 retry attempts

2
docs/src/test-snapshots-js.md

@ -103,7 +103,7 @@ module.exports = {
```
```js js-flavor=ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
expect: {
toHaveScreenshot: { maxDiffPixels: 100 },

8
docs/src/test-timeouts-js.md

@ -48,7 +48,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
timeout: 5 * 60 * 1000,
@ -146,7 +146,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
expect: {
@ -210,7 +210,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
use: {
@ -271,7 +271,7 @@ module.exports = config;
```js js-flavor=ts
// playwright.config.ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
globalTimeout: 60 * 60 * 1000,

2
docs/src/trace-viewer.md

@ -29,7 +29,7 @@ module.exports = config;
```
```js js-flavor=ts
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
retries: 1,
use: {

2
examples/github-api/playwright.config.ts

@ -1,6 +1,6 @@
/* eslint-disable notice/notice */
import { PlaywrightTestConfig } from '@playwright/test';
import type { PlaywrightTestConfig } from '@playwright/test';
/**
* See https://playwright.dev/docs/test-configuration.

2
examples/svgomg/playwright.config.ts

@ -1,6 +1,6 @@
/* eslint-disable notice/notice */
import { PlaywrightTestConfig, devices } from '@playwright/test';
import { type PlaywrightTestConfig, devices } from '@playwright/test';
/**
* See https://playwright.dev/docs/test-configuration.

2
examples/todomvc/playwright.config.ts

@ -1,6 +1,6 @@
/* eslint-disable notice/notice */
import { PlaywrightTestConfig, devices } from '@playwright/test';
import { type PlaywrightTestConfig, devices } from '@playwright/test';
/**
* See https://playwright.dev/docs/test-configuration.

76
packages/playwright-test/types/test.d.ts vendored

@ -44,7 +44,7 @@ type UseOptions<TestArgs, WorkerArgs> = { [K in keyof WorkerArgs]?: WorkerArgs[K
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig, devices } from '@playwright/test';
* import { type PlaywrightTestConfig, devices } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* // Options shared for all projects.
@ -98,7 +98,7 @@ export interface Project<TestArgs = {}, WorkerArgs = {}> extends TestProject {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* projects: [
@ -132,7 +132,7 @@ export interface Project<TestArgs = {}, WorkerArgs = {}> extends TestProject {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig, devices } from '@playwright/test';
* import { type PlaywrightTestConfig, devices } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* // Options shared for all projects.
@ -264,7 +264,7 @@ export interface FullProject<TestArgs = {}, WorkerArgs = {}> {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* projects: [
@ -343,7 +343,7 @@ export interface FullProject<TestArgs = {}, WorkerArgs = {}> {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* projects: [
@ -376,7 +376,7 @@ type LiteralUnion<T extends U, U = string> = T | (U & { zz_IGNORE_ME?: never });
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* timeout: 30000,
@ -401,7 +401,7 @@ interface TestConfig {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* reporter: 'line',
@ -430,7 +430,7 @@ interface TestConfig {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
* const config: PlaywrightTestConfig = {
* webServer: {
* command: 'npm run start',
@ -464,7 +464,7 @@ interface TestConfig {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* expect: {
@ -556,7 +556,7 @@ interface TestConfig {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* forbidOnly: !!process.env.CI,
@ -584,7 +584,7 @@ interface TestConfig {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig, devices } from '@playwright/test';
* import { type PlaywrightTestConfig, devices } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* globalSetup: './global-setup',
@ -603,7 +603,7 @@ interface TestConfig {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig, devices } from '@playwright/test';
* import { type PlaywrightTestConfig, devices } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* globalTeardown: './global-teardown',
@ -621,7 +621,7 @@ interface TestConfig {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* globalTimeout: process.env.CI ? 60 * 60 * 1000 : undefined,
@ -657,7 +657,7 @@ interface TestConfig {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* maxFailures: process.env.CI ? 1 : 0,
@ -684,7 +684,7 @@ interface TestConfig {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig, devices } from '@playwright/test';
* import { type PlaywrightTestConfig, devices } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* outputDir: './test-results',
@ -777,7 +777,7 @@ interface TestConfig {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* retries: 2,
@ -810,7 +810,7 @@ interface TestConfig {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* testDir: './tests/playwright',
@ -829,7 +829,7 @@ interface TestConfig {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig, devices } from '@playwright/test';
* import { type PlaywrightTestConfig, devices } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* testIgnore: '**\/test-assets/**',
@ -848,7 +848,7 @@ interface TestConfig {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig, devices } from '@playwright/test';
* import { type PlaywrightTestConfig, devices } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* testMatch: /.*\.e2e\.js/,
@ -868,7 +868,7 @@ interface TestConfig {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* timeout: 5 * 60 * 1000,
@ -901,7 +901,7 @@ interface TestConfig {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* workers: 3,
@ -922,7 +922,7 @@ interface TestConfig {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* timeout: 30000,
@ -946,7 +946,7 @@ export interface Config<TestArgs = {}, WorkerArgs = {}> extends TestConfig {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* use: {
@ -972,7 +972,7 @@ export type Metadata = { [key: string]: any };
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* timeout: 30000,
@ -992,7 +992,7 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* forbidOnly: !!process.env.CI,
@ -1018,7 +1018,7 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig, devices } from '@playwright/test';
* import { type PlaywrightTestConfig, devices } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* globalSetup: './global-setup',
@ -1036,7 +1036,7 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig, devices } from '@playwright/test';
* import { type PlaywrightTestConfig, devices } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* globalTeardown: './global-teardown',
@ -1053,7 +1053,7 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* globalTimeout: process.env.CI ? 60 * 60 * 1000 : undefined,
@ -1086,7 +1086,7 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* maxFailures: process.env.CI ? 1 : 0,
@ -1125,7 +1125,7 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* reporter: 'line',
@ -1174,7 +1174,7 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* workers: 3,
@ -1203,7 +1203,7 @@ export interface FullConfig<TestArgs = {}, WorkerArgs = {}> {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
* const config: PlaywrightTestConfig = {
* webServer: {
* command: 'npm run start',
@ -2414,7 +2414,7 @@ export interface TestType<TestArgs extends KeyValue, WorkerArgs extends KeyValue
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
* import { Options } from './my-test';
*
* const config: PlaywrightTestConfig<Options> = {
@ -2489,7 +2489,7 @@ type ConnectOptions = {
* [testProject.use](https://playwright.dev/docs/api/class-testproject#test-project-use).
*
* ```ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
* const config: PlaywrightTestConfig = {
* use: {
* headless: false,
@ -2524,7 +2524,7 @@ export interface PlaywrightWorkerOptions {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig, devices } from '@playwright/test';
* import { type PlaywrightTestConfig, devices } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* use: {
@ -2616,7 +2616,7 @@ export type VideoMode = 'off' | 'on' | 'retain-on-failure' | 'on-first-retry';
* [testProject.use](https://playwright.dev/docs/api/class-testproject#test-project-use).
*
* ```ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
* const config: PlaywrightTestConfig = {
* use: {
* headless: false,
@ -3937,7 +3937,7 @@ export interface TestError {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig, devices } from '@playwright/test';
* import { type PlaywrightTestConfig, devices } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* // Options shared for all projects.
@ -4163,7 +4163,7 @@ interface TestProject {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* projects: [

2
packages/playwright-test/types/testReporter.d.ts vendored

@ -323,7 +323,7 @@ export interface FullResult {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* reporter: './my-awesome-reporter.ts',

78
tests/config/experimental.d.ts vendored

@ -16226,7 +16226,7 @@ type UseOptions<TestArgs, WorkerArgs> = { [K in keyof WorkerArgs]?: WorkerArgs[K
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig, devices } from '@playwright/test';
* import { type PlaywrightTestConfig, devices } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* // Options shared for all projects.
@ -16280,7 +16280,7 @@ export interface Project<TestArgs = {}, WorkerArgs = {}> extends TestProject {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* projects: [
@ -16314,7 +16314,7 @@ export interface Project<TestArgs = {}, WorkerArgs = {}> extends TestProject {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig, devices } from '@playwright/test';
* import { type PlaywrightTestConfig, devices } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* // Options shared for all projects.
@ -16446,7 +16446,7 @@ export interface FullProject<TestArgs = {}, WorkerArgs = {}> {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* projects: [
@ -16525,7 +16525,7 @@ export interface FullProject<TestArgs = {}, WorkerArgs = {}> {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* projects: [
@ -16558,7 +16558,7 @@ type LiteralUnion<T extends U, U = string> = T | (U & { zz_IGNORE_ME?: never });
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* timeout: 30000,
@ -16583,7 +16583,7 @@ interface TestConfig {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* reporter: 'line',
@ -16612,7 +16612,7 @@ interface TestConfig {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
* const config: PlaywrightTestConfig = {
* webServer: {
* command: 'npm run start',
@ -16646,7 +16646,7 @@ interface TestConfig {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* expect: {
@ -16738,7 +16738,7 @@ interface TestConfig {
*
* ```ts
* // playwright.config.ts
* import { PlaywrightTestConfig } from '@playwright/test';
* import type { PlaywrightTestConfig } from '@playwright/test';
*
* const config: PlaywrightTestConfig = {
* forbidOnly: !!process.env.CI,
@ -16766,7 +16766,7 @@ interface TestConfig {
*