Hi guys, good morning :sunglasses::wave:; I'm new ...
# general
s
Hi guys, good morning 😎👋; I'm new to testing with PACT, is there any way to get the response of the calls to the APIs after the provider side verification was done? my code is as follows
Copy code
describe("Validate pact of identity", () => {

    it("Validate pact of identity creation", () => {
        let opts = {
            providerBaseUrl: baseUrl.BASE_URL,
            changeOrigin: true,
            provider: "Create identity",
            logLevel: "DEBUG",
            pactUrls: [
                path.resolve(
                    process.cwd(),
                    `./__tests__/contract/pacts/${identity_data.nameConsumerPactFile}-${identity_data.nameProviderPactFile}.json`
                ),
            ],
            requestFilter: async (req, res, next) => {

               

                req.headers["authorization"] = "Bearer UQiQPSG-MtD3mNHG0JZT2mqfBh1",
                    next()
            },
            consumerVersionTags: ["QA"],
            providerVersionTags: ["QA"],
            publishVerificationResult: false,
            providerVersion: "1.0.0"
        }

        return new Verifier(opts).verifyProvider()
            .then((res) => {
                console.log('-------> here I need to get the response <-------', res);
            }).catch((res) => {
                console.log('Pact Verification FAIL!: Get identity ', res);
            });
    })

})
y
Hey @Sebastian Suarez, Try setting the
logLevel
to
trace
See this PR for context . Hope that helps 🤞
Ahh that doesn't appear to work, the code is in place in pact-js, but from what I can see pact-js's exported Verifier, calls pact-node, which in turn calls the pact-provider-verifier, which doesn't support the trace method and fails here
pact-node@10.17.1: Created '/Users/saf/dev/pactoss/jest-pact-typescript/node_modules/@pact-foundation/pact-node/standalone/darwin-1.88.81/pact/bin/pact-provider-verifier'
https://github.com/pact-foundation/pact-provider-verifier/blob/7d52ff479e9ba982db49b9e120f4c876a515de97/lib/pact/provider_verifier/cli/verify.rb#L118
Copy code
[2022-03-09 17:30:14.098 +0000] WARN (31571 on Yousafs-MacBook-Pro.local): pact-node@10.17.1: Pact exited with code 1.
Error: Invalid log level 'trace'. Must be one of: debug, info, warn, error, fatal.

    at ChildProcess.<anonymous> (/Users/saf/dev/pactoss/jest-pact-typescript/node_modules/@pact-foundation/pact-node/src/verifier.ts:275:58)
s
Hi @Yousaf Nabi (pactflow.io) ) thanks for answering 😎, I want to contextualize my need a little more; the API that I am calling generates a guid that I need to capture in order to delete the data it generates (if I don't delete it, it could cause problems later); I don't know if there is any way to capture the response after of the validation of pact to later remove it with a hook 🤔
y
Ahh brilliant, thanks for the additional context. I dug a little more into the code here and it seems if you do set 'debug' now request/response logging will be provided. We are currently capturing them, but not storing them, just outputting to the logs (as
trace
) which isn't being set, so those refs probably want changing to
debug
as well. It wouldn't be too hard to store the req/responses in an object and return them. Would welcome a PR 😎 otherwise feel free to raise a feature request via the GitHub issues on https://github.com/pact-foundation/pact-js or via our public roadmap https://pact.canny.io/
s
Thank you so much for you help 🙌 @Yousaf Nabi (pactflow.io), I already have created the issue in the repo https://github.com/pact-foundation/pact-js/issues/836