TestRelic

API Test Reports

What does a TestRelic API test report contain, and how do I analyze request/response data, assertions, and failures?

API test reports use the same JSON structure as browser reports. When you run tests using testRelicApiFixture, test results, request/response data, assertions, and failure diagnostics are written to the same report file.

What does a report contain?

  • Test results — pass/fail/flaky/skipped status and duration for every test
  • Request & response data — HTTP method, URL, headers, bodies, status, and timing for each API call
  • Assertionsexpect() results, captured when you import the assertion-aware expect from TestRelic
  • Cookies — structured request/response cookies, captured with values masked
  • Failure diagnostics — error messages, source snippets, and optional stack traces
  • CI metadata — auto-detected CI provider details

API workspace inspector

Importing the assertion-aware expect from @testrelic/playwright-analytics/api-fixture (or .../fixture) routes request/response data and assertions to the TestRelic cloud's API workspace inspector. A run opens the API workspace when every test in it is an API test — tagged @api, under an api/ path, in a dedicated API project, or using the API request fixture. Mixed UI + API runs are not reclassified.

Report schema

Same top-level structure as all TestRelic reports (see Browser Reports) — for API tests, timeline entries reflect the test file and results rather than page navigations.

A failed API assertion looks like:

{
  "failure": {
    "message": "expect(received).toBe(expected)\n\nExpected: 200\nReceived: 404",
    "snippet": {
      "file": "tests/api/posts.spec.ts",
      "line": 15,
      "lines": [
        "  const response = await request.get('/api/posts/999');",
        ">>> expect(response.status()).toBe(200);"
      ]
    }
  }
}

Analyzing reports

AI Prompt — Analyze an API test report
Read my TestRelic API report at test-results/analytics-timeline.json and:
1. Print the test summary (total, passed, failed)
2. List all failed tests with their error messages
3. List the 5 slowest tests by duration
Write a Node.js script that does all of this.

Asserting on response time

test('API response time', async ({ request }) => {
  const start = Date.now();
  const response = await request.get('/api/endpoint');
  const duration = Date.now() - start;

  expect(response.status()).toBe(200);
  expect(duration).toBeLessThan(1000);
});

CI integration

Terminal
FAILED=$(jq '.summary.failed' test-results/analytics-timeline.json)
if [ "$FAILED" -gt 0 ]; then
  echo "API tests failed: $FAILED"
  exit 1
fi

Next steps

Was this page helpful?

On this page