Bird
0
0

Given this Pact interaction, what will be the expected response status code?

medium📝 Predict Output Q4 of 15
Rest API - API Testing and Monitoring
Given this Pact interaction, what will be the expected response status code?
provider.addInteraction({
  state: 'User exists',
  uponReceiving: 'a GET request for user',
  withRequest: { method: 'GET', path: '/user/123' },
  willRespondWith: { status: 200, body: { id: 123, name: 'Alice' } }
});
A200
B404
C500
D400
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the willRespondWith object

    The willRespondWith key defines the response the provider will send, including status 200.
  2. Step 2: Match status code to expected response

    The status code 200 means success, so the expected response status is 200.
  3. Final Answer:

    200 -> Option A
  4. Quick Check:

    Response status = 200 [OK]
Quick Trick: Check willRespondWith.status for expected response code [OK]
Common Mistakes:
MISTAKES
  • Confusing request method with response status
  • Assuming 404 if user ID is in path
  • Ignoring the willRespondWith status field

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes