-
-
Notifications
You must be signed in to change notification settings - Fork 705
Closed
Description
import { expect } from "chai";
class Exception {}
describe("chai", () => {
it("should handle thrown object", () => {
expect(()=> {
throw new Exception();
}).to.throw(Exception);
});
});
- chai
should handle thrown object:
AssertionError: expected [Function] to throw 'Exception' but {} was thrown
currently have to wrap as follows:
import { expect } from "chai";
class SentinelNoError {}
const sentinelNoError = new SentinelNoError();
function returnCatch(fn: ()=>void): any {
try {
fn();
return sentinelNoError;
} catch(error) {
return error;
}
}
class Exception {}
describe("chai", () => {
it("should handle thrown object", () => {
expect(returnCatch(()=> {
throw new Exception();
})).to.be.instanceof(Exception);
});
});
Metadata
Metadata
Assignees
Labels
No labels