diff --git a/docs/command-line/index.mdx b/docs/command-line/index.mdx index 9e95ad9..51f5c24 100644 --- a/docs/command-line/index.mdx +++ b/docs/command-line/index.mdx @@ -1,4 +1,5 @@ import Admonition from "@theme/Admonition"; +import Version from "../_partials/specs/version.mdx"; # CLI {#cli} @@ -21,6 +22,7 @@ Main command to run tests. -s, --set run tests only in the specified set -r, --require require module --grep run only tests matching the pattern + --tag run only tests with specified tags --reporter test reporters --update-refs update screenshot references or gather them if they do not exist ("assertView" command) --inspect [inspect] nodejs inspector on [=[host:]port] @@ -136,6 +138,50 @@ testplane --grep "with nested path" testplane --grep "test with nested path" ``` +#### Tag {#testplane-tag} + + + +Run only tests, which matches the tag pattern. + +##### Example {#testplane-tag-example} + +You can assign tags to a test using the second parameter of `describe` ot `it` (see example below). +You can also add tags dynamically during test execution with the [addTag][add-tag] command, +but you can not use dynamic tags to filter tests at launch. + +```ts +describe("test", {tag: "all"}, () => { + describe("with", {tag: "desktop"}, () => { + describe("nested path", {tag: ["smoke", "slow"]}, () => { + await browser.addTag("some"); + ... + }); + describe("other path", {tag: "slow"}, () => { + ... + }) + }); + describe("with", {tag: "mobile"}, () => { + describe("nested path", {tag: "smoke"}, () => { + ... + }); + describe("other path", {tag: "slow"}, () => { + ... + }) + }); +}); +``` + +You can use tags to run tests and combine them with logical operators & (and), | (or), and ! (not). + +```bash +testplane --tag "desktop" +testplane --tag "mobile" +testplane --tag "mobile&smoke" +testplane --tag "desktop|slow" +testplane --tag "!slow" +``` + #### Update refs {#testplane-update-refs} Run tests, updating all screenshot references, created by [assertView][assert-view] command. @@ -700,5 +746,6 @@ TESTPLANE_SETS=desktop,touch testplane [html-reporter]: ../html-reporter/html-reporter-setup [assert-view]: ../commands/browser/assertView +[add-tag]: ../commands/browser/addTag [switch-to-repl]: ../commands/browser/switchToRepl [webdriver-vs-cdp]: ../reference/webdriver-vs-cdp diff --git a/docs/commands/browser/addTag.mdx b/docs/commands/browser/addTag.mdx new file mode 100644 index 0000000..236b861 --- /dev/null +++ b/docs/commands/browser/addTag.mdx @@ -0,0 +1,52 @@ +import Version from "../../_partials/specs/version.mdx"; + +# addTag + + + +## Overview {#overview} + +Use the `addTag` command to add a tag (or multiple tags) to a test during execution. + +## Usage {#usage} + +```typescript +await browser.addTag("one"); +await browser.addTag(["first", "second"]); +``` + +Also, the test object now has methods to add a tag, get a list of tags, and check if a tag exists. +You can use it in your plugin where you have access to test objects. + +```typescript +type TestTag = { + title: string; + dynamic?: boolean; +}; + +function addTag(tag: string | string[]): void; +function hasTag(tag: string): boolean; +function getTag(): TestTag[]; +``` + +`getTag` returns an array of the tag objects mentioned above. +Each object has a `title` and a `dynamic` field, which indicates that the tag was added during the test. + +## Command Parameters {#parameters} + + + + + + + + + + + + + + + + +
**Name****Type****Description**
tag`string | string[]`Required parameter. Name of tag or tags.
diff --git a/i18n/ru/docusaurus-plugin-content-docs/current/command-line/index.mdx b/i18n/ru/docusaurus-plugin-content-docs/current/command-line/index.mdx index 923e794..8438350 100644 --- a/i18n/ru/docusaurus-plugin-content-docs/current/command-line/index.mdx +++ b/i18n/ru/docusaurus-plugin-content-docs/current/command-line/index.mdx @@ -1,4 +1,5 @@ import Admonition from "@theme/Admonition"; +import Version from "../_partials/specs/version.mdx"; # CLI {#cli} @@ -21,6 +22,7 @@ import Admonition from "@theme/Admonition"; -s, --set run tests only in the specified set -r, --require require module --grep run only tests matching the pattern + --tag run only tests with specified tags --reporter test reporters --update-refs update screenshot references or gather them if they do not exist ("assertView" command) --inspect [inspect] nodejs inspector on [=[host:]port] @@ -136,6 +138,50 @@ testplane --grep "with nested path" testplane --grep "test with nested path" ``` +#### Tag {#testplane-tag} + + + +Запуск только тестов, соответствующих паттерну. + +##### Example {#testplane-tag-example} + +Вы можете назначить теги тесту с помощью второго параметре `describe` или `it` (пример ниже). +Также вы можете добавлять теги динамически во время выполнения теста с помощью команды [addTag][add-tag], +но вы не можете использовать динамически добавленные теги для фильтрации тестов при запуске. + +```ts +describe("test", {tag: "all"}, () => { + describe("with", {tag: "desktop"}, () => { + describe("nested path", {tag: ["smoke", "slow"]}, () => { + await browser.addTag("some"); + ... + }); + describe("other path", {tag: "slow"}, () => { + ... + }) + }); + describe("with", {tag: "mobile"}, () => { + describe("nested path", {tag: "smoke"}, () => { + ... + }); + describe("other path", {tag: "slow"}, () => { + ... + }) + }); +}); +``` + +Вы можете использовать теги для запуска тестов, комбинируя их с логическими операторами & (и), | (или) и ! (не). + +```bash +testplane --tag "desktop" +testplane --tag "mobile" +testplane --tag "mobile&smoke" +testplane --tag "desktop|slow" +testplane --tag "!slow" +``` + #### Update-refs {#testplane-update-refs} Запуск тестов с обновлением всех ссылок на скриншоты, созданных командой [assertView][assert-view]. @@ -701,5 +747,6 @@ TESTPLANE_SETS=desktop,touch testplane [html-reporter]: ../html-reporter/html-reporter-setup [assert-view]: ../commands/browser/assertView +[add-tag]: ../commands/browser/addTag [switch-to-repl]: ../commands/browser/switchToRepl [webdriver-vs-cdp]: ../reference/webdriver-vs-cdp diff --git a/i18n/ru/docusaurus-plugin-content-docs/current/commands/browser/addTag.mdx b/i18n/ru/docusaurus-plugin-content-docs/current/commands/browser/addTag.mdx new file mode 100644 index 0000000..154fdf1 --- /dev/null +++ b/i18n/ru/docusaurus-plugin-content-docs/current/commands/browser/addTag.mdx @@ -0,0 +1,52 @@ +import Version from "../../_partials/specs/version.mdx"; + +# addTag + + + +## Обзор {#overview} + +Используйте команду `addTag`, чтобы добавить один или несколько тегов к тесту во время его выполнения. + +## Использование {#usage} + +```typescript +await browser.addTag("one"); +await browser.addTag(["first", "second"]); +``` + +Также, объект теста теперь имеет методы для добавления тега, получения списка тегов и проверки существования тега. +Вы можете использовать это в своём плагине где у вас есть доступ к объектам тестов. + +```typescript +type TestTag = { + title: string; + dynamic?: boolean; +}; + +function addTag(tag: string | string[]): void; +function hasTag(tag: string): boolean; +function getTag(): TestTag[]; +``` + +Метод `getTag` возвращает массив объектов тегов, которые были упомянуты выше. +Каждый объект имеет поле `title` и поле `dynamic`, которое указывает на то, что тег был добавлен в процессе теста. + +## Параметры команды {#parameters} + + + + + + + + + + + + + + + + +
**Имя****Тип****Описание**
tag`string | string[]`Обязательный параметр. Название тега или тегов.