0

I have a service that uses the findByIdAndUpdate (which uses findOneAndUpdate under the hood), which I need to test.

The problem is that as far as I can tell, the finderMock function that I pass to the toReturn method get called with just the query, which contains the id but neither the options nor the update objects.

However, to properly test my service's method, I need access to those, since I need to check that the options are correct and that the request is actually trying to update what it should.
Looking at the query object and query.getQuery(), I don't see anyway to access those objects.

Is there any way to access them ? If not, is there any way to properly test the findAndUpdate type methods ?

ethanfar
  • 3,733
  • 24
  • 43
  • Could you provide a short code sample illustrating your usecase? – fwoelffel May 01 '19 at 16:36
  • I already got an answer from the author that it's not supported, and since he immediately closed my issue without labeling it as feature request, I gather that he has no intention of adding the support. I found myself replacing the library with my own mocking utility. – ethanfar May 04 '19 at 18:38

0 Answers0