Skip to content

Latest commit

 

History

History
170 lines (144 loc) · 8.33 KB

File metadata and controls

170 lines (144 loc) · 8.33 KB
id class-apiresponseassertions
title APIResponseAssertions

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import HTMLCard from '@site/src/components/HTMLCard';

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 {#api-response-assertions-to-be-ok}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.18apiResponseAssertions.toBeOK

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

Usage

await expect(response).toBeOK();

Returns


Properties

not {#api-response-assertions-not}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.20apiResponseAssertions.not

Makes the assertion check for the opposite condition. For example, this code tests that the response status is not successful:

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

Usage

expect(response).not

Type