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

Jasmine does not clear scheduledFunctions between mock clock invocations #51

Closed
rslifka opened this issue Feb 4, 2011 · 3 comments
Closed
Labels

Comments

@rslifka
Copy link

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

@infews
Copy link
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
Copy link

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
Copy link

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
Labels
Projects
None yet
Development

No branches or pull requests

3 participants