Skip to content

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

docs: Added types to custom reporter typescript example (#20191)

Adi32724cd5ce4e
diff --git a/docs/src/test-reporter-api/class-reporter.md b/docs/src/test-reporter-api/class-reporter.md
index db05d7a7d6..b3cac403de 100644
--- a/docs/src/test-reporter-api/class-reporter.md
+++ b/docs/src/test-reporter-api/class-reporter.md
@@ -34,22 +34,22 @@ module.exports = MyReporter;
```js tab=js-ts
// my-awesome-reporter.ts
-import { Reporter } from '@playwright/test/reporter';
+import { Reporter, FullConfig, Suite, TestCase, TestResult, FullResult } 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) {
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}`);
}
}
diff --git a/packages/playwright-test/types/testReporter.d.ts b/packages/playwright-test/types/testReporter.d.ts
index 5697b94f3e..bc3e732fce 100644
--- a/packages/playwright-test/types/testReporter.d.ts
+++ b/packages/playwright-test/types/testReporter.d.ts
@@ -313,22 +313,22 @@ export interface FullResult {
*
* ```js
* // my-awesome-reporter.ts
- * import { Reporter } from '@playwright/test/reporter';
+ * import { Reporter, FullConfig, Suite, TestCase, TestResult, FullResult } 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) {
* 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}`);
* }
* }