Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

docs(reporter): added types to Reporter TypeScript example (#19917)

Tommaso A6d64edc090e1
diff --git a/docs/src/test-reporters-js.md b/docs/src/test-reporters-js.md
index 08cc35de05..2a73f58b11 100644
--- a/docs/src/test-reporters-js.md
+++ b/docs/src/test-reporters-js.md
@@ -626,25 +626,26 @@ module.exports = MyReporter;
```js tab=js-ts
// my-awesome-reporter.ts
-import { Reporter } from '@playwright/test/reporter';
+import { FullConfig, FullResult, Reporter, Suite, TestCase, TestResult } from '@playwright/test/reporter';
class MyReporter implements Reporter {
- onBegin(config, suite) {
+ onBegin(config: FullConfig, suite: Suite) {
console.log(`Starting the run with ${suite.allTests().length} tests`);
}
- onTestBegin(test) {
+ onTestBegin(test: TestCase, result: TestResult) {
console.log(`Starting test ${test.title}`);
}
- onTestEnd(test, result) {
+ onTestEnd(test: TestCase, result: TestResult) {
console.log(`Finished test ${test.title}: ${result.status}`);
}
- onEnd(result) {
+ onEnd(result: FullResult) {
console.log(`Finished the run: ${result.status}`);
}
}
+
export default MyReporter;
```