Complete the code to define a Pact consumer test with the correct provider name.
const pact = new Pact({ consumer: 'UserService', provider: '[1]' });The provider name must be the service that the consumer depends on. Here, 'OrderService' is the provider for 'UserService'.
Complete the code to specify the HTTP method in the Pact interaction.
pact.addInteraction({ uponReceiving: 'a request for order details', withRequest: { method: '[1]', path: '/orders/123' }, willRespondWith: { status: 200 } });The HTTP method for retrieving data is GET, which matches the request for order details.
Fix the error in the Pact interaction to correctly specify the expected response status code.
pact.addInteraction({ uponReceiving: 'a request for payment status', withRequest: { method: 'GET', path: '/payments/456' }, willRespondWith: { status: [1] } });The expected response for a successful GET request is status code 200 (OK).
Fill both blanks to define the expected JSON response body with correct keys and values.
willRespondWith: { status: 200, body: { orderId: [1], status: '[2]' } }The orderId should be a number like 123, and the status string should be 'confirmed' to indicate the order state.
Fill all three blanks to create a Pact test that verifies the provider and writes the pact file.
pact.setup().then(() => pact.verify()).then(() => pact.[1]()).then(() => pact.[2]()).catch(e => console.error(e)); // After tests pact.[3]();
After verification, the pact file is written with writePact(), finalized with finalize(), and resources cleaned up with cleanup().