Files
Oxicloud/tests/e2e/playwright.config.ts
T

71 lines
1.9 KiB
TypeScript
Raw Normal View History

import { defineConfig, devices } from '@playwright/test';
2026-05-11 00:50:39 +02:00
import * as fs from 'fs';
import * as path from 'path';
/** Parse a KEY=VALUE env file, skipping blank lines and comments. */
function loadEnv(filePath: string): Record<string, string> {
const env: Record<string, string> = {};
for (const line of fs.readFileSync(filePath, 'utf-8').split('\n')) {
const trimmed = line.trim();
if (!trimmed || trimmed.startsWith('#')) continue;
const idx = trimmed.indexOf('=');
if (idx === -1) continue;
env[trimmed.slice(0, idx)] = trimmed.slice(idx + 1);
}
return env;
}
const commonEnv = loadEnv(path.join(__dirname, '../common/server.env'));
console.log(`starting playwright with env BUILD_TARGET=${process.env.BUILD_TARGET ?? "debug"}`);
const workspace=process.env.GITHUB_WORKSPACE ?? path.join(__dirname, '../..');
export default defineConfig({
testDir: './scenarios',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: process.env.CI ? [['github'], ['html']] : 'html',
globalSetup: require.resolve('./global-setup'),
use: {
baseURL: 'http://localhost:8087',
trace: 'on-first-retry',
},
expect: {
toHaveScreenshot: { maxDiffPixelRatio: 0.02 },
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
],
webServer: {
command: process.env.BUILD_TARGET
? `${workspace}/target/${process.env.BUILD_TARGET}/oxicloud`
: 'cargo run',
url: 'http://localhost:8087',
timeout: 600_000,
reuseExistingServer: false,
cwd: '../..',
stdout: 'pipe',
stderr: 'pipe',
env: {
2026-05-11 00:50:39 +02:00
...commonEnv,
OXICLOUD_SERVER_PORT: '8087',
OXICLOUD_STORAGE_PATH: './tests/e2e/storage',
},
},
});