Skip to content

Commit 64966a1

Browse files
authored
docs: tags docs
1 parent fcc9dff commit 64966a1

4 files changed

Lines changed: 198 additions & 0 deletions

File tree

docs/command-line/index.mdx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Admonition from "@theme/Admonition";
2+
import Version from "../_partials/specs/version.mdx";
23

34
# CLI {#cli}
45

@@ -21,6 +22,7 @@ Main command to run tests.
2122
-s, --set <set> run tests only in the specified set
2223
-r, --require <module> require module
2324
--grep <grep> run only tests matching the pattern
25+
--tag <tag> run only tests with specified tags
2426
--reporter <name> test reporters
2527
--update-refs update screenshot references or gather them if they do not exist ("assertView" command)
2628
--inspect [inspect] nodejs inspector on [=[host:]port]
@@ -136,6 +138,50 @@ testplane --grep "with nested path"
136138
testplane --grep "test with nested path"
137139
```
138140
141+
#### Tag {#testplane-tag}
142+
143+
<Version version="8.37.0" />
144+
145+
Run only tests, which matches the tag pattern.
146+
147+
##### Example {#testplane-tag-example}
148+
149+
You can assign tags to a test using the second parameter of `describe` ot `it` (see example below).
150+
You can also add tags dynamically during test execution with the [addTag][add-tag] command,
151+
but you can not use dynamic tags to filter tests at launch.
152+
153+
```ts
154+
describe("test", {tag: "all"}, () => {
155+
describe("with", {tag: "desktop"}, () => {
156+
describe("nested path", {tag: ["smoke", "slow"]}, () => {
157+
await browser.addTag("some");
158+
...
159+
});
160+
describe("other path", {tag: "slow"}, () => {
161+
...
162+
})
163+
});
164+
describe("with", {tag: "mobile"}, () => {
165+
describe("nested path", {tag: "smoke"}, () => {
166+
...
167+
});
168+
describe("other path", {tag: "slow"}, () => {
169+
...
170+
})
171+
});
172+
});
173+
```
174+
175+
You can use tags to run tests and combine them with logical operators & (and), | (or), and ! (not).
176+
177+
```bash
178+
testplane --tag "desktop"
179+
testplane --tag "mobile"
180+
testplane --tag "mobile&smoke"
181+
testplane --tag "desktop|slow"
182+
testplane --tag "!slow"
183+
```
184+
139185
#### Update refs {#testplane-update-refs}
140186
141187
Run tests, updating all screenshot references, created by [assertView][assert-view] command.
@@ -700,5 +746,6 @@ TESTPLANE_SETS=desktop,touch testplane
700746
701747
[html-reporter]: ../html-reporter/html-reporter-setup
702748
[assert-view]: ../commands/browser/assertView
749+
[add-tag]: ../commands/browser/addTag
703750
[switch-to-repl]: ../commands/browser/switchToRepl
704751
[webdriver-vs-cdp]: ../reference/webdriver-vs-cdp

docs/commands/browser/addTag.mdx

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import Version from "../../_partials/specs/version.mdx";
2+
3+
# addTag
4+
5+
<Version version="8.37.0" />
6+
7+
## Overview {#overview}
8+
9+
Use the `addTag` command to add a tag (or multiple tags) to a test during execution.
10+
11+
## Usage {#usage}
12+
13+
```typescript
14+
await browser.addTag("one");
15+
await browser.addTag(["first", "second"]);
16+
```
17+
18+
Also, the test object now has methods to add a tag, get a list of tags, and check if a tag exists.
19+
You can use it in your plugin where you have access to test objects.
20+
21+
```typescript
22+
type TestTag = {
23+
title: string;
24+
dynamic?: boolean;
25+
};
26+
27+
function addTag(tag: string | string[]): void;
28+
function hasTag(tag: string): boolean;
29+
function getTag(): TestTag[];
30+
```
31+
32+
`getTag` returns an array of the tag objects mentioned above.
33+
Each object has a `title` and a `dynamic` field, which indicates that the tag was added during the test.
34+
35+
## Command Parameters {#parameters}
36+
37+
<table>
38+
<thead>
39+
<tr>
40+
<td>**Name**</td>
41+
<td>**Type**</td>
42+
<td>**Description**</td>
43+
</tr>
44+
</thead>
45+
<tbody>
46+
<tr>
47+
<td>tag</td>
48+
<td>`string | string[]`</td>
49+
<td>Required parameter. Name of tag or tags.</td>
50+
</tr>
51+
</tbody>
52+
</table>

i18n/ru/docusaurus-plugin-content-docs/current/command-line/index.mdx

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Admonition from "@theme/Admonition";
2+
import Version from "../_partials/specs/version.mdx";
23

34
# CLI {#cli}
45

@@ -21,6 +22,7 @@ import Admonition from "@theme/Admonition";
2122
-s, --set <set> run tests only in the specified set
2223
-r, --require <module> require module
2324
--grep <grep> run only tests matching the pattern
25+
--tag <tag> run only tests with specified tags
2426
--reporter <name> test reporters
2527
--update-refs update screenshot references or gather them if they do not exist ("assertView" command)
2628
--inspect [inspect] nodejs inspector on [=[host:]port]
@@ -136,6 +138,50 @@ testplane --grep "with nested path"
136138
testplane --grep "test with nested path"
137139
```
138140
141+
#### Tag {#testplane-tag}
142+
143+
<Version version="8.37.0" />
144+
145+
Запуск только тестов, соответствующих паттерну.
146+
147+
##### Example {#testplane-tag-example}
148+
149+
Вы можете назначить теги тесту с помощью второго параметре `describe` или `it` (пример ниже).
150+
Также вы можете добавлять теги динамически во время выполнения теста с помощью команды [addTag][add-tag],
151+
но вы не можете использовать динамически добавленные теги для фильтрации тестов при запуске.
152+
153+
```ts
154+
describe("test", {tag: "all"}, () => {
155+
describe("with", {tag: "desktop"}, () => {
156+
describe("nested path", {tag: ["smoke", "slow"]}, () => {
157+
await browser.addTag("some");
158+
...
159+
});
160+
describe("other path", {tag: "slow"}, () => {
161+
...
162+
})
163+
});
164+
describe("with", {tag: "mobile"}, () => {
165+
describe("nested path", {tag: "smoke"}, () => {
166+
...
167+
});
168+
describe("other path", {tag: "slow"}, () => {
169+
...
170+
})
171+
});
172+
});
173+
```
174+
175+
Вы можете использовать теги для запуска тестов, комбинируя их с логическими операторами & (и), | (или) и ! (не).
176+
177+
```bash
178+
testplane --tag "desktop"
179+
testplane --tag "mobile"
180+
testplane --tag "mobile&smoke"
181+
testplane --tag "desktop|slow"
182+
testplane --tag "!slow"
183+
```
184+
139185
#### Update-refs {#testplane-update-refs}
140186
141187
Запуск тестов с обновлением всех ссылок на скриншоты, созданных командой [assertView][assert-view].
@@ -701,5 +747,6 @@ TESTPLANE_SETS=desktop,touch testplane
701747
702748
[html-reporter]: ../html-reporter/html-reporter-setup
703749
[assert-view]: ../commands/browser/assertView
750+
[add-tag]: ../commands/browser/addTag
704751
[switch-to-repl]: ../commands/browser/switchToRepl
705752
[webdriver-vs-cdp]: ../reference/webdriver-vs-cdp
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import Version from "../../_partials/specs/version.mdx";
2+
3+
# addTag
4+
5+
<Version version="8.37.0" />
6+
7+
## Обзор {#overview}
8+
9+
Используйте команду `addTag`, чтобы добавить один или несколько тегов к тесту во время его выполнения.
10+
11+
## Использование {#usage}
12+
13+
```typescript
14+
await browser.addTag("one");
15+
await browser.addTag(["first", "second"]);
16+
```
17+
18+
Также, объект теста теперь имеет методы для добавления тега, получения списка тегов и проверки существования тега.
19+
Вы можете использовать это в своём плагине где у вас есть доступ к объектам тестов.
20+
21+
```typescript
22+
type TestTag = {
23+
title: string;
24+
dynamic?: boolean;
25+
};
26+
27+
function addTag(tag: string | string[]): void;
28+
function hasTag(tag: string): boolean;
29+
function getTag(): TestTag[];
30+
```
31+
32+
Метод `getTag` возвращает массив объектов тегов, которые были упомянуты выше.
33+
Каждый объект имеет поле `title` и поле `dynamic`, которое указывает на то, что тег был добавлен в процессе теста.
34+
35+
## Параметры команды {#parameters}
36+
37+
<table>
38+
<thead>
39+
<tr>
40+
<td>**Имя**</td>
41+
<td>**Тип**</td>
42+
<td>**Описание**</td>
43+
</tr>
44+
</thead>
45+
<tbody>
46+
<tr>
47+
<td>tag</td>
48+
<td>`string | string[]`</td>
49+
<td>Обязательный параметр. Название тега или тегов.</td>
50+
</tr>
51+
</tbody>
52+
</table>

0 commit comments

Comments
 (0)