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

Mocking the JavaScript Timeout Functions in IE 8 with Jasmine 2.0.0 #41

Closed
Wraul opened this issue Jul 25, 2014 · 1 comment · Fixed by #54
Closed

Mocking the JavaScript Timeout Functions in IE 8 with Jasmine 2.0.0 #41

Wraul opened this issue Jul 25, 2014 · 1 comment · Fixed by #54

Comments

@Wraul
Copy link

Wraul commented Jul 25, 2014

Hi

I'm having issues using Jasmines clock mock with Karma.
I have reported the issue to Jasmine here but since the issue is only present with Karma I report it here instead.

The following test does not work with Karma in IE 8.

describe('Clock', function() {
    beforeEach(function() {
        jasmine.clock().install();
    });

    afterEach(function() {
        jasmine.clock().uninstall();
    });

    it('works in IE 8', function() {
        var test = jasmine.createSpy('timeout');
        setTimeout(test, 1000);
        jasmine.clock().tick(1000);
        expect(test).toHaveBeenCalled();
    });
});

It works with Jasmines SpecRunner.html.

I have done some experimenting and I can break Jasmines clock mock in IE 8 by calling setTimeout() before the first use of the mock.

@maksimr
Copy link
Contributor

maksimr commented Oct 30, 2014

@Wraul I think this is strange behavior of IE8

If you put in your test window.setTimeout(test, 1000) instead setTimout(test, 100) all will work.

SevInf pushed a commit to SevInf/karma-jasmine that referenced this issue Oct 31, 2014
See http://www.adequatelygood.com/Replacing-setTimeout-Globally.html
for description of the problems and solutions.
Jasmine's boot.js already has this hack.

Fix karma-runner#41
SevInf pushed a commit to SevInf/karma-jasmine that referenced this issue Oct 31, 2014
See http://www.adequatelygood.com/Replacing-setTimeout-Globally.html
for description of the problems and solutions.
Jasmine's boot.js already has this hack.

Closes karma-runner#41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants