From 7a8eb1582090f8f11c01f4067404815a17899201 Mon Sep 17 00:00:00 2001 From: Debbie O'Brien Date: Wed, 10 May 2023 18:38:12 +0200 Subject: [PATCH] docs: add titles to config snippets (#22910) Docs PR: https://github.com/microsoft/playwright.dev/pull/1039 --------- Co-authored-by: Max Schmitt --- docs/src/api-testing-js.md | 3 +- docs/src/api/params.md | 6 +- docs/src/auth.md | 3 +- docs/src/best-practices-js.md | 3 +- docs/src/emulation.md | 4 +- docs/src/locators.md | 3 +- docs/src/network.md | 6 +- docs/src/release-notes-js.md | 24 ++--- docs/src/test-api/class-test.md | 6 +- docs/src/test-api/class-testconfig.md | 96 +++++++------------- docs/src/test-api/class-testoptions.md | 65 +++++++------ docs/src/test-api/class-testproject.md | 15 +-- docs/src/test-configuration-js.md | 12 +-- docs/src/test-fixtures-js.md | 6 +- docs/src/test-global-setup-teardown-js.md | 9 +- docs/src/test-parallel-js.md | 11 +-- docs/src/test-parameterize-js.md | 12 +-- docs/src/test-projects-js.md | 7 +- docs/src/test-reporter-api/class-reporter.md | 3 +- docs/src/test-reporters-js.md | 28 +++--- docs/src/test-retries-js.md | 2 +- docs/src/test-snapshots-js.md | 2 +- docs/src/test-timeouts-js.md | 12 +-- docs/src/test-use-options-js.md | 16 ++-- docs/src/test-webserver-js.md | 8 +- docs/src/trace-viewer-intro-js.md | 2 +- docs/src/trace-viewer.md | 2 +- docs/src/videos.md | 4 +- packages/playwright-test/types/test.d.ts | 32 +++++++ utils/markdown.js | 5 +- 30 files changed, 185 insertions(+), 222 deletions(-) diff --git a/docs/src/api-testing-js.md b/docs/src/api-testing-js.md index e9df14fc7b..3d83a37835 100644 --- a/docs/src/api-testing-js.md +++ b/docs/src/api-testing-js.md @@ -29,8 +29,7 @@ The following example demonstrates how to use Playwright to test issues creation GitHub API requires authorization, so we'll configure the token once for all tests. While at it, we'll also set the `baseURL` to simplify the tests. You can either put them in the configuration file, or in the test file with `test.use()`. -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ use: { diff --git a/docs/src/api/params.md b/docs/src/api/params.md index 55b60af35c..d228f12226 100644 --- a/docs/src/api/params.md +++ b/docs/src/api/params.md @@ -1642,8 +1642,7 @@ This option configures a template controlling location of snapshots generated by **Usage** -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -1704,8 +1703,7 @@ Each token can be preceded with a single character that will be used **only if** Consider the following config: -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ diff --git a/docs/src/auth.md b/docs/src/auth.md index 8484e2e58e..11c37583ac 100644 --- a/docs/src/auth.md +++ b/docs/src/auth.md @@ -71,8 +71,7 @@ setup('authenticate', async ({ page }) => { Create a new `setup` project in the config and declare it as a dependency for all your testing projects. This project will always run and authenticate before all the tests. All testing projects should use the authenticated state as `storageState`. -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig, devices } from '@playwright/test'; export default defineConfig({ diff --git a/docs/src/best-practices-js.md b/docs/src/best-practices-js.md index 21ec5d7666..4296675627 100644 --- a/docs/src/best-practices-js.md +++ b/docs/src/best-practices-js.md @@ -226,8 +226,7 @@ Playwright comes with a range of tooling to help you write tests. Playwright makes it easy to test your site across all [browsers](./test-configuration#multiple-browsers) no matter what platform you are on. Testing across all browsers ensures your app works for all users. In your config file you can set up projects adding the name and which browser or device to use. -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig, devices } from '@playwright/test'; export default defineConfig({ diff --git a/docs/src/emulation.md b/docs/src/emulation.md index b4c729746b..afa2f5ef0c 100644 --- a/docs/src/emulation.md +++ b/docs/src/emulation.md @@ -541,7 +541,7 @@ await context.SetGeolocationAsync(new Geolocation() { Longitude = 48.858455, Lat Emulate the users `"colorScheme"`. Supported values are 'light', 'dark', 'no-preference'. You can also emulate the media type with [`method: Page.emulateMedia`]. -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -705,7 +705,7 @@ var context = await browser.NewContextAsync(new() { UserAgent = "My User Agent" Emulate the network being offline. -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ diff --git a/docs/src/locators.md b/docs/src/locators.md index 35e7612508..8cd8a31fe1 100644 --- a/docs/src/locators.md +++ b/docs/src/locators.md @@ -553,8 +553,7 @@ By default, [`method: Page.getByTestId`] will locate elements based on the `data Set the test id to use a custom data attribute for your tests. -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ diff --git a/docs/src/network.md b/docs/src/network.md index 6da91a78bf..aa32b56201 100644 --- a/docs/src/network.md +++ b/docs/src/network.md @@ -45,7 +45,7 @@ test('loads page without images', async ({ page }) => { Perform HTTP Authentication. -```js tab=js-test +```js tab=js-test title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ use: { @@ -113,7 +113,7 @@ bypass proxy for. Here is an example of a global proxy: -```js tab=js-test +```js tab=js-test title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ use: { @@ -174,7 +174,7 @@ await using var browser = await BrowserType.LaunchAsync(new() When specifying proxy for each context individually, **Chromium on Windows** needs a hint that proxy will be set. This is done via passing a non-empty proxy server to the browser itself. Here is an example of a context-specific proxy: -```js tab=js-test +```js tab=js-test title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ use: { diff --git a/docs/src/release-notes-js.md b/docs/src/release-notes-js.md index 010a736ee7..027d28168a 100644 --- a/docs/src/release-notes-js.md +++ b/docs/src/release-notes-js.md @@ -116,8 +116,7 @@ This version was also tested against the following stable channels: Using dependencies allows global setup to produce traces and other artifacts, see the setup steps in the test report and more. - ```js - // playwright.config.ts + ```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -283,8 +282,7 @@ This version was also tested against the following stable channels: Read more in [our documentation](./test-assertions.md#retrying). - Automatically capture **full page screenshot** on test failure: - ```js - // playwright.config.ts + ```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ use: { @@ -349,8 +347,7 @@ This version was also tested against the following stable channels: * Use [`property: TestProject.snapshotPathTemplate`] and [`property: TestConfig.snapshotPathTemplate`] to configure a template controlling location of snapshots generated by [`method: PageAssertions.toHaveScreenshot#1`] and [`method: SnapshotAssertions.toMatchSnapshot#1`]. - ```js - // playwright.config.ts + ```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ testDir: './tests', @@ -557,8 +554,7 @@ This version was also tested against the following stable channels: Launch multiple web servers, databases, or other processes by passing an array of configurations: -```ts -// playwright.config.ts +```ts title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ webServer: [ @@ -754,8 +750,7 @@ Read more about [component testing with Playwright](./test-components). ### Miscellaneous * If there's a service worker that's in your way, you can now easily disable it with a new context option `serviceWorkers`: - ```ts - // playwright.config.ts + ```ts title="playwright.config.ts" export default { use: { serviceWorkers: 'block', @@ -949,8 +944,7 @@ This version was also tested against the following stable channels: - Playwright Test now adds [`property: TestConfig.fullyParallel`] mode. By default, Playwright Test parallelizes between files. In fully parallel mode, tests inside a single file are also run in parallel. You can also use `--fully-parallel` command line flag. - ```ts - // playwright.config.ts + ```ts title="playwright.config.ts" export default { fullyParallel: true, }; @@ -958,8 +952,7 @@ This version was also tested against the following stable channels: - [`property: TestProject.grep`] and [`property: TestProject.grepInvert`] are now configurable per project. For example, you can now configure smoke tests project using `grep`: - ```ts - // playwright.config.ts + ```ts title="playwright.config.ts" export default { projects: [ { @@ -1581,8 +1574,7 @@ Step information is exposed in reporters API. To launch a server during the tests, use the [`webServer`](./test-webserver) option in the configuration file. The server will wait for a given url to be available before running the tests, and the url will be passed over to Playwright as a [`baseURL`](./api/class-fixtures#fixtures-base-url) when creating a context. -```ts -// playwright.config.ts +```ts title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ webServer: { diff --git a/docs/src/test-api/class-test.md b/docs/src/test-api/class-test.md index 46fadc360b..2db5ecf957 100644 --- a/docs/src/test-api/class-test.md +++ b/docs/src/test-api/class-test.md @@ -612,8 +612,7 @@ test('test 1', async ({ todoPage }) => { Configure the option in config file. -```js tab=js-js -// playwright.config.js +```js tab=js-js title="playwright.config.ts" // @ts-check module.exports = defineConfig({ @@ -630,8 +629,7 @@ module.exports = defineConfig({ }); ``` -```js tab=js-ts -// playwright.config.ts +```js tab=js-ts title="playwright.config.ts" import { defineConfig } from '@playwright/test'; import { Options } from './my-test'; diff --git a/docs/src/test-api/class-testconfig.md b/docs/src/test-api/class-testconfig.md index e4ac5de1a4..14fc4f9411 100644 --- a/docs/src/test-api/class-testconfig.md +++ b/docs/src/test-api/class-testconfig.md @@ -6,8 +6,7 @@ Playwright Test provides many options to configure how your tests are collected Playwright Test supports running multiple test projects at the same time. Project-specific options should be put to [`property: TestConfig.projects`], but top-level [TestConfig] can also define base options shared between all projects. -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -38,8 +37,7 @@ Configuration for the `expect` assertion library. Learn more about [various time **Usage** -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -60,8 +58,7 @@ Whether to exit with an error if any tests or groups are marked as [`method: Tes **Usage** -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -80,8 +77,7 @@ You can configure entire test run to concurrently execute all tests in all files **Usage** -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -99,8 +95,7 @@ Learn more about [global setup and teardown](../test-global-setup-teardown.md). **Usage** -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -118,8 +113,7 @@ Learn more about [global setup and teardown](../test-global-setup-teardown.md). **Usage** -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -135,8 +129,7 @@ Maximum time in milliseconds the whole test suite can run. Zero timeout (default **Usage** -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -154,8 +147,7 @@ Filter to only run tests with a title matching one of the patterns. For example, **Usage** -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -173,8 +165,7 @@ Filter to only run tests with a title **not** matching one of the patterns. This **Usage** -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -190,8 +181,7 @@ Whether to skip snapshot expectations, such as `expect(value).toMatchSnapshot()` **Usage** -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -209,8 +199,7 @@ Also available in the [command line](../test-cli.md) with the `--max-failures` a **Usage** -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -226,8 +215,7 @@ Metadata that will be put directly to the test report serialized as JSON. **Usage** -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -243,8 +231,7 @@ Config name is visible in the report and during test execution, unless overridde **Usage** -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -260,8 +247,7 @@ The output directory for files created during test execution. Defaults to ` { Multiple web servers (or background processes) can be launched: -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ webServer: [ @@ -685,8 +654,7 @@ Defaults to half of the number of logical CPU cores. Learn more about [paralleli **Usage** -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ diff --git a/docs/src/test-api/class-testoptions.md b/docs/src/test-api/class-testoptions.md index 586b60f292..e2a511e6bb 100644 --- a/docs/src/test-api/class-testoptions.md +++ b/docs/src/test-api/class-testoptions.md @@ -6,7 +6,7 @@ Playwright Test provides many options to configure test environment, [Browser], These options are usually provided in the [configuration file](../test-configuration.md) through [`property: TestConfig.use`] and [`property: TestProject.use`]. -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ use: { @@ -37,7 +37,7 @@ test('my portrait test', async ({ page }) => { **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -71,8 +71,7 @@ Name of the browser that runs tests. Defaults to `'chromium'`. Most of the time **Usage** -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig, devices } from '@playwright/test'; export default defineConfig({ @@ -110,7 +109,7 @@ Learn more about [various timeouts](../test-timeouts.md). **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -125,7 +124,7 @@ export default defineConfig({ **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -145,7 +144,7 @@ export default defineConfig({ **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -165,7 +164,7 @@ export default defineConfig({ **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -187,7 +186,7 @@ Options used to create the context, as passed to [`method: Browser.newContext`]. **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -204,7 +203,7 @@ export default defineConfig({ **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -220,7 +219,7 @@ export default defineConfig({ **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -237,7 +236,7 @@ export default defineConfig({ **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -253,7 +252,7 @@ Learn more about [geolocation](../emulation.md#color-scheme-and-media). **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -268,7 +267,7 @@ export default defineConfig({ **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -283,7 +282,7 @@ export default defineConfig({ **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -301,7 +300,7 @@ export default defineConfig({ **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -316,7 +315,7 @@ export default defineConfig({ **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -331,7 +330,7 @@ export default defineConfig({ **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -350,7 +349,7 @@ Options used to launch the browser, as passed to [`method: BrowserType.launch`]. **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -371,7 +370,7 @@ export default defineConfig({ **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -391,7 +390,7 @@ This is a default navigation timeout, same as configured via [`method: Page.setD **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -408,7 +407,7 @@ Learn more about [various timeouts](../test-timeouts.md). **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -423,7 +422,7 @@ export default defineConfig({ **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -438,7 +437,7 @@ export default defineConfig({ **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -465,7 +464,7 @@ Whether to automatically capture a screenshot after each test. Defaults to `'off **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -482,7 +481,7 @@ Learn more about [automatic screenshots](../test-configuration.md#automatic-scre **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -499,7 +498,7 @@ Custom attribute to be used in [`method: Page.getByTestId`]. `data-testid` is us **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -514,7 +513,7 @@ export default defineConfig({ **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -543,7 +542,7 @@ For more control, pass an object that specifies `mode` and trace features to ena **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -560,7 +559,7 @@ Learn more about [recording trace](../test-configuration.md#record-test-trace). **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -588,7 +587,7 @@ To control video size, pass an object with `mode` and `size` properties. If vide **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -605,7 +604,7 @@ Learn more about [recording video](../test-configuration.md#record-video). **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -620,7 +619,7 @@ export default defineConfig({ **Usage** -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ diff --git a/docs/src/test-api/class-testproject.md b/docs/src/test-api/class-testproject.md index 3748e32411..7e9d2b0139 100644 --- a/docs/src/test-api/class-testproject.md +++ b/docs/src/test-api/class-testproject.md @@ -8,8 +8,7 @@ Playwright Test supports running multiple test projects at the same time. This i Here is an example configuration that runs every test in Chromium, Firefox and WebKit, both Desktop and Mobile versions. -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig, devices } from '@playwright/test'; export default defineConfig({ @@ -59,8 +58,7 @@ see the setup steps in the test report, etc. **Usage** -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -210,8 +208,7 @@ Passing `--no-deps` argument ignores [`property: TestProject.teardown`] and beha A common pattern is a "setup" dependency that has a corresponding "teardown": -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -252,8 +249,7 @@ Directory that will be recursively scanned for test files. Defaults to the direc Each project can use a different directory. Here is an example that runs smoke tests in three browsers and all other tests in stable Chrome browser. -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -329,8 +325,7 @@ Use [`property: TestConfig.timeout`] to change this option for all projects. Options for all tests in this project, for example [`property: TestOptions.browserName`]. Learn more about [configuration](../test-configuration.md) and see [available options][TestOptions]. -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ diff --git a/docs/src/test-configuration-js.md b/docs/src/test-configuration-js.md index 7e13d65f96..69f737af46 100644 --- a/docs/src/test-configuration-js.md +++ b/docs/src/test-configuration-js.md @@ -70,7 +70,7 @@ export default defineConfig({ Filter tests by glob patterns or regular expressions. -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -89,7 +89,7 @@ export default defineConfig({ ## Advanced Configuration -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -119,7 +119,7 @@ export default defineConfig({ Configuration for the expect assertion library. -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -154,8 +154,7 @@ You can extend Playwright assertions by providing custom matchers. These matcher In this example we add a custom `toBeWithinRange` function in the configuration file. Custom matcher should return a `message` callback and a `pass` flag indicating whether the assertion passed. -```js tab=js-js -// playwright.config.js +```js tab=js-js title="playwright.config.ts" const { expect, defineConfig } = require('@playwright/test'); expect.extend({ @@ -178,8 +177,7 @@ expect.extend({ module.exports = defineConfig({}); ``` -```js tab=js-ts -// playwright.config.ts +```js tab=js-ts title="playwright.config.ts" import { expect, defineConfig } from '@playwright/test'; expect.extend({ diff --git a/docs/src/test-fixtures-js.md b/docs/src/test-fixtures-js.md index 85c8a3fe4e..613bd80eae 100644 --- a/docs/src/test-fixtures-js.md +++ b/docs/src/test-fixtures-js.md @@ -905,8 +905,7 @@ export { expect } from '@playwright/test'; We can now use `todoPage` fixture as usual, and set the `defaultItem` option in the config file. -```js tab=js-js -// playwright.config.js +```js tab=js-js title="playwright.config.ts" // @ts-check const { defineConfig } = require('@playwright/test'); @@ -924,8 +923,7 @@ module.exports = defineConfig({ }); ``` -```js tab=js-ts -// playwright.config.ts +```js tab=js-ts title="playwright.config.ts" import { defineConfig } from '@playwright/test'; import { MyOptions } from './my-test'; diff --git a/docs/src/test-global-setup-teardown-js.md b/docs/src/test-global-setup-teardown-js.md index f66a97f9b9..3233991866 100644 --- a/docs/src/test-global-setup-teardown-js.md +++ b/docs/src/test-global-setup-teardown-js.md @@ -11,8 +11,7 @@ There are two ways to configure global setup and teardown: using a global setup In this example the chromium, firefox and webkit projects depend on the setup project. -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -46,8 +45,7 @@ You can use the `globalSetup` option in the [configuration file](#configuration- Similarly, use `globalTeardown` to run something once after all the tests. Alternatively, let `globalSetup` return a function that will be used as a global teardown. You can pass data such as port number, authentication tokens, etc. from your global setup to your tests using environment variables. -```js -// playwright.config.ts/js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -83,8 +81,7 @@ export default globalSetup; Specify `globalSetup`, `baseURL` and `storageState` in the configuration file. -```js -// playwright.config.ts/js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ globalSetup: require.resolve('./global-setup'), diff --git a/docs/src/test-parallel-js.md b/docs/src/test-parallel-js.md index 3ad691bcd8..8f63883330 100644 --- a/docs/src/test-parallel-js.md +++ b/docs/src/test-parallel-js.md @@ -30,7 +30,7 @@ npx playwright test --workers 4 In the configuration file: -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -64,7 +64,7 @@ test('runs in parallel 2', async ({ page }) => { /* ... */ }); Alternatively, you can opt-in all tests into this fully-parallel mode in the configuration file: -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -74,7 +74,7 @@ export default defineConfig({ You can also opt in for fully-parallel mode for just a few projects: -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -148,7 +148,7 @@ npx playwright test --max-failures=10 Setting in the configuration file: -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -218,8 +218,7 @@ test.describe(featureATests); Now **disable parallel execution** by setting workers to one, and specify your test list file. -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ diff --git a/docs/src/test-parameterize-js.md b/docs/src/test-parameterize-js.md index 75b781c45d..a8ac67dfe5 100644 --- a/docs/src/test-parameterize-js.md +++ b/docs/src/test-parameterize-js.md @@ -65,8 +65,7 @@ test('test 1', async ({ page, person }) => { Now, we can run tests in multiple configurations by using projects. -```js tab=js-js -// playwright.config.js +```js tab=js-js title="playwright.config.ts" // @ts-check module.exports = defineConfig({ @@ -83,8 +82,7 @@ module.exports = defineConfig({ }); ``` -```js tab=js-ts -// playwright.config.ts +```js tab=js-ts title="playwright.config.ts" import { defineConfig } from '@playwright/test'; import type { TestOptions } from './my-test'; @@ -189,8 +187,7 @@ npx playwright test Similarly, configuration file can also read environment variables passed through the command line. -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -220,8 +217,7 @@ npx playwright test To make environment variables easier to manage, consider something like `.env` files. Here is an example that uses [`dotenv`](https://www.npmjs.com/package/dotenv) package to read environment variables directly in the configuration file. -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; import dotenv from 'dotenv'; import path from 'path'; diff --git a/docs/src/test-projects-js.md b/docs/src/test-projects-js.md index c0b96e4353..c1c5a2b124 100644 --- a/docs/src/test-projects-js.md +++ b/docs/src/test-projects-js.md @@ -101,7 +101,7 @@ Choose a specific profile, various profiles or all profiles to run tests on. By setting up projects we can also run a group of tests with different timeouts or retries or run a group of tests against different environments. For example we can run our tests against a staging environment with 2 retries as well as against a production environment with 0 retries. -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -131,7 +131,7 @@ We can split tests into projects and use filters to run a subset of tests. For e Here is an example that defines a common timeout and two projects. The "Smoke" project runs a small subset of tests without retries, and "Default" project runs all other tests with retries. -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -156,8 +156,7 @@ Dependencies are a list of projects that need to run before the tests in another In this example the chromium, firefox and webkit projects depend on the setup project. -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ diff --git a/docs/src/test-reporter-api/class-reporter.md b/docs/src/test-reporter-api/class-reporter.md index 72203157d1..964b9f98aa 100644 --- a/docs/src/test-reporter-api/class-reporter.md +++ b/docs/src/test-reporter-api/class-reporter.md @@ -66,8 +66,7 @@ export default MyReporter; Now use this reporter with [`property: TestConfig.reporter`]. Learn more about [using reporters](../test-reporters.md). -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ diff --git a/docs/src/test-reporters-js.md b/docs/src/test-reporters-js.md index 25c3239c5d..3449482f31 100644 --- a/docs/src/test-reporters-js.md +++ b/docs/src/test-reporters-js.md @@ -12,7 +12,7 @@ npx playwright test --reporter=line For more control, you can specify reporters programmatically in the [configuration file](./test-configuration.md). -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -24,7 +24,7 @@ export default defineConfig({ You can use multiple reporters at the same time. For example you can use `'list'` for nice terminal output and `'json'` to get a comprehensive json file with the test results. -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -39,7 +39,7 @@ export default defineConfig({ You can use different reporters locally and on CI. For example, using concise `'dot'` reporter avoids too much output. This is the default on CI. -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -60,7 +60,7 @@ List reporter is default (except on CI where the `dot` reporter is default). It npx playwright test --reporter=list ``` -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -87,7 +87,7 @@ Running 124 tests using 6 workers You can opt into the step rendering via passing the following config option: -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -103,7 +103,7 @@ Line reporter is more concise than the list reporter. It uses a single line to r npx playwright test --reporter=line ``` -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -133,7 +133,7 @@ Dot reporter is very concise - it only produces a single character per successfu npx playwright test --reporter=dot ``` -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -162,7 +162,7 @@ By default, HTML report is opened automatically if some of the tests failed. You You can also configure `host` and `port` that are used to serve the HTML report. -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -175,7 +175,7 @@ that location using the `PLAYWRIGHT_HTML_REPORT` environment variable or a repor In configuration file, pass options directly: -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -185,7 +185,7 @@ export default defineConfig({ If you are uploading attachments from data folder to other location, you can use `attachmentsBaseURL` option to let html report where to look for them. -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -230,7 +230,7 @@ npx playwright test --reporter=json In configuration file, pass options directly: -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -260,7 +260,7 @@ npx playwright test --reporter=junit In configuration file, pass options directly: -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -274,7 +274,7 @@ You can use the built in `github` reporter to get automatic failure annotations Note that all other reporters work on GitHub Actions as well, but do not provide annotations. -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -315,7 +315,7 @@ export default MyReporter; Now use this reporter with [`property: TestConfig.reporter`]. -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ diff --git a/docs/src/test-retries-js.md b/docs/src/test-retries-js.md index bc6571d05c..e020d13e0e 100644 --- a/docs/src/test-retries-js.md +++ b/docs/src/test-retries-js.md @@ -61,7 +61,7 @@ npx playwright test --retries=3 You can configure retries in the configuration file: -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ diff --git a/docs/src/test-snapshots-js.md b/docs/src/test-snapshots-js.md index 414dbb91ff..683b95f54a 100644 --- a/docs/src/test-snapshots-js.md +++ b/docs/src/test-snapshots-js.md @@ -71,7 +71,7 @@ test('example test', async ({ page }) => { If you'd like to share the default value among all the tests in the project, you can specify it in the playwright config, either globally or per project: -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ expect: { diff --git a/docs/src/test-timeouts-js.md b/docs/src/test-timeouts-js.md index fae0d014fb..4e8682c071 100644 --- a/docs/src/test-timeouts-js.md +++ b/docs/src/test-timeouts-js.md @@ -31,8 +31,7 @@ The same timeout value also applies to `beforeAll` and `afterAll` hooks, but the ### Set test timeout in the config -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -106,8 +105,7 @@ Call log: ### Set expect timeout in the config -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -146,8 +144,7 @@ Playwright also allows to set a separate timeout for navigation actions like `pa ### Set action and navigation timeouts in the config -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -185,8 +182,7 @@ Running 1000 tests using 10 workers You can set global timeout in the config. -```js -// playwright.config.ts +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ diff --git a/docs/src/test-use-options-js.md b/docs/src/test-use-options-js.md index 7e43aa58f4..0b6912c2c5 100644 --- a/docs/src/test-use-options-js.md +++ b/docs/src/test-use-options-js.md @@ -9,7 +9,7 @@ In addition to configuring the test runner you can also configure [Emulation](#e Set the base URL and storage state for all tests: -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -34,7 +34,7 @@ export default defineConfig({ With Playwright you can emulate a real device such as a mobile phone or tablet. See our [guide on projects](./test-projects.md) for more info on emulating devices. You can also emulate the `"geolocation"`, `"locale"` and `"timezone"` for all tests or for a specific test as well as set the `"permissions"` to show notifications or change the `"colorScheme"`. See our [Emulation](./emulation.md) guide to learn more. -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -73,7 +73,7 @@ export default defineConfig({ Available options to configure networking: -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -127,7 +127,7 @@ With Playwright you can capture screenshots, record videos as well as traces of Trace files, screenshots and videos will appear in the test output directory, typically `test-results`. -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -153,7 +153,7 @@ export default defineConfig({ ### Other Options -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -192,7 +192,7 @@ export default defineConfig({ Any options accepted by [`method: BrowserType.launch`] or [`method: Browser.newContext`] can be put into `launchOptions` or `contextOptions` respectively in the `use` section. -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -210,7 +210,7 @@ However, most common ones like `headless` or `viewport` are available directly i If using the built-in `browser` fixture, calling [`method: Browser.newContext`] will create a context with options inherited from the config: -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -242,7 +242,7 @@ test('should inherit use options on context when using built-in browser fixture' You can configure Playwright globally, per project, or per test. For example, you can set the locale to be used globally by adding `locale` to the `use` option of the Playwright config, and then override it for a specific project using the `project` option in the config. You can also override it for a specific test by adding `test.use({})` in the test file and passing in the options. -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ diff --git a/docs/src/test-webserver-js.md b/docs/src/test-webserver-js.md index 779e7d6b31..5a19a4c14d 100644 --- a/docs/src/test-webserver-js.md +++ b/docs/src/test-webserver-js.md @@ -9,7 +9,7 @@ Playwright comes with a `webserver` option in the config file which gives you th Use the `webserver` property in your Playwright config to launch a development web server during the tests. -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -34,7 +34,7 @@ export default defineConfig({ Webservers can sometimes take longer to boot up. In this case, you can increase the timeout to wait for the server to start. -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -56,7 +56,7 @@ It is also recommended to specify the `baseURL` in the `use: {}` section of your When using [`method: Page.goto`], [`method: Page.route`], [`method: Page.waitForURL`], [`method: Page.waitForRequest`], or [`method: Page.waitForResponse`] it takes the base URL in consideration by using the [`URL()`](https://developer.mozilla.org/en-US/docs/Web/API/URL/URL) constructor for building the corresponding URL. For Example, by setting the baseURL to `http://127.0.0.1:3000` and navigating to `/login` in your tests, Playwright will run the test using `http://127.0.0.1:3000/login`. -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ @@ -91,7 +91,7 @@ test('test', async ({ page }) => { Multiple web servers (or background processes) can be launched simultaneously by providing an array of `webServer` configurations. See [`property: TestConfig.webServer`] for more info. -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ diff --git a/docs/src/trace-viewer-intro-js.md b/docs/src/trace-viewer-intro-js.md index 52b1083490..85be58602d 100644 --- a/docs/src/trace-viewer-intro-js.md +++ b/docs/src/trace-viewer-intro-js.md @@ -21,7 +21,7 @@ Playwright Trace Viewer is a GUI tool that lets you explore recorded Playwright By default the [playwright.config](/test-configuration.md#record-test-trace) file will contain the configuration needed to create a `trace.zip` file for each test. Traces are setup to run `on-first-retry` meaning they will be run on the first retry of a failed test. Also `retries` are set to 2 when running on CI and 0 locally. This means the traces will be recorded on the first retry of a failed test but not on the first run and not on the second retry. -```js +```js title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ retries: process.env.CI ? 2 : 0, // set to 2 when running on CI diff --git a/docs/src/trace-viewer.md b/docs/src/trace-viewer.md index 079f336f69..eda0759027 100644 --- a/docs/src/trace-viewer.md +++ b/docs/src/trace-viewer.md @@ -142,7 +142,7 @@ npx playwright show-report Traces should be run on continuous integration on the first retry of a failed test by setting the `trace: 'on-first-retry'` option in the test configuration file. This will produce a `trace.zip` file for each test that was retried. -```js tab=js-test +```js tab=js-test title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ retries: 1, diff --git a/docs/src/videos.md b/docs/src/videos.md index 03798a9679..5a386f07d7 100644 --- a/docs/src/videos.md +++ b/docs/src/videos.md @@ -19,7 +19,7 @@ Video files will appear in the test output directory, typically `test-results`. Videos are saved upon [browser context](./browser-contexts.md) closure at the end of a test. If you create a browser context manually, make sure to await [`method: BrowserContext.close`]. -```js tab=js-test +```js tab=js-test title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ use: { @@ -36,7 +36,7 @@ await context.close(); You can also specify video size. The video size defaults to the viewport size scaled down to fit 800x800. The video of the viewport is placed in the top-left corner of the output video, scaled down to fit if necessary. You may need to set the viewport size to match your desired video size. -```js tab=js-test +```js tab=js-test title="playwright.config.ts" import { defineConfig } from '@playwright/test'; export default defineConfig({ use: { diff --git a/packages/playwright-test/types/test.d.ts b/packages/playwright-test/types/test.d.ts index c4b39ced79..b6c5cfd5df 100644 --- a/packages/playwright-test/types/test.d.ts +++ b/packages/playwright-test/types/test.d.ts @@ -3360,6 +3360,7 @@ type ConnectOptions = { * [testProject.use](https://playwright.dev/docs/api/class-testproject#test-project-use). * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * export default defineConfig({ * use: { @@ -3412,6 +3413,7 @@ export interface PlaywrightWorkerOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3431,6 +3433,7 @@ export interface PlaywrightWorkerOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3461,6 +3464,7 @@ export interface PlaywrightWorkerOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3482,6 +3486,7 @@ export interface PlaywrightWorkerOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3511,6 +3516,7 @@ export interface PlaywrightWorkerOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3536,6 +3542,7 @@ export interface PlaywrightWorkerOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3563,6 +3570,7 @@ export interface PlaywrightWorkerOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3589,6 +3597,7 @@ export type VideoMode = 'off' | 'on' | 'retain-on-failure' | 'on-first-retry'; * [testProject.use](https://playwright.dev/docs/api/class-testproject#test-project-use). * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * export default defineConfig({ * use: { @@ -3621,6 +3630,7 @@ export interface PlaywrightTestOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3637,6 +3647,7 @@ export interface PlaywrightTestOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3653,6 +3664,7 @@ export interface PlaywrightTestOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3671,6 +3683,7 @@ export interface PlaywrightTestOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3689,6 +3702,7 @@ export interface PlaywrightTestOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3707,6 +3721,7 @@ export interface PlaywrightTestOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3723,6 +3738,7 @@ export interface PlaywrightTestOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3740,6 +3756,7 @@ export interface PlaywrightTestOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3760,6 +3777,7 @@ export interface PlaywrightTestOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3776,6 +3794,7 @@ export interface PlaywrightTestOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3794,6 +3813,7 @@ export interface PlaywrightTestOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3811,6 +3831,7 @@ export interface PlaywrightTestOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3829,6 +3850,7 @@ export interface PlaywrightTestOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3846,6 +3868,7 @@ export interface PlaywrightTestOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3864,6 +3887,7 @@ export interface PlaywrightTestOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3883,6 +3907,7 @@ export interface PlaywrightTestOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3904,6 +3929,7 @@ export interface PlaywrightTestOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3922,6 +3948,7 @@ export interface PlaywrightTestOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3938,6 +3965,7 @@ export interface PlaywrightTestOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -3993,6 +4021,7 @@ export interface PlaywrightTestOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -4037,6 +4066,7 @@ export interface PlaywrightTestOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -4053,6 +4083,7 @@ export interface PlaywrightTestOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ @@ -4076,6 +4107,7 @@ export interface PlaywrightTestOptions { * **Usage** * * ```js + * // playwright.config.ts * import { defineConfig } from '@playwright/test'; * * export default defineConfig({ diff --git a/utils/markdown.js b/utils/markdown.js index 9adaf6248d..77e7343426 100644 --- a/utils/markdown.js +++ b/utils/markdown.js @@ -67,6 +67,7 @@ * maxColumns?: number, * omitLastCR?: boolean, * flattenText?: boolean + * renderCodeBlockTitlesInHeader?: boolean * }} RenderOptions */ @@ -327,7 +328,9 @@ function innerRenderMdNode(indent, node, lastNode, result, options) { if (node.type === 'code') { newLine(); - result.push(`${indent}\`\`\`${node.codeLang}${node.title ? ' title="' + node.title + '"' : ''}`); + result.push(`${indent}\`\`\`${node.codeLang}${(options?.renderCodeBlockTitlesInHeader && node.title) ? ' title="' + node.title + '"' : ''}`); + if (!options?.renderCodeBlockTitlesInHeader && node.title) + result.push(`${indent}// ${node.title}`); for (const line of node.lines) result.push(indent + line); result.push(`${indent}\`\`\``);