Skip to main content
Version: 1.18


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 playwrightAssertions.expect(response):

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

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


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

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


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

await expect(response).toBeOK();