Skip to content

Commit 2bd4480

Browse files
committed
docs: add info about expect timeout configuration
1 parent d39f1c3 commit 2bd4480

File tree

3 files changed

+100
-0
lines changed

3 files changed

+100
-0
lines changed

docs/commands/expect/overview.mdx

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
sidebar_class_name: hidden
3+
---
4+
5+
# Assertion with Expect
6+
7+
## Overview
8+
9+
When writing tests, it's often necessary to ensure that values meet certain criteria. With the `expect` function you have access to a variety of matchers that help verify different characteristics of the browser, element, or object mock.
10+
11+
For example, you can check if the browser is on a specific page
12+
13+
```typescript
14+
await browser.url("https://webdriver.io/");
15+
// ...
16+
await expect(browser).toHaveUrl("https://webdriver.io");
17+
```
18+
19+
or check if the element has an attribute with the specified value
20+
21+
```typescript
22+
const myInput = await browser.$("input");
23+
await expect(myInput).toHaveAttribute("class", "form-control");
24+
```
25+
26+
or check if the specified request has been made for your mock
27+
28+
```typescript
29+
const mock = browser.mock("**/api/todo*");
30+
// ...
31+
await expect(mock).toBeRequested();
32+
```
33+
34+
By default, the timeout for executing asserts is 2000ms with a check interval of 100ms. However, if necessary, these values can be redefined in the [system section][system_config] in the general config.
35+
36+
```typescript
37+
{
38+
// another testplane configs
39+
system: {
40+
expectOpts: {
41+
wait: 5000,
42+
interval: 200,
43+
}
44+
}
45+
}
46+
```
47+
48+
[system_config]: ../../../config/system#expect_opts

docs/config/_partials/examples/_system-example.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ export default {
88
mochaOpts: {
99
timeout: 60000,
1010
},
11+
expectOpts: {
12+
wait: 3000,
13+
interval: 100,
14+
},
1115
ctx: {
1216
/* ... */
1317
},
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
sidebar_class_name: hidden
3+
---
4+
5+
# Ассерты с помощью Expect
6+
7+
## Обзор
8+
9+
В ходе написания тестов нужно часто удостовериться, что значения отвечают определённым требованиям. С помощью функции expect у вас есть доступ к множеству «матчеров», которые помогают проверить различные характеристики браузера, элемента или мока объекта.
10+
11+
Например, можно проверить находится ли браузер на заданной странице
12+
13+
```typescript
14+
await browser.url("https://webdriver.io/");
15+
// ...
16+
await expect(browser).toHaveUrl("https://webdriver.io");
17+
```
18+
19+
или проверить есть ли у элемента атрибут с заданным значением
20+
21+
```typescript
22+
const myInput = await browser.$("input");
23+
await expect(myInput).toHaveAttribute("class", "form-control");
24+
```
25+
26+
или проверить был ли сделан указанный запрос для вашего мока
27+
28+
```typescript
29+
const mock = browser.mock("**/api/todo*");
30+
// ...
31+
await expect(mock).toBeRequested();
32+
```
33+
34+
По умолчанию таймаут на выполнение ассертов равен 2000мс с интервалом проверок в 100мс. Но при необходимости эти значения можно переопределить в [секции system][system_config] в общем конфиге.
35+
36+
```typescript
37+
{
38+
// другие настройки testplane
39+
system: {
40+
expectOpts: {
41+
wait: 5000,
42+
interval: 200,
43+
}
44+
}
45+
}
46+
```
47+
48+
[system_config]: ../../../config/system#expect_opts

0 commit comments

Comments
 (0)