Bird
0
0

You wrote this Pact interaction but the test fails with a syntax error:

medium📝 Debug Q6 of 15
Rest API - API Testing and Monitoring
You wrote this Pact interaction but the test fails with a syntax error:
provider.addInteraction(
  state: 'User exists',
  uponReceiving: 'a request',
  withRequest: { method: 'GET', path: '/user' },
  willRespondWith: { status: 200 }
);

What is the error?
AMissing willRespondWith key
BIncorrect HTTP method name
CMissing curly braces around the interaction object
DExtra comma after last property
Step-by-Step Solution
Solution:
  1. Step 1: Check JavaScript object syntax

    The addInteraction method requires a single object argument enclosed in curly braces.
  2. Step 2: Identify missing braces

    The code passes multiple arguments without wrapping them in an object, causing syntax error.
  3. Final Answer:

    Missing curly braces around the interaction object -> Option C
  4. Quick Check:

    Object argument needs curly braces [OK]
Quick Trick: Wrap interaction details in curly braces for valid object [OK]
Common Mistakes:
MISTAKES
  • Passing multiple arguments instead of one object
  • Using wrong HTTP method casing
  • Leaving out willRespondWith key

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes