docs(python): enable Python response assertions (#11609)

This commit is contained in:
Max Schmitt 2022-01-25 18:53:49 +01:00 committed by GitHub
parent 3c27badd31
commit a13f71d328
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View file

@ -1,5 +1,5 @@
# class: APIResponseAssertions # class: APIResponseAssertions
* langs: js, java * langs: js, java, python
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`]:
@ -29,7 +29,6 @@ public class TestPage {
``` ```
```python async ```python async
import re
from playwright.async_api import Page, expect 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:
@ -39,7 +38,6 @@ async def test_navigates_to_login_page(page: Page) -> None:
``` ```
```python sync ```python sync
import re
from playwright.sync_api import Page, expect from playwright.sync_api import Page, expect
def test_navigates_to_login_page(page: Page) -> None: def test_navigates_to_login_page(page: Page) -> None:
@ -63,6 +61,11 @@ await expect(response).not.toBeOK();
assertThat(response).not().isOK(); assertThat(response).not().isOK();
``` ```
## async method: APIResponseAssertions.NotToBeOK
* langs: python
The opposite of [`method: APIResponseAssertions.toBeOK`].
## async method: APIResponseAssertions.toBeOK ## async method: APIResponseAssertions.toBeOK
* langs: * langs:
- alias-java: isOK - alias-java: isOK
@ -78,7 +81,6 @@ assertThat(response).isOK();
``` ```
```python async ```python async
import re
from playwright.async_api import expect from playwright.async_api import expect
# ... # ...

View file

@ -55,7 +55,7 @@ reached. You can pass this timeout as an option.
By default, the timeout for assertions is set to 5 seconds. By default, the timeout for assertions is set to 5 seconds.
## method: PlaywrightAssertions.expectAPIResponse ## method: PlaywrightAssertions.expectAPIResponse
* langs: js, java * langs: js, java, python
- alias-java: assertThat - alias-java: assertThat
- alias-python: expect - alias-python: expect
- alias-js: expect - alias-js: expect