ember-data-factory-guy icon indicating copy to clipboard operation
ember-data-factory-guy copied to clipboard

prioritize newer mock handlers

Open dwickern opened this issue 2 years ago • 1 comments

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

dwickern avatar Nov 03 '21 18:11 dwickern

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.

patocallaghan avatar Nov 15 '21 14:11 patocallaghan