Huy Luong
09/11/2024, 6:13 PMWhat I need help with is there a way to "spy" on the actual outgoing request url? I already verified the following:
• My Pact generated the "URL" from the local json file that gets created as a result of running the pact tests. I passed this in the pactUrls object
• I passed in the correct "base url" in the providerBaseUrl object e.g. <https://api.mytestpacturl.com>
• within the requestFilter hook, i was able to log out the req.url which seems correct e.g. /myTestEndpoint/123
◦ i'd expect the complete request url to be ``https://api.mytestpacturl.com/myTestEndpoint/123``
Despite the correct logs, it looks like the actual endpoint under the hood might send something different? I got a 404 error back my endpoint.
here's my code:
test("my test pact complies with the contract", async () => {
const pactUrls = await glob("pacts/*-mytest.json");
const verifier = new Verifier({
// omitted the beforeEach hook since I do not think it is relevant to the question here
failIfNoPactsFound: true,
providerBaseUrl: '<https://api.mytestpacturl.com>',
pactUrls,
requestFilter: (req, res, next) => {
console.log("req.url ", req.url); // logs out /myTestEndpoint/123
next();
},
});
await verifier.verifyProvider();
});Matt (pactflow.io / pact-js / pact-go)
404 it means your provider doesn’t know how to respond to the requestHuy Luong
09/12/2024, 1:10 PMpath from the pactUrls (pact generated json file), and constructed it with what I gave in the providerBaseUrl and made requests in postman and got back successful responses from the endpoint. But when I run the actual test which should use the correct parameters, i got back a 404 which is why I was wondering if there's a hook or something to spy to intercept the actual requests url that goes out to the real world @Matt (pactflow.io / pact-js / pact-go)Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Huy Luong
09/13/2024, 7:20 PMMatt (pactflow.io / pact-js / pact-go)
Huy Luong
09/16/2024, 1:24 PMMatt (pactflow.io / pact-js / pact-go)