···11+import { test, expect } from '@playwright/test';
22+33+// See here how to get started:
44+// https://playwright.dev/docs/intro
55+test('visits the app root url', async ({ page }) => {
66+ await page.goto('/');
77+ await expect(page.locator('h1')).toHaveText('You did it!');
88+});
···11+import process from 'node:process';
22+33+import { defineConfig, devices } from '@playwright/test';
44+55+/**
66+ * Read environment variables from file.
77+ * https://github.com/motdotla/dotenv
88+ */
99+// require('dotenv').config();
1010+1111+/**
1212+ * See https://playwright.dev/docs/test-configuration.
1313+ */
1414+export default defineConfig({
1515+ testDir: './e2e',
1616+ /* Maximum time one test can run for. */
1717+ timeout: 30 * 1000,
1818+ expect: {
1919+ /**
2020+ * Maximum time expect() should wait for the condition to be met.
2121+ * For example in `await expect(locator).toHaveText();`
2222+ */
2323+ timeout: 5000,
2424+ },
2525+ /* Fail the build on CI if you accidentally left test.only in the source code. */
2626+ forbidOnly: !!process.env.CI,
2727+ /* Retry on CI only */
2828+ retries: process.env.CI ? 2 : 0,
2929+ /* Opt out of parallel tests on CI. */
3030+ workers: process.env.CI ? 1 : undefined,
3131+ /* Reporter to use. See https://playwright.dev/docs/test-reporters */
3232+ reporter: 'html',
3333+ /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
3434+ use: {
3535+ /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
3636+ actionTimeout: 0,
3737+ /* Base URL to use in actions like `await page.goto('/')`. */
3838+ baseURL: process.env.CI ? 'http://localhost:4173' : 'http://localhost:5173',
3939+4040+ /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
4141+ trace: 'on-first-retry',
4242+4343+ /* Only on CI systems run the tests headless */
4444+ headless: !!process.env.CI,
4545+ },
4646+4747+ /* Configure projects for major browsers */
4848+ projects: [
4949+ {
5050+ name: 'chromium',
5151+ use: {
5252+ ...devices['Desktop Chrome'],
5353+ },
5454+ },
5555+ {
5656+ name: 'firefox',
5757+ use: {
5858+ ...devices['Desktop Firefox'],
5959+ },
6060+ },
6161+ {
6262+ name: 'webkit',
6363+ use: {
6464+ ...devices['Desktop Safari'],
6565+ },
6666+ },
6767+6868+ /* Test against mobile viewports. */
6969+ // {
7070+ // name: 'Mobile Chrome',
7171+ // use: {
7272+ // ...devices['Pixel 5'],
7373+ // },
7474+ // },
7575+ // {
7676+ // name: 'Mobile Safari',
7777+ // use: {
7878+ // ...devices['iPhone 12'],
7979+ // },
8080+ // },
8181+8282+ /* Test against branded browsers. */
8383+ // {
8484+ // name: 'Microsoft Edge',
8585+ // use: {
8686+ // channel: 'msedge',
8787+ // },
8888+ // },
8989+ // {
9090+ // name: 'Google Chrome',
9191+ // use: {
9292+ // channel: 'chrome',
9393+ // },
9494+ // },
9595+ ],
9696+9797+ /* Folder for test artifacts such as screenshots, videos, traces, etc. */
9898+ // outputDir: 'test-results/',
9999+100100+ /* Run your local dev server before starting the tests */
101101+ webServer: {
102102+ /**
103103+ * Use the dev server by default for faster feedback loop.
104104+ * Use the preview server on CI for more realistic testing.
105105+ * Playwright will re-use the local server if there is already a dev-server running.
106106+ */
107107+ command: process.env.CI ? 'npm run preview' : 'npm run dev',
108108+ port: process.env.CI ? 4173 : 5173,
109109+ reuseExistingServer: !process.env.CI,
110110+ },
111111+});