Skip to content

Init configuration #2

Description

@maikschneider

The command ddev playwright-init should add an example configuration + useful helpers.

E.g.

import { defineConfig, devices } from "@playwright/test";

const baseURL = process.env.PLAYWRIGHT_BASE_URL || `https://${process.env.VIRTUAL_HOST.split(',')[0]}`;
console.log(`Testing against: ${baseURL}`);

export default defineConfig({
  testDir: "Tests/Playwright/",
  timeout: 30 * 1000,
  forbidOnly: !!process.env.CI,
  fullyParallel: true,
  retries: process.env.CI ? 1 : 0,
  workers: process.env.CI ? 1 : undefined,
  reporter: process.env.CI
    ? [["list"], ["html", { open: "never" }], ["junit", { outputFile: "test-results/junit.xml" }]]
    : [["list"], ["html", { open: "never", outputFolder: "Tests/Playwright/playwright-report" }]],
  use: {
    baseURL,
    trace: "on-first-retry",
    screenshot: "only-on-failure",
    ignoreHTTPSErrors: true
  },

  expect: {
    toHaveScreenshot: {
      animations: "disabled",
      fullPage: true,
      maxDiffPixels: 100,
      maxDiffPixelRatio: 0.01,
      threshold: 0.2
    }
  },

  projects: [
    {
      name: "chromium",
      use: { ...devices["Desktop Chrome"] }
    }
  ]
});

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions