Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Factor in the request body when mocking a response #426

Open
dustinlessard-wf opened this issue Apr 19, 2024 · 0 comments
Open

Factor in the request body when mocking a response #426

dustinlessard-wf opened this issue Apr 19, 2024 · 0 comments

Comments

@dustinlessard-wf
Copy link

Sometimes multiple requests are only differentiated by the request body, as is often the case with GraphQL queries. When unit-testing code that makes such requests, we often want to provide a different response, depending on the request body OR a pattern within the body.

Currently, we can get close with something like this:
MockTransports.http.expect('GET', myUri, respondWith: myResponse);

Ideally, we could do something like this:
MockTransports.http.expect('GET', myUri, body: myBody, respondWith: myResponse);
Or,
`MockTransports.http.expectPattern('GET', myUriPattern, bodyPattern: myBodyPattern, respondWith: myResponse);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant