Re:Mocking Is an Anti-Pattern
by h1fra on Monday June 17, 2024 @12:45PM
(#40707793)
Clearly mocking DB is a footgun and it's not that hard to setup e2e test.
Use TestContainer or Docker on a random port, run your API on a random port.
Every tests seeds all the data needed to run (user, org, token), it requires an initial setup but then you just reuse it everywhere, and voila. No side effects, no mock to maintain, it also test your auth and permissions, almost 1:1 with prod.
Every tests seeds all the data needed to run (user, org, token), it requires an initial setup but then you just reuse it everywhere, and voila. No side effects, no mock to maintain, it also test your auth and permissions, almost 1:1 with prod.