← full-stack-fastapi-template  /  frontend/playwright.config.ts

1
import { defineConfig, devices } from '@playwright/test';
2
import 'dotenv/config'
3
4
/**
5
 * Read environment variables from file.
6
 * https://github.com/motdotla/dotenv
7
 */
8
9
/**
10
 * See https://playwright.dev/docs/test-configuration.
11
 */
12
export default defineConfig({
13
  testDir: './tests',
14
  /* Run tests in files in parallel */
15
  fullyParallel: true,
16
  /* Fail the build on CI if you accidentally left test.only in the source code. */
17
  forbidOnly: !!process.env.CI,
18
  /* Retry on CI only */
19
  retries: process.env.CI ? 2 : 0,
20
  /* Opt out of parallel tests on CI. */
21
  workers: process.env.CI ? 1 : undefined,
22
  /* Reporter to use. See https://playwright.dev/docs/test-reporters */
23
  reporter: process.env.CI ? 'blob' : 'html',
24
  /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
25
  use: {
26
    /* Base URL to use in actions like `await page.goto('/')`. */
27
    baseURL: 'http://localhost:5173',
28
29
    /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
30
    trace: 'on-first-retry',
31
  },
32
33
  /* Configure projects for major browsers */
34
  projects: [
35
    { name: 'setup', testMatch: /.*\.setup\.ts/ },
36
37
    {
38
      name: 'chromium',
39
      use: {
40
        ...devices['Desktop Chrome'],
41
        storageState: 'playwright/.auth/user.json',
42
      },
43
      dependencies: ['setup'],
44
    },
45
46
    // {
47
    //   name: 'firefox',
48
    //   use: {
49
    //     ...devices['Desktop Firefox'],
50
    //     storageState: 'playwright/.auth/user.json',
51
    //   },
52
    //   dependencies: ['setup'],
53
    // },
54
55
    // {
56
    //   name: 'webkit',
57
    //   use: {
58
    //     ...devices['Desktop Safari'],
59
    //     storageState: 'playwright/.auth/user.json',
60
    //   },
61
    //   dependencies: ['setup'],
62
    // },
63
64
    /* Test against mobile viewports. */
65
    // {
66
    //   name: 'Mobile Chrome',
67
    //   use: { ...devices['Pixel 5'] },
68
    // },
69
    // {
70
    //   name: 'Mobile Safari',
71
    //   use: { ...devices['iPhone 12'] },
72
    // },
73
74
    /* Test against branded browsers. */
75
    // {
76
    //   name: 'Microsoft Edge',
77
    //   use: { ...devices['Desktop Edge'], channel: 'msedge' },
78
    // },
79
    // {
80
    //   name: 'Google Chrome',
81
    //   use: { ...devices['Desktop Chrome'], channel: 'chrome' },
82
    // },
83
  ],
84
85
  /* Run your local dev server before starting the tests */
86
  webServer: {
87
    command: 'bun run dev',
88
    url: 'http://localhost:5173',
89
    reuseExistingServer: !process.env.CI,
90
  },
91
});
92