Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Jasmine does not clear scheduledFunctions between mock clock invocations #51

Closed
rslifka opened this Issue Feb 4, 2011 · 3 comments

Comments

Projects
None yet
3 participants

rslifka commented Feb 4, 2011

Hi guys,

We noticed yesterday that between invocation of jasmine.Clock.useMock(), Jasmine does not reset the list of scheduledFunctions. This was the cause of some test pollution for us, where things scheduled in previous tests were still running in later tests.

To see the bug, in useMock(), output the list of scheduledFunctions. You'll see that functions scheduled in previous tests are still pending execution.

We worked around this by adding to our SpecHelper.js:

afterEach(function () {
// Jasmine's mock clock does not remove scheduled functions between specs,
// which allows for test pollution.
jasmine.Clock.defaultFakeTimer.reset();
});

...although the real fix is probably to ensure FakeTimer.reset gets called at each useMock.

Thanks!

Rob

Contributor

infews commented Feb 4, 2011

Yup. That's a bug and it's already in the backlog. Thanks for the note & the workaround.

ngan commented Feb 28, 2013

This bug appears to not have been resolved yet...I'm on version 1.3.1.
Isn't a fix to this just adding a call to reset() in uninstallMock()?

ngan commented Feb 28, 2013

Hm...apparently this bug is fixed on master...
Just curious, is master slated for 2.0? Or are there plans for 1.3.2 anytime soon? Thanks!

This issue was closed.

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