1

I have the test in my node application...

it('will call done', function(done) {
            myObj.fn(function(){

                done();
           }
});

and the code....

myObj.fn = function(success){
   setTimeout(2000000000,success);
}

When I run the test I get this in the output...

-MacBook-Pro:torus-pqdata user$ npm test

> torus-pqdata@0.0.0 test /Stuff/code bases/2015/torus-pqdata
> jasmine-node specs/

However as you can see the unit test just exits without failing but I need it to timeout (I am trying to simulate something hanging). How do I get it to timeout?

Exitos
  • 29,230
  • 38
  • 123
  • 178

1 Answers1

1

Swap the arguments in setTimeout:

myObj.fn = function(success){
    setTimeout(success, 200000000);
}

Here's some reference from MDN: https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout

jojo
  • 1,135
  • 1
  • 15
  • 35