From d15910b4506764349404fbdc5284b0d3a2d50cb9 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Fri, 11 Mar 2022 19:09:23 +0100 Subject: [PATCH] docs(test-runner): add note about custom annotations (#12681) o-authored-by: Dmitry Gozman --- docs/src/test-annotations-js.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/docs/src/test-annotations-js.md b/docs/src/test-annotations-js.md index bbc9a4a5ec..eaa0ea9749 100644 --- a/docs/src/test-annotations-js.md +++ b/docs/src/test-annotations-js.md @@ -212,3 +212,25 @@ test('user profile', async ({ page }) => { // ... }); ``` + +## Custom annotations + +It's also possible to add custom metadata in the form of annotations to your tests. Annotations are key/value pairs accessible via [`test.info().annotations`](./api/class-testinfo#test-info-annotations). Many reporters show annotations, for example `'html'`. + +```js js-flavor=js +// example.spec.js + +test('user profile', async ({ page }) => { + test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/' }); + // ... +}); +``` + +```js js-flavor=ts +// example.spec.ts + +test('user profile', async ({ page }) => { + test.info().annotations.push({ type: 'issue', description: 'https://github.com/microsoft/playwright/issues/' }); + // ... +}); +```