Enforce strict three-layer architecture: thin HTTP routes, pure service logic with domain errors, isolated data access with dependency injection.
94
93%
Does it follow best practices?
Impact
97%
1.08xAverage score across 5 eval scenarios
Passed
No known issues
A SaaS platform sends email notifications when users complete certain actions (password reset, subscription renewal, account suspension). The engineering team is trying to increase test coverage but is hitting a wall: the notification service directly imports a SendGrid client module at the top of the file, which means every test that touches notification logic actually tries to send real emails (or fails trying to connect). Similarly, the service imports the user repository directly, requiring a live database connection in tests.
A developer has been asked to refactor the notification service so that it can be fully unit tested without any real email sending or database access. They should also write a small set of unit tests demonstrating that the service works correctly with mocked dependencies.
The notifications being covered are:
sendPasswordReset(userId) — looks up the user, sends a password reset emailsendSubscriptionRenewal(userId, planName) — looks up the user, sends a renewal confirmation emailsuspendAccount(userId, reason) — looks up the user, marks the account suspended in the database, sends a suspension notification emailProduce:
src/services/notificationService.ts — Refactored notification servicesrc/repositories/userRepo.ts — User data access interface and a stub/in-memory implementationsrc/routes/notifications.ts — Thin HTTP handlers for triggering the notifications abovetests/notificationService.test.ts — Unit tests for the three notification methods using mocked dependencies (use any test framework you prefer)wiring.ts — Shows how the service would be constructed with real dependencies for production useThe tests should pass without requiring network access or a real database.
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
skills
separation-of-concerns
verifiers