arunoda / laika

testing framework for meteor
http://arunoda.github.io/laika/
MIT License
242 stars 38 forks source link

setTimeout doesn't seem to work #59

Open ramseydsilva opened 11 years ago

ramseydsilva commented 11 years ago

I try to delay emitting events in my tests, something like this:

        client.eval(function() {
            Meteor.logout();
            Router.go("profile");
            setTimeout(function() {
                emit('checkUrl', {
                    current_path: Router.current().path,
                    expected_path: Router.path("home")
                });
            }, 5000);
        });

        client.on('checkUrl', function(dict) {
            assert.equal(dict.current_path, dict.expected_path);
            done();
        });

However it doesn't wait 5 minutes to emit. The test output shows it took about 1200ms and I get the undesired result for that test (as a result of not delaying the event).

I also tried using Meteor.setTimeout but the same issue.

krstffr commented 10 years ago

+1

It only works on the server as far as I'm concerned.

arunoda commented 10 years ago

This is an issue with evaluating setTimeout inside PhantomJS. Seems like there is a hack to fix it. Give it a try: https://github.com/ariya/phantomjs/issues/10832#issuecomment-30869416

apendua commented 10 years ago

@arunoda Do you think we could implement this patch into laika?