docs(test-runner): add note about custom annotations (#12681)

o-authored-by: Dmitry Gozman <dgozman@gmail.com>
This commit is contained in:
Max Schmitt 2022-03-11 19:09:23 +01:00 committed by GitHub
parent 95c774cf84
commit d15910b450
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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/<some-issue>' });
// ...
});
```
```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/<some-issue>' });
// ...
});
```