docs: add custom reporter options documentation (#21144)
This commit is contained in:
parent
03da0609ba
commit
7c6630b1a2
|
|
@ -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} */
|
/** @implements {import('@playwright/test/reporter').Reporter} */
|
||||||
class MyReporter {
|
class MyReporter {
|
||||||
|
constructor(options) {
|
||||||
|
console.log(`my-awesome-reporter setup with customOption set to ${options.customOption}`);
|
||||||
|
}
|
||||||
|
|
||||||
onBegin(config, suite) {
|
onBegin(config, suite) {
|
||||||
console.log(`Starting the run with ${suite.allTests().length} tests`);
|
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';
|
import { Reporter, FullConfig, Suite, TestCase, TestResult, FullResult } from '@playwright/test/reporter';
|
||||||
|
|
||||||
class MyReporter implements 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) {
|
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`);
|
||||||
}
|
}
|
||||||
|
|
@ -65,7 +73,7 @@ Now use this reporter with [`property: TestConfig.reporter`]. Learn more about [
|
||||||
const { defineConfig } = require('@playwright/test');
|
const { defineConfig } = require('@playwright/test');
|
||||||
|
|
||||||
module.exports = defineConfig({
|
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';
|
import { defineConfig } from '@playwright/test';
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
reporter: './my-awesome-reporter.ts',
|
reporter: ['./my-awesome-reporter.ts', { customOption: 'some value' }],
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -319,6 +319,10 @@ export interface FullResult {
|
||||||
* import { Reporter, FullConfig, Suite, TestCase, TestResult, FullResult } from '@playwright/test/reporter';
|
* import { Reporter, FullConfig, Suite, TestCase, TestResult, FullResult } from '@playwright/test/reporter';
|
||||||
*
|
*
|
||||||
* class MyReporter implements 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) {
|
* 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`);
|
||||||
* }
|
* }
|
||||||
|
|
@ -347,7 +351,7 @@ export interface FullResult {
|
||||||
* import { defineConfig } from '@playwright/test';
|
* import { defineConfig } from '@playwright/test';
|
||||||
*
|
*
|
||||||
* export default defineConfig({
|
* export default defineConfig({
|
||||||
* reporter: './my-awesome-reporter.ts',
|
* reporter: ['./my-awesome-reporter.ts', { customOption: 'some value' }],
|
||||||
* });
|
* });
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue