Spec-Zone.ru › Playwright

APIResponseAssertions

The APIResponseAssertions class provides assertion methods that can be used to make assertions about the APIResponse in the tests.

import { test, expect } from '@playwright/test';

test('navigates to login', async ({ page }) => {
  // ...
  const response = await page.request.get('https://playwright.dev');
  await expect(response).toBeOK();
});

Methods​

toBeOK​

Ensures the response status code is within 200..299 range.

Usage

await expect(response).toBeOK();

Returns

  • Promise<void>

Properties​

not​

Makes the assertion check for the opposite condition.

Usage

For example, this code tests that the response status is not successful:

await expect(response).not.toBeOK();

Type

  • APIResponseAssertions

© 2026 Microsoft
Licensed under the Apache License, Version 2.0.
https://playwright.dev/docs/api/class-apiresponseassertions

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API