Skip to content

Commit 606c23e

Browse files
authored
Merge pull request #51 from gemini-testing/sp.addExpectConfig
docs: add info about expect timeout configuration
2 parents adc46d1 + d202e7d commit 606c23e

File tree

4 files changed

+123
-1
lines changed

4 files changed

+123
-1
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

sidebars.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,29 @@ const sidebars: SidebarsConfig = {
1616
{
1717
type: "category",
1818
label: "Commands",
19-
items: [{ type: "autogenerated", dirName: "commands" }],
19+
items: [
20+
{
21+
type: "category",
22+
label: "browser",
23+
items: [{ type: "autogenerated", dirName: "commands/browser" }],
24+
},
25+
{
26+
type: "category",
27+
label: "element",
28+
items: [{ type: "autogenerated", dirName: "commands/element" }],
29+
},
30+
{
31+
type: "category",
32+
label: "expect",
33+
items: [{ type: "autogenerated", dirName: "commands/expect" }],
34+
link: { type: "doc", id: "commands/expect/overview" },
35+
},
36+
{
37+
type: "category",
38+
label: "mock",
39+
items: [{ type: "autogenerated", dirName: "commands/mock" }],
40+
},
41+
],
2042
link: { type: "doc", id: "commands/overview" },
2143
},
2244
{

0 commit comments

Comments
 (0)