Skip to content
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

sinon.useFakeTimers in acceptance tests break if run.later is used #14722

Closed
Gaurav0 opened this issue Dec 15, 2016 · 11 comments
Closed

sinon.useFakeTimers in acceptance tests break if run.later is used #14722

Gaurav0 opened this issue Dec 15, 2016 · 11 comments

Comments

@Gaurav0
Copy link
Contributor

Gaurav0 commented Dec 15, 2016

You can use sinon.useFakeTimers in an acceptance test, or you can use run.later in your application, but doing both causes the acceptance test to time out.

Reproduction: https://ember-twiddle.com/d5f34d97be1e75b8258e654f6a482d70?openFiles=tests.acceptance.my-acceptance-test.js%2C

@Gaurav0
Copy link
Contributor Author

Gaurav0 commented Dec 15, 2016

I think the issue is in Backburner.

@morhook
Copy link
Contributor

morhook commented Dec 15, 2016

I think the problem is that sinon.useFakeTimers() is modifying the environment (the timers of the VM JS, as kind-of-everything depends on setTimeout).

You can put a lot of clock.tick(0); to let run the normal async mechanisms of the acceptance utilities (like visit(xx), andThen, etc).

p.s.: I've fixed your twiddle hard-coding a little bit https://ember-twiddle.com/d5f34d97be1e75b8258e654f6a482d70?openFiles=tests.acceptance.my-acceptance-test.js%2C

@morhook
Copy link
Contributor

morhook commented Dec 15, 2016

p.s.2: I've fixed your twiddle, taking out the 'Date' parameter in sinon.useFakeTimers() https://ember-twiddle.com/f2c762d2bdcb25e7329827bf92c91c68?openFiles=tests.acceptance.my-acceptance-test.js%2C

@stefanpenner
Copy link
Member

believe this has been addressed: BackburnerJS/backburner.js#179 (although that was merged yesterday) and it still needs to make its way into ember.

@Gaurav0
Copy link
Contributor Author

Gaurav0 commented Dec 15, 2016

@morhook Not putting a Date in sinon.useFakeTimers() kind of defeats the point, the use case is so that Date.now() returns a predictable value, allowing acceptance tests that use the Date to pass regardless of what date it is.

@pixelhandler
Copy link
Contributor

@stefanpenner so does this need a PR for the Backburner update?

@pittst3r
Copy link
Contributor

pittst3r commented Dec 17, 2016

@pixelhandler I'd be happy to make a follow-up PR in Ember if necessary.

@morhook
Copy link
Contributor

morhook commented Dec 19, 2016

@Gaurav0 sounds fair! Thanks for explaining it to me.

@rwjblue
Copy link
Member

rwjblue commented Jul 4, 2017

Discussed with @Turbo87 and we believe this is resolved.

@rwjblue rwjblue closed this as completed Jul 4, 2017
@Turbo87
Copy link
Member

Turbo87 commented Jul 4, 2017

yes, https://github.com/BackburnerJS/backburner.js/pull/179/files resolved it and has found its way into one of the recent Ember releases, though I can't say which one specifically fixed it.

@vcipriani
Copy link

Just fyi for anyone running into this problem, it looks like the Backburner fix is not included in Ember 2.14. It looks like it is shipping in 2.15.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants