isaacs / node-lru-cache

A fast cache that automatically deletes the least recently used items
http://isaacs.github.io/node-lru-cache/
ISC License
5.39k stars 353 forks source link

Testing with clock-mock #218

Closed eugene1g closed 2 years ago

eugene1g commented 2 years ago

Hi,

I saw you recently carved out the "time travel" test utility into its own library, clock-mock. Good idea as it's useful on its own. It's small & simple and perfectly suits your needs. I recently had the same need and ended up choosing @sinonjs/fake-timers - just thought I'd mention it here in case you hadn't seen it and don't want to maintain your own take on the problem.

Not suggesting you should migrate, or knocking clock-mock :) Feel free to close this.

isaacs commented 2 years ago

Ah yeah, it's started as like a 20 line throwaway, then kept growing, then I wanted to use it in multiple tests without copypasta.

mock-clock was taken and didn't look maintained, so I took clock-mock 😂

I'll take a look at the sinon one, maybe one less thing to care about.

isaacs commented 2 years ago

I'm gonna close this because I just don't feel like changing tests that are working, but I appreciate the heads up, and will check out the @sinonjs/fake-timers module next time I need time traveling. It looks to be a bit more comprehensive.