I'm writing a test for my custom requirejs loader. On malformed input it it supposed to throw an error.
I'm using mocha
and plain node-assert
to test it like this:
it('throws a SyntaxError on malformed input', function(done){
assert.throws(function(){ requirejs(['myLoader!malformedInput'], Function.prototype) }, SyntaxError);
done();
});
The test fails due to:
AssertionError: Missing expected exception (SyntaxError)..
From what I understand reading the docs on assert my syntax should be ok. The error message is a little hard to understand too.
My best guess would be that this is due to the fact that the requirejs
call is async, but then I don't know when to call done
in this scenario?
Or am I misunderstanding something in the way that requirejs
will handle the error that I pass to onload.error(e)
?