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

feat(tests) Add request matchers to MockApiClient #29910

Merged
merged 4 commits into from
Nov 12, 2021

Conversation

markstory
Copy link
Member

A while back we added predicate to mocked responses. However, we generally only match against query string parameters and or request data. These changes add a match option to mock definitions and two higher level methods for matching query data and request payloads. This interface is based on how request matching is done in responses.

I've updated a subset of our tests to show how the new methods work in comparison to predicate. If folks are happy with these changes I can update the other tests and remove predicate as well.

A while back we added `predicate` to mocked responses. However, we
generally only match against query string parameters and or request
data. These changes add a `match` option to mock definitions and two
higher level methods for matching query data and request payloads. This
interface is based on how request matching is done in `responses`.

I've updated a subset of our tests to show how the new methods work in
comparison to `predicate`. If folks are happy with these changes I can
update the other tests and remove predicate as well.

return matchesURL && matchesMethod && matchesPredicate;
let matchersMatch = true;
response.match.forEach(matcher => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
response.match.forEach(matcher => {
const matchersMatch = response.match.every(matcher => matcher(url, options));

@markstory markstory merged commit d6007de into master Nov 12, 2021
@markstory markstory deleted the feat-improve-mock-matchers branch November 12, 2021 15:16
@github-actions github-actions bot locked and limited conversation to collaborators Nov 28, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants