DocumentationTest AuthoringAPI contract testing

API contract testing

6 min readLast updated 2026-04-29New

Validate API responses against OpenAPI schemas using Playwright request fixtures.

API contract testing ensures your frontend and backend stay in sync. Check Studio integrates with Playwright request fixtures to validate responses against OpenAPI specs.

Setup

  1. 1Export your OpenAPI spec to openapi.json in the project root
  2. 2Install the contract testing add-on: npm install -D @checkstudio/contract-testing
  3. 3Add the fixture to your test config

Writing a contract test

test('GET /users returns valid response', async ({ request, contract }) => {
  const response = await request.get('/api/users');
  await contract.validate(response, { schema: 'UserList' });
  expect(response.status()).toBe(200);
});
typescript

Breaking change detection

When a contract test fails, Check Studio alerts the team and links to the diff between the expected schema and the actual response.

Was this article helpful?

Still have questions?

Our support team is here to help. Reach out directly or search the docs.