Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions docs/command-line/index.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Admonition from "@theme/Admonition";
import Version from "../_partials/specs/version.mdx";

# CLI {#cli}

Expand All @@ -21,6 +22,7 @@ Main command to run tests.
-s, --set <set> run tests only in the specified set
-r, --require <module> require module
--grep <grep> run only tests matching the pattern
--tag <tag> run only tests with specified tags
--reporter <name> test reporters
--update-refs update screenshot references or gather them if they do not exist ("assertView" command)
--inspect [inspect] nodejs inspector on [=[host:]port]
Expand Down Expand Up @@ -136,6 +138,50 @@ testplane --grep "with nested path"
testplane --grep "test with nested path"
```

#### Tag {#testplane-tag}

<Version version="8.37.0" />

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing example of setting multiple tags in one suite/test
There should be example where tag is array

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.
Expand Down Expand Up @@ -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
52 changes: 52 additions & 0 deletions docs/commands/browser/addTag.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import Version from "../../_partials/specs/version.mdx";

# addTag

<Version version="8.37.0" />

## 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}

<table>
<thead>
<tr>
<td>**Name**</td>
<td>**Type**</td>
<td>**Description**</td>
</tr>
</thead>
<tbody>
<tr>
<td>tag</td>
<td>`string | string[]`</td>
<td>Required parameter. Name of tag or tags.</td>
</tr>
</tbody>
</table>
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Admonition from "@theme/Admonition";
import Version from "../_partials/specs/version.mdx";

# CLI {#cli}

Expand All @@ -21,6 +22,7 @@ import Admonition from "@theme/Admonition";
-s, --set <set> run tests only in the specified set
-r, --require <module> require module
--grep <grep> run only tests matching the pattern
--tag <tag> run only tests with specified tags
--reporter <name> test reporters
--update-refs update screenshot references or gather them if they do not exist ("assertView" command)
--inspect [inspect] nodejs inspector on [=[host:]port]
Expand Down Expand Up @@ -136,6 +138,50 @@ testplane --grep "with nested path"
testplane --grep "test with nested path"
```

#### Tag {#testplane-tag}

<Version version="8.37.0" />

Запуск только тестов, соответствующих паттерну.

##### 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].
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import Version from "../../_partials/specs/version.mdx";

# addTag

<Version version="8.37.0" />

## Обзор {#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}

<table>
<thead>
<tr>
<td>**Имя**</td>
<td>**Тип**</td>
<td>**Описание**</td>
</tr>
</thead>
<tbody>
<tr>
<td>tag</td>
<td>`string | string[]`</td>
<td>Обязательный параметр. Название тега или тегов.</td>
</tr>
</tbody>
</table>