ExpertPW-MOCK-00660 minutesPlaywright

Validate a controlled contract variation

A response can be syntactically valid JSON while failing the published catalogue-item contract.

  • network-mocking
  • api
  • assertions

Objective

What to automate

Fulfil the request with an item missing name and price, then assert the controlled contract-mismatch outcome and learner retry.

Preconditions and test data

Preconditions

  • Use a fresh isolated Practice Lab browser context.
  • Open the fixture identified by FX-MOCK-001.

Test data

  • body: {"data":[{"id":"mock-invalid"}]}
  • expected status: CONTRACT_MISMATCH

Expected result

The fixture reports CONTRACT_MISMATCH, leaves invalid data out of the response table, and enables Retry request.

Progressive hints

Hint 1

Keep the JSON syntactically valid so the contract validator runs.

Hint 2

Omit a required visible item field such as name or price.

Hint 3

Assert the labelled contract outcome and the explicit retry boundary.

I’ve tried it — show solution
  1. Keep the JSON syntactically valid so the contract validator runs.
  2. Omit a required visible item field such as name or price.
  3. Assert the labelled contract outcome and the explicit retry boundary.

The deliberately failing starter is in tests/network-mocking.spec.ts inside the TypeScript starter ZIP.