I'm seeing an issue where in my code I have an async functional test which calls our api at a certain route which is just an async call that works fine
const response = await callOurApp(
req,
stuff
);
but then later down in the FT I am calling another endpoint from another service like so but this fails with TypeError: Cannot read property 'then' of undefined
const newQuery = await getNewStuff(req);
does it have to do with the way the promise is handled in the function since this function is also calling another service? or is there something I need to do in Jest to allow this behavior in my FT?
here is the function below.... this function is calling the request method for another service which we make an instance of when we are running our api
export async function getNewStuff(req) {
const payload = {
method: 'GET',
path: '/path/to/the/resource',
headers: {'stuff'},
};
req.log('debug', 'GET_PAYMENT_TOKEN_REQ_PAYLOAD', {
result: JSON.stringify(payload),
});
return theService.request(req, payload).then(result => {
return result;
});
}