Closed grug closed 5 years ago
Yeah!
mock.get('/foo', (req, res) => {
if (!req.header('Authorisation')) {
return res.body(JSON.stringify({hello: 'world'}));
} else {
return res.body(JSON.stringify({something: 'else'}));
}
});
Oh, perfect!
I'll give that a go and let you know :)
I know there have been similar issues opened in here but I think this is slightly different (feel free to correct me here)
Is there a way to have multiple mocks for the same endpoint, but the responses are different based on headers
i.e.
a mock of
GET /foo
that responds with{hello: 'world'}
AND
a mock of
GET /foo
with an auth token in the request to respond with{something: 'else'}
Please let me know if my question is not clear enough and I'll provide more details.
Thanks