Hi I´m trying to make a unit test creating some fake data and executing a request (using supertest) to check if the controller works well. The problem rise up when the controller tries to get the fake data, because it exists only inside the transaction.
So my questions are:
Thanks in advance.
If I'm understanding you correctly, you are trying to run a bunch of api calls with some fake data, but you are unable to actually get the data from database?
If that's the case, one of two things I would suggest:
Allow your api to update the db, then retrieve from db. When your tests are done, you can do the full clean up at that point (that can be achieve via the after()
in mocha)
Use sinon.js
, and stub all db calls to return some fake data that you know.