Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add info about expect timeout configuration #51

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
48 changes: 48 additions & 0 deletions docs/commands/expect/overview.mdx
Copy link
Member

Choose a reason for hiding this comment

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

The page is not accessible from the website (https://testplane-ci.website.yandexcloud.net/testplane-docs/website-static/12693202346-209-1/)
You need to link this mdx page

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
4 changes: 4 additions & 0 deletions docs/config/_partials/examples/_system-example.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ export default {
mochaOpts: {
timeout: 60000,
},
expectOpts: {
wait: 3000,
interval: 100,
},
ctx: {
/* ... */
},
Expand Down
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
Loading