Laura Cabantous
08/08/2022, 11:20 AMwith 30000 ms timeout for Pact. I've tried to increase the timeout (quite significantly but it still fails with the same message).
Is there any way to check why it times out? It seems due to a promise that doesn't resolve...
Also it seems to be specifically when looking to get the provider to respond with status 400 ๐ค
Code snippet in ๐งตLaura Cabantous
08/08/2022, 11:24 AMit('should return an error when an invalid UPRN is passed', async () => {
await provider.addInteraction({
uponReceiving: 'an invalid UPRN',
withRequest: {
method: 'GET',
path: '/property/m1xf%d5/sales'
},
willRespondWith: {
status: 400,
headers: default_headers,
body: {
error: 'BadRequest',
message: 'Invalid UPRN format',
statusCode: 400
}
}
});
process.env.API_PROPERTY_TRANSACTIONS_URL =
provider.mockService.baseUrl;
const response = await api().transactionalHistoryByUprn('m1xf%d5');
expect(response).toThrow('400: Bad Request');
});Laura Cabantous
08/08/2022, 11:24 AMMatt (pactflow.io / pact-js / pact-go)
const response = await api().transactionalHistoryByUprn('m1xf%d5'); <- throws
expect(response).toThrow('400: Bad Request'); <- to late, already thrown!Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
expect(() => {
throw Error();
}).toThrow();Matt (pactflow.io / pact-js / pact-go)
expect(() => api().transactionalHistoryByUprn('m1xf%d5')).toThrow('400: Bad Request');Matt (pactflow.io / pact-js / pact-go)
toThrow docs. You might be able to just hand it a promise. But you are await ing the promise, so that will always throw before the expectYousaf Nabi (pactflow.io)
Laura Cabantous
08/08/2022, 12:32 PMMatt (pactflow.io / pact-js / pact-go)