2023-06-25 14:57:42 +08:00
|
|
|
import { devices } from '@playwright/test';
|
2023-12-22 13:27:13 +08:00
|
|
|
import { testConfig } from './server.configs.js';
|
2023-12-12 05:00:33 +08:00
|
|
|
|
2023-12-22 13:27:13 +08:00
|
|
|
const { hostname, port } = testConfig;
|
2023-12-12 05:00:33 +08:00
|
|
|
const TEST_HOST = `http://${hostname}:${port}`;
|
|
|
|
|
|
|
|
process.env.TEST_HOST = TEST_HOST;
|
2022-01-31 11:40:21 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @see https://playwright.dev/docs/test-configuration
|
|
|
|
* @type {import('@playwright/test').PlaywrightTestConfig}
|
|
|
|
*/
|
|
|
|
const config = {
|
|
|
|
// Setup / Teardown
|
|
|
|
globalSetup: './test/config/playwright.setup.js',
|
|
|
|
globalTeardown: './test/config/playwright.teardown.js',
|
|
|
|
|
|
|
|
// Test Execution
|
|
|
|
expect: {
|
|
|
|
timeout: 5000,
|
|
|
|
},
|
|
|
|
retries: process.env.CI ? 2 : 0, // Retry on CI only
|
|
|
|
testDir: './test/e2e',
|
|
|
|
timeout: 30 * 1000,
|
|
|
|
workers: process.env.CI ? 1 : undefined, // No parallel tests on CI
|
|
|
|
forbidOnly: !!process.env.CI, // Fail on CI if test.only in source
|
|
|
|
|
|
|
|
// Output
|
|
|
|
outputDir: './_playwright-results/', // screenshots, videos, traces, etc.
|
|
|
|
reporter: [
|
|
|
|
[
|
|
|
|
'html',
|
|
|
|
{
|
|
|
|
open: 'never',
|
|
|
|
outputFolder: '_playwright-report',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
],
|
|
|
|
snapshotDir: './test/e2e/__snapshots__',
|
|
|
|
|
|
|
|
// Config - Shared
|
|
|
|
// See https://playwright.dev/docs/api/class-testoptions
|
|
|
|
use: {
|
|
|
|
actionTimeout: 0,
|
2023-12-12 05:00:33 +08:00
|
|
|
baseURL: TEST_HOST, // Allow relative page.goto() (e.g. `await page.goto('/')`).
|
2022-01-31 11:40:21 +08:00
|
|
|
trace: 'on-first-retry',
|
|
|
|
},
|
|
|
|
|
|
|
|
// Projects
|
|
|
|
projects: [
|
|
|
|
{
|
|
|
|
name: 'chromium',
|
|
|
|
use: { ...devices['Desktop Chrome'] },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'firefox',
|
|
|
|
use: { ...devices['Desktop Firefox'] },
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'webkit',
|
|
|
|
use: { ...devices['Desktop Safari'] },
|
|
|
|
},
|
|
|
|
// {
|
|
|
|
// name: 'Mobile Safari',
|
|
|
|
// use: { ...devices['iPhone 12'] }
|
|
|
|
// },
|
|
|
|
],
|
|
|
|
};
|
|
|
|
|
2023-06-25 14:57:42 +08:00
|
|
|
export default config;
|