API testing

Return a canned error from a mock

Medium70 pts~25 min
  • Canned responses
  • Error handling
Practice app · Acme REST API

A live REST + GraphQL API with auth, validation, pagination, rate limiting and an interactive request console.

BASE_URL
/api/practice
Console app
/lab/api-testing-return-a-canned-error-from-a-mock

Your starter code already declares BASE_URL — call the API relative to it.

Objective

Trigger the gateway's canned decline and a canned 503 to test your error handling.

Your task

  1. 1POST BASE_URL + "/payments" with { "amount": 49, "cardNumber": "4000000000000002" } → assert 402, status "declined", reason "insufficient_funds".
  2. 2GET BASE_URL + "/status/503" as a stand-in for an unavailable dependency → assert 503.
  3. 3Map both to the error your client should surface.

Acceptance criteria

  • POST /payments returns 402
  • GET /status/503 returns 503
  • At least 3 assertions pass

Fixtures

apiKey
tqa_live_key_123
basicUser
admin
basicPassword
secret
username
qa@target.dev
password
Test@123

API testing · API Testing · Mocking & virtualization