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

prioritize newer mock handlers #453

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dwickern
Copy link

@dwickern dwickern commented Nov 3, 2021

When there are multiple mocks for the same request, we should prioritize the newer one. For example, you might set up some mocks for all tests in beforeEach, and then override it for a specific test. Currently the first mock would be used.

Besides that, we should put a higher priority to mocks with a filter, regardless of their declaration order. Here's what I came up with:

  1. prioritize mocks using match() to match the request body
  2. prioritize mocks using withParams() to match exact query params
  3. prioritize mocks using withSomeParams() to match partial query params
  4. otherwise, prioritize by reverse declaration order

@patocallaghan
Copy link
Collaborator

Hey @dwickern, this is an interesting idea. I'd be happy to chat more about it. This would be a breaking change so I wonder if we should try and get some feedback from other users of the framework.

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

Successfully merging this pull request may close these issues.

2 participants