# Playwright

[Playwright](https://playwright.dev/) enables reliable end-to-end testing for modern web apps. Here's more information on [Getting Started](https://playwright.dev/docs/intro) with Playwright.

Your project requires simple modifications to your playwright config file. <br>

**Parallel**

Testery will handle the level of parallelism for the test files, so for best result set this option to **false**. If you would like to keep this **true** for local runs and **false** for Testery, you can add an environment variable check for `IS_TESTERY` and set to `false` when present.

```
fullyParallel: false
```

```
fullyParallel: process.env.IS_TESTERY ? false : true
```

**Retries**

Testery also will handle any retries, so it's best to leave them at 0 when running on the cloud.

```
retries: 0
```

**Viewport**

Add the **viewport** option in your `use` array for each project under the `projects` array and set to `1920x1080`. This will allow better sized video and screenshots to be displayed in Testery.

```json
  use: {
    ...devices['Desktop Chrome'],
    channel: 'chrome',
    viewport: { width: 1920, height: 1080 },
  }
```

#### Screenshots

If you want your captured screenshots to display in Testery, you'll need adjust the `outputDir` option to a predefined path: `./screenshots`

```
outputDir: './screenshots'
```

Also make sure your `use` block to contains right value for screenshots to be taken. For example:

```
screenshot: 'only-on-failure'
```

For better screenshot names, it's recommended to use a fixture instead.

```typescript
  screenshots: [async ({ page }, use, testInfo) => {
    await use()
    await page.screenshot({ path: `./screenshots/${testInfo.title}.png` })
  }, { auto: true }],
```

**Suggested Testery config example**

```typescript
export default defineConfig({
  testDir,
  outputDir: './screenshots',
  fullyParallel: false, // Testery will handle the parallelism
  retries: 0, // Testery will handle the retries
  workers: 4, // Leave this to local running preference. Testery will run one at a time per worker (File/Feature)
  reporter: [['list']], // Leave this to local running preference. Testery will change this to json report when running on cloud
  use: {
    trace: 'retain-on-failure',
    screenshot: 'only-on-failure'
  },
  timeout: 60_000, // Make sure this is less than test timeout in Testery to get more detailed timeout error in the log

  projects: [ // recommend using the playwright project field in test runs to separate different project to different runs
    {
      name: 'chromium',
      use: { ...devices['Desktop Chrome'], 
      viewport: { width: 1920, height: 1080 } }
    }
  ]
})
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.testery.io/framework-specific-guidance/playwright.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
