Skip to content

Factor in the request body when mocking a response #426

@dustinlessard-wf

Description

@dustinlessard-wf

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);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions