docs: make toBeOK async, expose in java (#11227)
This commit is contained in:
parent
d49bf00183
commit
d629fe57ab
|
|
@ -1,5 +1,5 @@
|
||||||
# class: APIResponseAssertions
|
# class: APIResponseAssertions
|
||||||
* langs: js
|
* langs: js, java
|
||||||
|
|
||||||
The [APIResponseAssertions] class provides assertion methods that can be used to make assertions about the [APIResponse] in the tests. A new instance of [APIResponseAssertions] is created by calling [`method: PlaywrightAssertions.expectAPIResponse`]:
|
The [APIResponseAssertions] class provides assertion methods that can be used to make assertions about the [APIResponse] in the tests. A new instance of [APIResponseAssertions] is created by calling [`method: PlaywrightAssertions.expectAPIResponse`]:
|
||||||
|
|
||||||
|
|
@ -9,7 +9,7 @@ import { test, expect } from '@playwright/test';
|
||||||
test('navigates to login', async ({ page }) => {
|
test('navigates to login', async ({ page }) => {
|
||||||
// ...
|
// ...
|
||||||
const response = await page.request.get('https://playwright.dev');
|
const response = await page.request.get('https://playwright.dev');
|
||||||
expect(response).toBeOK();
|
await expect(response).toBeOK();
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -35,7 +35,7 @@ from playwright.async_api import Page, expect
|
||||||
async def test_navigates_to_login_page(page: Page) -> None:
|
async def test_navigates_to_login_page(page: Page) -> None:
|
||||||
# ..
|
# ..
|
||||||
response = await page.request.get('https://playwright.dev')
|
response = await page.request.get('https://playwright.dev')
|
||||||
expect(response).to_be_ok()
|
await expect(response).to_be_ok()
|
||||||
```
|
```
|
||||||
|
|
||||||
```python sync
|
```python sync
|
||||||
|
|
@ -56,21 +56,21 @@ def test_navigates_to_login_page(page: Page) -> None:
|
||||||
Makes the assertion check for the opposite condition. For example, this code tests that the response status is not successfull:
|
Makes the assertion check for the opposite condition. For example, this code tests that the response status is not successfull:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
expect(response).not.toBeOK();
|
await expect(response).not.toBeOK();
|
||||||
```
|
```
|
||||||
|
|
||||||
```java
|
```java
|
||||||
assertThat(response).not().isOK();
|
assertThat(response).not().isOK();
|
||||||
```
|
```
|
||||||
|
|
||||||
## method: APIResponseAssertions.toBeOK
|
## async method: APIResponseAssertions.toBeOK
|
||||||
* langs:
|
* langs:
|
||||||
- alias-java: isOK
|
- alias-java: isOK
|
||||||
|
|
||||||
Ensures the response status code is within [200..299) range.
|
Ensures the response status code is within [200..299) range.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
expect(response).toBeOK();
|
await expect(response).toBeOK();
|
||||||
```
|
```
|
||||||
|
|
||||||
```java
|
```java
|
||||||
|
|
@ -82,7 +82,7 @@ import re
|
||||||
from playwright.async_api import expect
|
from playwright.async_api import expect
|
||||||
|
|
||||||
# ...
|
# ...
|
||||||
expect(response).to_be_ok()
|
await expect(response).to_be_ok()
|
||||||
```
|
```
|
||||||
|
|
||||||
```python sync
|
```python sync
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ By default, the timeout for assertions is set to 5 seconds.
|
||||||
```
|
```
|
||||||
|
|
||||||
## method: PlaywrightAssertions.expectAPIResponse
|
## method: PlaywrightAssertions.expectAPIResponse
|
||||||
* langs: js
|
* langs: js, java
|
||||||
- alias-java: assertThat
|
- alias-java: assertThat
|
||||||
- alias-python: expect
|
- alias-python: expect
|
||||||
- alias-js: expect
|
- alias-js: expect
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue