You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(learn): clean up code sample & update/correct time mocking section (#8707)
* feat(learn): clean up code sample & update/correct time mocking section
* fixup!: correct typo
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com>
---------
Signed-off-by: Jacob Smith <3012099+JakobJingleheimer@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
it('should choose "minutes" when that\'s the closest unit', () => {
267
264
constt=ago('1999-12-01T23:59:59Z');
268
265
269
266
assert.equal(t, '2 minutes ago');
270
267
});
271
268
});
272
269
```
273
270
271
+
`ago`**must** be imported dynamically _after_`mock.timers` is enabled. As with all module dependency mocking, this is necessary so that the `ago` module receives the mock before the `ago` module is executed (if the mocking does not occur before, it will be too late).
272
+
274
273
This is especially useful when comparing against a static fixture (that is checked into a repository), such as in [snapshot testing](https://nodejs.org/api/test.html#snapshot-testing).
0 commit comments