2023-04-09 23:59:57 +08:00
|
|
|
import { defineConfig, devices } from '@playwright/test';
|
|
|
|
|
2023-06-30 02:27:35 +08:00
|
|
|
const isCI = !!process.env.CI;
|
|
|
|
const baseUrl = process.env.BASE_URL || 'http://localhost:5050';
|
2023-09-03 22:28:19 +08:00
|
|
|
const useWebServer = process.env.NO_WEB_SERVER !== 'true';
|
2023-04-09 23:59:57 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* See https://playwright.dev/docs/test-configuration.
|
|
|
|
*/
|
|
|
|
export default defineConfig({
|
|
|
|
testDir: './src',
|
2024-04-15 15:43:12 +08:00
|
|
|
testMatch: /\.e2e\.(spec\.)?ts$/,
|
2023-04-09 23:59:57 +08:00
|
|
|
/* Run tests in files in parallel */
|
|
|
|
fullyParallel: true,
|
|
|
|
/* Fail the build on CI if you accidentally left test.only in the source code. */
|
2023-06-30 02:27:35 +08:00
|
|
|
forbidOnly: isCI,
|
2023-04-09 23:59:57 +08:00
|
|
|
/* Retry on CI only */
|
2023-06-30 02:27:35 +08:00
|
|
|
retries: isCI ? 2 : 0,
|
2023-04-09 23:59:57 +08:00
|
|
|
/* Opt out of parallel tests on CI. */
|
2023-06-30 02:27:35 +08:00
|
|
|
workers: isCI ? 1 : undefined,
|
2023-04-09 23:59:57 +08:00
|
|
|
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
|
|
|
|
reporter: 'html',
|
|
|
|
/* 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('/')`. */
|
2023-06-30 02:27:35 +08:00
|
|
|
baseURL: baseUrl,
|
2023-04-09 23:59:57 +08:00
|
|
|
|
|
|
|
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
|
|
|
|
trace: 'on-first-retry',
|
|
|
|
|
|
|
|
testIdAttribute: 'data-test-id',
|
2023-04-13 05:01:21 +08:00
|
|
|
locale: 'en-GB',
|
|
|
|
timezoneId: 'Europe/Paris',
|
2023-04-09 23:59:57 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
/* Configure projects for major browsers */
|
|
|
|
projects: [
|
|
|
|
{
|
|
|
|
name: 'chromium',
|
|
|
|
use: { ...devices['Desktop Chrome'] },
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
name: 'firefox',
|
|
|
|
use: { ...devices['Desktop Firefox'] },
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
name: 'webkit',
|
|
|
|
use: { ...devices['Desktop Safari'] },
|
|
|
|
},
|
|
|
|
],
|
|
|
|
|
|
|
|
/* Run your local dev server before starting the tests */
|
2023-06-30 02:27:35 +08:00
|
|
|
|
2023-09-03 22:28:19 +08:00
|
|
|
...(useWebServer
|
|
|
|
&& {
|
|
|
|
webServer: {
|
|
|
|
command: 'npm run preview',
|
2024-04-15 15:43:12 +08:00
|
|
|
url: 'http://localhost:5050',
|
2023-09-03 22:28:19 +08:00
|
|
|
reuseExistingServer: !isCI,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
),
|
2023-04-09 23:59:57 +08:00
|
|
|
});
|