vue3-realworld-example-app/playwright.config.ts

78 lines
2.1 KiB
TypeScript

import { defineConfig, devices } from '@playwright/test'
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// dotenv.config({ path: path.resolve(__dirname, '.env') });
const isCI = process.env.CI
const baseURL = process.env.E2E_BASE_URL || 'http://localhost:4173'
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './playwright',
/* Run tests in files in parallel */
fullyParallel: false,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!isCI,
/* Retry on CI only */
retries: isCI ? 1 : 0,
/* Opt out of parallel tests on CI. */
workers: isCI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: [
['html', { open: 'never' }],
isCI ? ['github'] : ['list'],
],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL,
navigationTimeout: isCI ? 10_000 : 4000,
actionTimeout: isCI ? 10_000 : 4000,
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
screenshot: 'only-on-failure',
trace: isCI ? 'on-first-retry' : 'retain-on-failure',
video: isCI ? 'on-first-retry' : 'retain-on-failure',
},
/* Configure projects for major browsers */
projects: isCI
? [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
]
: [
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
},
},
],
/* Run your local dev server before starting the tests */
webServer: {
command: isCI ? 'pnpm serve' : 'npm run dev',
url: baseURL,
reuseExistingServer: !isCI,
ignoreHTTPSErrors: true,
},
})