From 3c5f1dca53a21c69af99c0014de03a8b2860666e Mon Sep 17 00:00:00 2001 From: cenfun Date: Wed, 6 Nov 2024 07:50:34 +0800 Subject: [PATCH] doc for onData --- README.md | 10 ++++++++++ tests/playwright.config.js | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/README.md b/README.md index 5c145cf..3b0e333 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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) diff --git a/tests/playwright.config.js b/tests/playwright.config.js index d4ee997..c40a2f3 100644 --- a/tests/playwright.config.js +++ b/tests/playwright.config.js @@ -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');