Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs: improve the emulation viewport doc (#27434)

Pavel Feldmanb2a07c26750f
diff --git a/docs/src/emulation.md b/docs/src/emulation.md
index 2bd95d9d20..a673659661 100644
--- a/docs/src/emulation.md
+++ b/docs/src/emulation.md
@@ -101,10 +101,17 @@ The viewport is included in the device but you can override it for some tests wi
```js tab=js-test title="playwright.config.ts"
import { defineConfig } from '@playwright/test';
export default defineConfig({
- use: {
- // Viewport used for all pages in the context.
- viewport: { width: 1280, height: 720 },
- },
+ projects: [
+ {
+ name: 'chromium',
+ use: {
+ ...devices['Desktop Chrome'],
+ // It is important to define the `viewport` property after destructuring `devices`,
+ // since devices also define the `viewport` for that device.
+ viewport: { width: 1280, height: 720 },
+ },
+ },
+ ]
});
```
@@ -239,9 +246,17 @@ Whether the meta viewport tag is taken into account and touch events are enabled
import { defineConfig } from '@playwright/test';
export default defineConfig({
- use: {
- isMobile: false,
- },
+ projects: [
+ {
+ name: 'chromium',
+ use: {
+ ...devices['Desktop Chrome'],
+ // It is important to define the `isMobile` property after destructuring `devices`,
+ // since devices also define the `isMobile` for that device.
+ isMobile: false,
+ },
+ },
+ ]
});
```