|
| 1 | +import Version from "../_partials/specs/version.mdx"; |
| 2 | + |
1 | 3 | --- |
2 | | -sidebar_position: 2 |
3 | | ---- |
| 4 | + |
| 5 | +## sidebar_position: 2 |
4 | 6 |
|
5 | 7 | import Tabs from "@theme/Tabs"; |
6 | 8 | import TabItem from "@theme/TabItem"; |
@@ -35,6 +37,7 @@ import ConfigExamples from "/docs/_partials/html-reporter-config-examples.mdx"; |
35 | 37 | <tr><td>[plugins](#plugins)</td><td>`Plugin[]`</td><td>`[]`</td><td>A list of plugins with their settings.</td></tr> |
36 | 38 | <tr><td>[customScripts](#customscripts)</td><td>`AnyFunction[]`</td><td>`[]`</td><td>A list of functions that implement custom scripts. For example, Yandex.Metrika scripts or a Bug.</td></tr> |
37 | 39 | <tr><td>[yandexMetrika](#yandexmetrika)</td><td>`YandexMetrika`</td><td>*see below*</td><td>[Yandex.Metrika][yandex-metrika].</td></tr> |
| 40 | +<tr><td>[generateBadges](#generatebadges)</td><td>`GenerateBadges`</td><td>`null`</td><td>A callback that is called after every test run. It receives the test result and returns a list of badges.</td></tr> |
38 | 41 |
|
39 | 42 | </tbody> |
40 | 43 | </table> |
@@ -288,6 +291,82 @@ If you don't want to share analytics with us, you can disable it in any of the f |
288 | 291 | - Using environment variables: `html_reporter_yandex_metrika_enabled=false` or simply `NO_ANALYTICS=true` |
289 | 292 | - Using CLI arguments: `--html-reporter-yandex_metrika_enabled=false` |
290 | 293 |
|
| 294 | +### generateBadges |
| 295 | + |
| 296 | +<Version version="11.4.0" /> |
| 297 | + |
| 298 | +A callback that is called after every test run. It receives the test result and returns a list of badges. |
| 299 | + |
| 300 | +Usage example: here we set the issue name and URL, the branch name. |
| 301 | + |
| 302 | +```typescript title="testplane.config.ts" |
| 303 | +{ |
| 304 | + // other Testplane config... |
| 305 | + plugins: { |
| 306 | + "html-reporter/testplane": { |
| 307 | + //... |
| 308 | + generateBadges: (test) => [ |
| 309 | + { |
| 310 | + title: test.meta.issueTitle, |
| 311 | + icon: 'LogoYandexTracker', |
| 312 | + url: test.meta.issueUrl, |
| 313 | + }, |
| 314 | + { |
| 315 | + title: test.meta.branch, |
| 316 | + icon: 'BranchesRight', |
| 317 | + }, |
| 318 | + ] |
| 319 | + } |
| 320 | + } |
| 321 | +} |
| 322 | +``` |
| 323 | + |
| 324 | +An example of a test where you can set metadata. |
| 325 | + |
| 326 | +```typescript title="testplane.config.ts" |
| 327 | +describe("badges", () => { |
| 328 | + it("badge example", async ({ browser }) => { |
| 329 | + await browser.setMeta("issueTitle", "ticket-1234"); |
| 330 | + await browser.setMeta("issueUrl", "https://example.com"); |
| 331 | + await browser.setMeta("branch", "master"); |
| 332 | + |
| 333 | + await browser.pause(3000); |
| 334 | + }); |
| 335 | +}); |
| 336 | +``` |
| 337 | + |
| 338 | +#### Badge params |
| 339 | + |
| 340 | +<table> |
| 341 | + <thead> |
| 342 | + <tr> |
| 343 | + <td>**Name**</td> |
| 344 | + <td>**Type**</td> |
| 345 | + <td>**Description**</td> |
| 346 | + </tr> |
| 347 | + </thead> |
| 348 | + <tbody> |
| 349 | + <tr> |
| 350 | + <td>`title`</td> |
| 351 | + <td>`string`</td> |
| 352 | + <td> |
| 353 | + Optional parameter. Displayed badge title. If not provided, the badge will not |
| 354 | + render. |
| 355 | + </td> |
| 356 | + </tr> |
| 357 | + <tr> |
| 358 | + <td>`icon`</td> |
| 359 | + <td>`string`</td> |
| 360 | + <td>Optional parameter. Name of icon from [GravityUI][gravity-ui-icons].</td> |
| 361 | + </tr> |
| 362 | + <tr> |
| 363 | + <td>`url`</td> |
| 364 | + <td>`string`</td> |
| 365 | + <td>Optional parameter. Url of badge.</td> |
| 366 | + </tr> |
| 367 | + </tbody> |
| 368 | +</table> |
| 369 | + |
291 | 370 | ### Passing parameters via the CLI {#setup_by_cli} |
292 | 371 |
|
293 | 372 | All plugin parameters that can be defined in the config can also be passed as command line options or through environment variables during Testplane startup. Use the prefix `--html-reporter-` for command line options and `html_reporter_` for environment variables. |
@@ -328,3 +407,4 @@ Files that are created during the execution of tests: |
328 | 407 | [how-to-create-counter]: https://yandex.ru/support/metrica/general/creating-counter.html |
329 | 408 | [merge-reports]: ../html-reporter-commands#merge-reports |
330 | 409 | [http-server]: https://github.com/http-party/http-server#http-server-a-simple-static-http-server |
| 410 | +[gravity-ui-icons]: https://gravity-ui.com/ru/icons |
0 commit comments