0

I wrote some tests using jQuery's qUni for some Bacon.js functions i did.
However Bacon.js throws an error and qUnit marks the test as failed but the outcome is correct and the equals() methods work ok.

My question is can i make qUnit ignore a type of error or an error from a source ? The error is something like this :
"Uncaught TypeError: undefined is not a function
Source: ..../static/js/libs/Bacon.js:62"

Thanks

Razvan
  • 710
  • 3
  • 9
  • 25

1 Answers1

1

Without seeing your actual tests it's hard to say exactly how you need to structure the tests, but if the Error being thrown is expected behavior, then you can use QUnit's throws() assertion to make sure that happens as expected:

QUnit.test("this should throw an error...", function(assert) {
    assert.throws(
        function() {
            someFunctionThatThrowsAnError("maybe with a 'bad' arg versus good?");
        },
        /undefined is not a function/, // regex to match, any other Error fails the test
        "Error should be thrown with invalid arguments"
    );
});
Jordan Kasper
  • 13,153
  • 3
  • 36
  • 55