Skip to content

Commit

Permalink
doc for onData
Browse files Browse the repository at this point in the history
  • Loading branch information
cenfun committed Nov 5, 2024
1 parent b835696 commit 3c5f1dc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
- [Send and Receive Messages between Processes](#send-and-receive-messages-between-processes)
* [Merge Shard Reports](#merge-shard-reports)
* [onEnd Hook](#onend-hook)
* [onData Hook](#ondata-hook)
* [Integration Examples](#integration-examples)
* [Contributing](#contributing)
* [Changelog](CHANGELOG.md)
Expand Down Expand Up @@ -1145,6 +1146,15 @@ module.exports = {
};
```
## onData hook
The `onData` function will be executed after report data generated (before `onEnd`).
```js
onData: (reportData) => {
// console.log('onData', reportData);
reportData.name = 'My Report Name';
}
```
## Integration Examples
By using the `onEnd` hook, we can integrate Playwright report with any other tools, such as:
- [Email](https://github.com/cenfun/playwright-reporter-integrations/tree/main/send-email)
Expand Down
5 changes: 5 additions & 0 deletions tests/playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,11 @@ module.exports = {
merge: false
},

onData: (reportData) => {
// console.log('onData', reportData);
// reportData.name = 'My Report Name';
},

// async hook after report data generated
onEnd: (reportData, helper) => {
// console.log('onEnd hook start');
Expand Down

0 comments on commit 3c5f1dc

Please sign in to comment.