Skip to content Skip to sidebar Skip to footer

Testing If JS Method Throws RangeError With QUnit

I made some Javascript unit tests with QUnit library, then I want to test if method throws RangeError. It has be done in this way: QUnit.test('Resolve slide animation from left', f

Solution 1:

I found an answer on my own. Instead calling function:

assert.throws(myOwnCreator.resolveAnimationType("slideSide", "hide"), 
  new RangeError()....

I should pass to assert.throws() function which call my function, like this:

assert.throws(function(){
    myOwnCreator.resolveAnimationType("slideSide", "hide");
  }, 
  new RangeError(--message which function should throw in error--)...

Post a Comment for "Testing If JS Method Throws RangeError With QUnit"