-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add info about expect timeout configuration
- Loading branch information
Showing
3 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
sidebar_class_name: hidden | ||
--- | ||
|
||
# Assertion with Expect | ||
|
||
## Overview | ||
|
||
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. | ||
|
||
For example, you can check if the browser is on a specific page | ||
|
||
```typescript | ||
await browser.url("https://webdriver.io/"); | ||
// ... | ||
await expect(browser).toHaveUrl("https://webdriver.io"); | ||
``` | ||
|
||
or check if the element has an attribute with the specified value | ||
|
||
```typescript | ||
const myInput = await browser.$("input"); | ||
await expect(myInput).toHaveAttribute("class", "form-control"); | ||
``` | ||
|
||
or check if the specified request has been made for your mock | ||
|
||
```typescript | ||
const mock = browser.mock("**/api/todo*"); | ||
// ... | ||
await expect(mock).toBeRequested(); | ||
``` | ||
|
||
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. | ||
|
||
```typescript | ||
{ | ||
// another testplane configs | ||
system: { | ||
expectOpts: { | ||
wait: 5000, | ||
interval: 200, | ||
} | ||
} | ||
} | ||
``` | ||
|
||
[system_config]: ../../../config/system#expect_opts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
i18n/ru/docusaurus-plugin-content-docs/current/commands/expect/overview.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
sidebar_class_name: hidden | ||
--- | ||
|
||
# Ассерты с помощью Expect | ||
|
||
## Обзор | ||
|
||
В ходе написания тестов нужно часто удостовериться, что значения отвечают определённым требованиям. С помощью функции expect у вас есть доступ к множеству «матчеров», которые помогают проверить различные характеристики браузера, элемента или мока объекта. | ||
|
||
Например, можно проверить находится ли браузер на заданной странице | ||
|
||
```typescript | ||
await browser.url("https://webdriver.io/"); | ||
// ... | ||
await expect(browser).toHaveUrl("https://webdriver.io"); | ||
``` | ||
|
||
или проверить есть ли у элемента атрибут с заданным значением | ||
|
||
```typescript | ||
const myInput = await browser.$("input"); | ||
await expect(myInput).toHaveAttribute("class", "form-control"); | ||
``` | ||
|
||
или проверить был ли сделан указанный запрос для вашего мока | ||
|
||
```typescript | ||
const mock = browser.mock("**/api/todo*"); | ||
// ... | ||
await expect(mock).toBeRequested(); | ||
``` | ||
|
||
По умолчанию таймаут на выполнение ассертов равен 2000мс с интервалом проверок в 100мс. Но при необходимости эти значения можно переопределить в [секции system][system_config] в общем конфиге. | ||
|
||
```typescript | ||
{ | ||
// другие настройки testplane | ||
system: { | ||
expectOpts: { | ||
wait: 5000, | ||
interval: 200, | ||
} | ||
} | ||
} | ||
``` | ||
|
||
[system_config]: ../../../config/system#expect_opts |