mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 12:24:30 +01:00
test(e2e): clean up run artifacts after the suite
- server.sh removes e2e/.tmp when the backend exits, forwarding SIGTERM so Playwright's graceful shutdown still applies - a cleanup reporter removes playwright-report and test-results after a passing run; failed runs keep them for debugging and CI upload
This commit is contained in:
1 parent
132176d6f9
commit
0b42f7de97
4 files changed
+35
-5
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import { rm } from 'node:fs/promises'
|
||||
import type { FullResult, Reporter } from '@playwright/test/reporter'
|
||||
import { REPORT_DIR, TEST_RESULTS_DIR } from './env'
|
||||
|
||||
/** Removes the HTML report and test results after a passing run; failed runs keep them for debugging and CI upload. */
|
||||
export default class CleanupPassedRunReporter implements Reporter {
|
||||
private status: FullResult['status'] | undefined
|
||||
|
||||
onEnd(result: FullResult) {
|
||||
this.status = result.status
|
||||
}
|
||||
|
||||
async onExit() {
|
||||
if (this.status !== 'passed') return
|
||||
await Promise.all([
|
||||
rm(REPORT_DIR, { recursive: true, force: true }),
|
||||
rm(TEST_RESULTS_DIR, { recursive: true, force: true }),
|
||||
])
|
||||
}
|
||||
|
||||
printsToStdio() {
|
||||
return false
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,8 @@ export const E2E_ROOT = path.dirname(fileURLToPath(import.meta.url))
|
||||
export const REPO_ROOT = path.resolve(E2E_ROOT, '..')
|
||||
export const E2E_TMP = path.join(E2E_ROOT, '.tmp')
|
||||
export const STORAGE_STATE = path.join(E2E_TMP, 'storage-state.json')
|
||||
export const TEST_RESULTS_DIR = path.join(REPO_ROOT, 'test-results')
|
||||
export const REPORT_DIR = path.join(REPO_ROOT, 'playwright-report')
|
||||
|
||||
export const BASE_URL = 'http://127.0.0.1:5013'
|
||||
export const SERVER_PORT = 5013
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import path from 'node:path'
|
||||
import { defineConfig, devices } from '@playwright/test'
|
||||
import { BASE_URL, E2E_ROOT, REPO_ROOT, STORAGE_STATE, createServerEnv } from './env'
|
||||
import { BASE_URL, E2E_ROOT, REPORT_DIR, REPO_ROOT, STORAGE_STATE, TEST_RESULTS_DIR, createServerEnv } from './env'
|
||||
|
||||
export default defineConfig({
|
||||
testDir: E2E_ROOT,
|
||||
outputDir: path.join(REPO_ROOT, 'test-results'),
|
||||
outputDir: TEST_RESULTS_DIR,
|
||||
fullyParallel: false,
|
||||
forbidOnly: Boolean(process.env.CI),
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
@@ -13,7 +12,8 @@ export default defineConfig({
|
||||
expect: { timeout: 15_000 },
|
||||
reporter: [
|
||||
['list'],
|
||||
['html', { open: 'never', outputFolder: path.join(REPO_ROOT, 'playwright-report') }],
|
||||
['html', { open: 'never', outputFolder: REPORT_DIR }],
|
||||
['./cleanup-reporter.ts'],
|
||||
],
|
||||
use: {
|
||||
baseURL: BASE_URL,
|
||||
|
||||
+5
-1
@@ -6,6 +6,10 @@ TMP="$ROOT/e2e/.tmp"
|
||||
|
||||
rm -rf "$TMP"
|
||||
mkdir -p "$TMP/home" "$TMP/data" "$TMP/workspace" "$TMP/tmp" "$TMP/run"
|
||||
trap 'rm -rf "$TMP"' EXIT
|
||||
|
||||
cd "$ROOT"
|
||||
exec bun run backend/dist/index.js
|
||||
bun run backend/dist/index.js &
|
||||
BACKEND_PID=$!
|
||||
trap 'kill -TERM "$BACKEND_PID" 2>/dev/null || true' TERM INT
|
||||
wait "$BACKEND_PID" || wait "$BACKEND_PID"
|
||||
Reference in new issue
Block a user