Post

Problem: Some interfaces like dates, times, localStorage, the URL, and the file system are “globals” that may change at any time. This makes it difficult to set up complex edge cases and hampers testing. Solution: Instead of coding against these APIs directly, wrap access in an interface.

Result: Now we can code and test against a mocked implementation in non-prod environments. The mocked implementation can be deterministic and fast, and thus allow quickly testing our business logic against many scenarios. In prod, the wrapper implementation merely forwards to the real APIs.

0 reposts2 likes