Abdurahman Hijazi
08/19/2022, 11:36 AMYousaf Nabi (pactflow.io)
In our JS consumer we add a timeout in our http requestWhat do you mean exactly by this? HTTP clients tend to have a default timeout value, do you mean you have modified this to be something different than the default? Test frameworks normally have the ability to set timeouts, which test framework are you referring to?
Abdurahman Hijazi
08/19/2022, 1:54 PMconst response = await fetchRequest(
this.resolveUri(config.SSO_TOKEN_PATH),
{
method: "POST",
headers: {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
},
body: createFormBody(reqBody),
timeout: config.API_DEFAULT_TIMEOUT,
}
);
config.API_DEFAULT_TIMEOUT is set to 60000 . When I leave that timeout in, the pact test doesn't workAbdurahman Hijazi
08/19/2022, 1:55 PMYousaf Nabi (pactflow.io)
Abdurahman Hijazi
08/19/2022, 2:38 PMYousaf Nabi (pactflow.io)
Turns out I understood this timeout thing wrong, basically the timeout property specifies the time that the request must be completed in before being terminated.Correct
I don't know why this would effect the pact test though. When the property is not there the pact test works and passes, and when it is there the pact test failsIf you can share your test code, it would help, otherwise its hard to guess
Yousaf Nabi (pactflow.io)
Abdurahman Hijazi
08/19/2022, 2:40 PMYousaf Nabi (pactflow.io)
If you're trying to demonstrate a problem or diagnose a bug, the best possible thing you can do is provide a minimal reproducible example that doesn't contain any organisational confidential information.
Slackbot
08/19/2022, 2:43 PMAbdurahman Hijazi
08/19/2022, 2:44 PMmockProvider.addInteraction({
state: "",
uponReceiving: "",
withRequest: {
method: "POST",
path: "/token",
headers: {
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
},
body: request,
},
willRespondWith: {
status: 200,
headers: {
"Content-Type": "application/json; charset=UTF-8",
},
body: like(response),
},
});
const expectedToken= jwtBody
const actualToken = await retrieveToken(session);
// Assert - did we get the expected response
assert.deepStrictEqual(
actualIdToken,
expectedIdToken
);Abdurahman Hijazi
08/19/2022, 2:44 PMYousaf Nabi (pactflow.io)
Abdurahman Hijazi
08/19/2022, 2:47 PMYousaf Nabi (pactflow.io)
Yousaf Nabi (pactflow.io)
config.API_DEFAULT_TIMEOUTAbdurahman Hijazi
08/19/2022, 2:50 PMretrieveToken imports the config file and makes the HTTP request from there, the one I sent earlierTimothy Jones
08/19/2022, 3:15 PMTimothy Jones
08/19/2022, 3:16 PMI’ve looked at the logs, the request is matched, and the response is sent back, but when i console log the response it’s nullIf this is the case, then I expect the bug is in the calling code, not pact.
Timothy Jones
08/19/2022, 3:19 PMfetchRequest (and several other functions and variables). If you can’t compile the snippets on their own, neither can we.Timothy Jones
08/19/2022, 3:20 PMIf I leave the timeout the pact test fails because of an “After each hook” error.What is the error? This doesn’t sound like it is coming from pact. What after each hooks are you using?
Timothy Jones
08/19/2022, 3:21 PMAbdurahman Hijazi
08/19/2022, 3:42 PM"@pact-foundation/pact": "^10.1.1"
After each error message:
2) Pact Tests
"after each" hook for "user is authenticated, and sends a valid body":
Error: Error in native callback
at Object.mockServerMismatches (node_modules\@pact-foundation\pact-core\src\consumer\index.ts:94:13)
at Pact.verify (node_modules\@pact-foundation\src\httpPact\index.ts:202:39)
at Context.<anonymous> (tests\contract\contractTesting.spec.js:20:32)
at processImmediate (node:internal/timers:466:21)Abdurahman Hijazi
08/19/2022, 3:48 PMTimothy Jones
08/19/2022, 11:12 PMAbdurahman Hijazi
08/22/2022, 10:21 AMAbdurahman Hijazi
08/22/2022, 10:22 AMYousaf Nabi (pactflow.io)