Get the latest tech news
Testing Without Mocks: A Pattern Language (2023)
February 16, 2023 Automated tests are important. Without them, programmers waste a huge amount of time manually checking and fixing their code.
However, if you don’t want test-specific code in production, or if the logic gets complicated, you can use the Object Mother pattern to put it in a test-only helper module instead. Choose one simple output mechanism that your application will use (such as rendering to the console, the DOM, or responding to a network request) and implement a barebones Infrastructure Wrapper for it. That means it can’t talk to a database, communicate across a network, touch the file system, read the date and time, look at environment variables, or use most random number generators.
Or read this on Hacker News