Missing information in documentation about shouldAdvanceTime
See original GitHub issue- FakeTimers version : 6.0.1
I am using fake-timers for some time now and I wanted to utilize the shouldAdvanceTime
option.
But I did not get it to work from the start.
This was my install code;
const installFakeClock = (): void => {
(window as any).fakeClock = install({
now: new Date(),
toFake: ['setTimeout', 'clearTimeout'],
shouldAdvanceTime: true,
});
};
According to the documentation, this should work. Set shouldAdvanceTime
to true and it will use the default time delta of 20ms. However, it would not work. The fake timer was not advancing automatically.
I had to look through the source to see that it actually also expects setInterval
and clearInterval
to be faked too.
I’m not sure why the advanceTime needs set and clearInterval to be faked too, but it was not expected.
If it is needed, could you change the documentation to reflect that the setInterval
and clearInterval
are needed for this option to work?
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
"Modern" fake-timer implementation doesn't work with ... - GitHub
Testing async code with Promises, as described in this Jest doc, doesn't seem to work with jest.useFakeTimers('modern'); (from #7776; documented ...
Read more >Sinon useFakeTimers() creates a timeout in before/afterEach
Mystery solved. It appears to be a conflict between Sinon and versions of Knex > 0.7.6. Seems to be because pool2 relies on...
Read more >@sinonjs/fake-timers | Yarn - Package Manager
Important: This documentation covers modern versions of Yarn. For 1.x docs, see classic.yarnpkg.com.
Read more >webdriverio/webdriverio - Gitter
Hello everyone. I'm currently having a problem with the autocompletion with the browser methods (as well as not recognizing them whenver I Ctrl+click...
Read more >Fake-timers: Fake SetTimeout, Friends (collectively Known As ...
var FakeTimers = require("@sinonjs/fake-timers"); var clock = FakeTimers.install({ shouldAdvanceTime: true, advanceTimeDelta: 40, }); setTimeout(() ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@fatso83 Thanks for looking into it and creating a PR in such short time.
Did not hear back, but this should make the actual implementation be in line with the docs, so no doc update needed 😄