-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
I have a scenario where I am setting up expectations to call an external service twice (mocking that in my tests using mock-https-server), one which returns an empty array and one that returns a response.
something like this:
expectGetResourceByParamX (queryParams, statusCode, body) {
this.server.on({
method: 'GET',
path: '/v1/resource',
filter: (req) => {
// filter code
return true
},
reply: {
status: statusCode,
headers: { 'content-type': 'application/json' },
body: JSON.stringify(body)
}
})
}
expectGetResourceByParamY (queryParams, statusCode, body) {
this.server.on({
method: 'GET',
path: '/v1/resource',
filter: (req) => {
// filter code
return true
},
reply: {
status: statusCode,
headers: { 'content-type': 'application/json' },
body: JSON.stringify(body)
}
})
}
The only difference is what query params I use on that same exact path, however when setting up the test this seems to cause an issue since the handlers have the same path and the requests that come in are processed by the wrong handler. I looked at the library code but can't see an obvious place where this can be fixed.
Any ideas on how this sort of problem can be solved (if it can be) using this library or is this some sort of limitation of the library.
Thank You.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels