-
-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Factory method to create delay implementation with bound timer methods #39
Comments
Sure |
This breaks using sinon.useFakeTimers(), as setTimeout and cancelTimeout are captured before sinon can stub them out. |
That's kinda the point of this feature. It should only be used though when you're actively trying to avoid stubbing. |
You can't not use this feature, is the problem, because the default version
of delay also uses the factory method.
…On Fri, Jun 7, 2019, 1:51 AM Mark Wubben ***@***.***> wrote:
This breaks using sinon.useFakeTimers(), as setTimeout and cancelTimeout
are captured before sinon can stub them out.
That's kinda the point of this feature. It should only be used though when
you're actively trying to avoid stubbing.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#39?email_source=notifications&email_token=ACHRSKENM4NBY24SCMSASHLPZIOQXA5CNFSM4FU5OCD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXFHWEQ#issuecomment-499809042>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACHRSKCUU7KNVZKYQAOBN6LPZIOQXANCNFSM4FU5OCDQ>
.
|
No it should use the global methods by default. |
It grabs the value of setTimeout and clearTimeout once when the module is
loaded, so it doesn't notice if you replace their values from the test
harness.
…On Fri, Jun 7, 2019 at 2:02 AM Mark Wubben ***@***.***> wrote:
No it should use the global methods by default.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#39?email_source=notifications&email_token=ACHRSKER3KFT6MURWPCIPE3PZIPY7A5CNFSM4FU5OCD2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXFIPKA#issuecomment-499812264>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACHRSKH3LGMLTZYDPYFPNX3PZIPY7ANCNFSM4FU5OCDQ>
.
|
Ah of course, thanks for pointing that out! Yea that's not what I intended. Probably best to open a new issue for that. I'm sure @sindresorhus would appreciate a PR as well if you have some thoughts on how to fix this. |
It'd be useful if I could do the following:
Since this binds the implementation to the timer methods I've provided, I can then safely stub the timers using say
lolex
and still use thedelay
interface.The text was updated successfully, but these errors were encountered: