docs: Added types to custom reporter typescript example (#20191)
This commit is contained in:
parent
2b499bd5d6
commit
32724cd5ce
|
|
@ -34,22 +34,22 @@ module.exports = MyReporter;
|
||||||
|
|
||||||
```js tab=js-ts
|
```js tab=js-ts
|
||||||
// my-awesome-reporter.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 {
|
class MyReporter implements Reporter {
|
||||||
onBegin(config, suite) {
|
onBegin(config: FullConfig, suite: Suite) {
|
||||||
console.log(`Starting the run with ${suite.allTests().length} tests`);
|
console.log(`Starting the run with ${suite.allTests().length} tests`);
|
||||||
}
|
}
|
||||||
|
|
||||||
onTestBegin(test) {
|
onTestBegin(test: TestCase) {
|
||||||
console.log(`Starting test ${test.title}`);
|
console.log(`Starting test ${test.title}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
onTestEnd(test, result) {
|
onTestEnd(test: TestCase, result: TestResult) {
|
||||||
console.log(`Finished test ${test.title}: ${result.status}`);
|
console.log(`Finished test ${test.title}: ${result.status}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
onEnd(result) {
|
onEnd(result: FullResult) {
|
||||||
console.log(`Finished the run: ${result.status}`);
|
console.log(`Finished the run: ${result.status}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
10
packages/playwright-test/types/testReporter.d.ts
vendored
10
packages/playwright-test/types/testReporter.d.ts
vendored
|
|
@ -313,22 +313,22 @@ export interface FullResult {
|
||||||
*
|
*
|
||||||
* ```js
|
* ```js
|
||||||
* // my-awesome-reporter.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 {
|
* class MyReporter implements Reporter {
|
||||||
* onBegin(config, suite) {
|
* onBegin(config: FullConfig, suite: Suite) {
|
||||||
* console.log(`Starting the run with ${suite.allTests().length} tests`);
|
* console.log(`Starting the run with ${suite.allTests().length} tests`);
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* onTestBegin(test) {
|
* onTestBegin(test: TestCase) {
|
||||||
* console.log(`Starting test ${test.title}`);
|
* console.log(`Starting test ${test.title}`);
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* onTestEnd(test, result) {
|
* onTestEnd(test: TestCase, result: TestResult) {
|
||||||
* console.log(`Finished test ${test.title}: ${result.status}`);
|
* console.log(`Finished test ${test.title}: ${result.status}`);
|
||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* onEnd(result) {
|
* onEnd(result: FullResult) {
|
||||||
* console.log(`Finished the run: ${result.status}`);
|
* console.log(`Finished the run: ${result.status}`);
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue