Get the latest tech news
Test Spies in Haskell
Learn how to spy on function calls in Yesod tests using a stubbed dependency and a bit of mutable state.
Take something like a transactional email: a user signs up, resets their password, or completes a purchase — and your application needs to send a notification. Instead of calling sendEmail directly, you’ll retrieve it from somewhere that can be swapped out at runtime — like your application’s settings. This test swaps in a fake email function, triggers the handler, and checks that the expected recipient was recorded.
Or read this on Hacker News