docs: add custom reporter options documentation (#21144)

This commit is contained in:
Gonçalo Basto 2023-02-24 11:29:08 +00:00 committed by GitHub
parent 03da0609ba
commit 7c6630b1a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 3 deletions

View File

@ -12,6 +12,10 @@ You can create a custom reporter by implementing a class with some of the report
/** @implements {import('@playwright/test/reporter').Reporter} */
class MyReporter {
constructor(options) {
console.log(`my-awesome-reporter setup with customOption set to ${options.customOption}`);
}
onBegin(config, suite) {
console.log(`Starting the run with ${suite.allTests().length} tests`);
}
@ -37,6 +41,10 @@ module.exports = MyReporter;
import { Reporter, FullConfig, Suite, TestCase, TestResult, FullResult } from '@playwright/test/reporter';
class MyReporter implements Reporter {
constructor(options: {customOption: { customOption?: string } = {}) {
console.log(`my-awesome-reporter setup with customOption set to ${options.customOption}`);
}
onBegin(config: FullConfig, suite: Suite) {
console.log(`Starting the run with ${suite.allTests().length} tests`);
}
@ -65,7 +73,7 @@ Now use this reporter with [`property: TestConfig.reporter`]. Learn more about [
const { defineConfig } = require('@playwright/test');
module.exports = defineConfig({
reporter: './my-awesome-reporter.js',
reporter: ['./my-awesome-reporter.js', { customOption: 'some value' }],
});
```
@ -74,7 +82,7 @@ module.exports = defineConfig({
import { defineConfig } from '@playwright/test';
export default defineConfig({
reporter: './my-awesome-reporter.ts',
reporter: ['./my-awesome-reporter.ts', { customOption: 'some value' }],
});
```

View File

@ -319,6 +319,10 @@ export interface FullResult {
* import { Reporter, FullConfig, Suite, TestCase, TestResult, FullResult } from '@playwright/test/reporter';
*
* class MyReporter implements Reporter {
* constructor(options: {customOption: { customOption?: string } = {}) {
* console.log(`my-awesome-reporter setup with customOption set to ${options.customOption}`);
* }
*
* onBegin(config: FullConfig, suite: Suite) {
* console.log(`Starting the run with ${suite.allTests().length} tests`);
* }
@ -347,7 +351,7 @@ export interface FullResult {
* import { defineConfig } from '@playwright/test';
*
* export default defineConfig({
* reporter: './my-awesome-reporter.ts',
* reporter: ['./my-awesome-reporter.ts', { customOption: 'some value' }],
* });
* ```
*