jbrumwell / mock-knex

A mock knex adapter for simulating a database during testing
MIT License
239 stars 71 forks source link

Doc should warn about next tick #99

Open mlarcher opened 4 years ago

mlarcher commented 4 years ago

I've been fiddling around for a few hours trying to figure out why the tracker was never called in my test. I tried reverting knex/mock-knex versions, using different versions of node, shrinking my test to the bare minimum...

Eventually, I realized that the query was never called because I was expecting something in the event listener, while the promise returned by knex was never explicitly resolved. It's weird that both mocha and jest let it happen without any pending promise warning, but that's where the problem lied.

I believe the README should warn users that knex's promise needs to be resolved in order for mock-knex to kick in, in order to prevent other users from doing the same mistake I did. What do you think ?