playwright-test-commons - v0.8.0
    Preparing search index...

    Function validateJsonSchema

    • Asserts (soft) that a body matches its schema, and that every date-like field holds a valid date. The failure lists every mismatch, one line each, e.g. body.items[0].price: must be number, got "12.50" or body: unexpected field "extra".

      For a new endpoint, run once with { update: true } (or UPDATE_SCHEMAS=true for a whole run) to generate the schema from the real response. Review it, commit it, then remove the flag: left on, it rewrites the schema from every response and hides real changes.

      Parameters

      Returns Promise<void>

      Error if the schema file doesn't exist or can't be read

      const body = await getBody(await Posts.list());
      await validateJsonSchema("posts/listPosts", body);