A method of a class I have created is supposed to throw an error under certain circumstances. I have the following:
test('calling do() must throw an error', function(assert) {
var anInstance = new SomeClass();
anInstance.do();
/*
at this point the above function throws an error
that appears on my browser's console with a custom
message I am including. What I want to do is verify
that this error was actually thrown and if that is the case,
consider this test a success. i.e. I want something similar to
the below.
*/
assert.errorWasThrownFromWithinInstanceWithMessage('my custom message');
});
I've looked into assert.throws but it looks like it works with Errors created inside the above scope. I want to check for a specific Error that is thrown from within the instance of my Class which is declared elsewhere on a separate file.
Aucun commentaire:
Enregistrer un commentaire