42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { defineConfig, devices } from '@playwright/test';
|
|
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
|
|
function cachedChromium() {
|
|
if (process.env.PLAYWRIGHT_EXECUTABLE_PATH) return process.env.PLAYWRIGHT_EXECUTABLE_PATH;
|
|
const cache =
|
|
process.env.PLAYWRIGHT_BROWSERS_PATH || path.join(process.env.HOME || '', 'Library/Caches/ms-playwright');
|
|
if (!fs.existsSync(cache)) return undefined;
|
|
const candidates = fs
|
|
.readdirSync(cache)
|
|
.filter((name) => name.startsWith('chromium_headless_shell-'))
|
|
.sort()
|
|
.reverse()
|
|
.map((name) => path.join(cache, name, 'chrome-headless-shell-mac-x64', 'chrome-headless-shell'));
|
|
return candidates.find((candidate) => fs.existsSync(candidate));
|
|
}
|
|
|
|
export default defineConfig({
|
|
testDir: './test/e2e',
|
|
fullyParallel: false,
|
|
forbidOnly: Boolean(process.env.CI),
|
|
reporter: process.env.CI ? 'line' : 'list',
|
|
use: {
|
|
baseURL: 'http://127.0.0.1:8899',
|
|
trace: 'retain-on-failure',
|
|
screenshot: 'only-on-failure',
|
|
},
|
|
webServer: {
|
|
command: 'node test/e2e-server.js',
|
|
url: 'http://127.0.0.1:8899/',
|
|
reuseExistingServer: !process.env.CI,
|
|
timeout: 30_000,
|
|
},
|
|
projects: [
|
|
{
|
|
name: 'chromium',
|
|
use: { ...devices['Desktop Chrome'], launchOptions: { executablePath: cachedChromium() } },
|
|
},
|
|
],
|
|
});
|