As the title says, how would I achieve this? Say for example, I have this backend api which will eventually query the atlas freetier cluster when it’s deployed to production. This query uses $search to be able to execute full text search on “products” collection. My TDD environment is set up with mongodb in-memory server. This in-memory server doesn’t recognize $search operator.
I’m currently mocking/stubbing the result from the query that I executed manually from MongodbCompass. The process is like, execute the query and check the result. If it’s the one I was expecting then, copy and paste the query to the backend code and use the result as stub.
It doesn’'t seem to be too bad for now but what if db configuration changes, then I’ll always have to replace the stub with latest result from actual db query. I don’t feel like stubbing the result is a good idea.
Unit testing to compare the actual result with what I’m expecting while I already know the result? hmm it’s almost like doing nothing.
The only way I came up with is just connect to dev db on atlas. I was wondering if there’s other way or right way to achieve what I want without using actual cloud db. I prefer in-memory server cause obviously it’s fast and light.