I'd like to have my unit tests assert that a particular function call throws an AssertionError specifically when expected, rather than that it throws an exception at all. The assertion library (expect) supports such a thing by passing an exception constructor in, but I can't seem to find where, if anywhere, the AssertionError constructor is exported. Is it intended to be an internal class only and not exposed to us? The docs contain numerous references to it, but no links.
I have a super hacky way:
let AssertionError;
try {
const assert = require("assert");
assert.fail();
}
catch (ex) {
AssertionError = ex.constructor;
}
but I'm hoping there's a better way.