Skip to content

Commit 6da5bf1

Browse files
committed
Implement CoderReporter
1 parent 90acf99 commit 6da5bf1

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

.github/workflows/ci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ jobs:
554554
- run: pnpm playwright:install
555555
working-directory: site
556556

557-
- run: pnpm playwright:test
557+
- run: pnpm playwright:test --workers 1
558558
env:
559559
DEBUG: pw:api
560560
working-directory: site

site/e2e/playwright.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { defineConfig } from "@playwright/test"
22
import path from "path"
33
import { defaultPort, gitAuth } from "./constants"
4+
import CoderReporter from "./reporter"
45

56
export const port = process.env.CODER_E2E_PORT
67
? Number(process.env.CODER_E2E_PORT)
@@ -30,6 +31,7 @@ export default defineConfig({
3031
timeout: 60000,
3132
},
3233
],
34+
reporter: [["./reporter.ts"]],
3335
use: {
3436
baseURL: `http://localhost:${port}`,
3537
video: "retain-on-failure",

site/e2e/reporter.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import type {
2+
Reporter,
3+
FullConfig,
4+
Suite,
5+
TestCase,
6+
TestResult,
7+
FullResult,
8+
} from "@playwright/test/reporter"
9+
10+
class CoderReporter implements Reporter {
11+
onBegin(config: FullConfig, suite: Suite) {
12+
// eslint-disable-next-line no-console -- Helpful for debugging
13+
console.log(`Starting the run with ${suite.allTests().length} tests`)
14+
}
15+
16+
onTestBegin(test: TestCase) {
17+
// eslint-disable-next-line no-console -- Helpful for debugging
18+
console.log(`Starting test ${test.title}`)
19+
}
20+
21+
onStdOut(chunk: string, test: TestCase, _: TestResult): void {
22+
// eslint-disable-next-line no-console -- Helpful for debugging
23+
console.log(
24+
`[stdout] [${test ? test.title : "unknown"}]: ${chunk.replace(
25+
/\n$/g,
26+
"",
27+
)}`,
28+
)
29+
}
30+
31+
onStdErr(chunk: string, test: TestCase, _: TestResult): void {
32+
// eslint-disable-next-line no-console -- Helpful for debugging
33+
console.log(
34+
`[stderr] [${test ? test.title : "unknown"}]: ${chunk.replace(
35+
/\n$/g,
36+
"",
37+
)}`,
38+
)
39+
}
40+
41+
onTestEnd(test: TestCase, result: TestResult) {
42+
// eslint-disable-next-line no-console -- Helpful for debugging
43+
console.log(`Finished test ${test.title}: ${result.status}`)
44+
}
45+
46+
onEnd(result: FullResult) {
47+
// eslint-disable-next-line no-console -- Helpful for debugging
48+
console.log(`Finished the run: ${result.status}`)
49+
}
50+
}
51+
export default CoderReporter

0 commit comments

Comments
 (0)