3 ms·
Jest has pretty robust time mocking, it's a breeze to do time related testing if you're writing JS/TS: https://jestjs.io/docs/jest-object#fake-timers https://je
by p1necone 3y ago
Jest has pretty robust time mocking, it's a breeze to do time related testing if you're writing JS/TS: https://jestjs.io/docs/jest-object#fake-timers https://jestjs.io/docs/jest-object#fake-timers
- theamk 3y agothis blogpost is specific for C++ -- in most dynamic languages like Python or JS, the default approach is to redefine time functions from standard libraries. This would correspond to option 3 in the blog post, except instead of clock factory you redefine individual methods.
- s4i 3y agoA big blind spot in Jest (and I assume in Vitest although I have no experience) are the timezones. It’s very tricky to run the tests in other TZ’s than what Node has been started with.