Let's say I have a function that throws an exception:
hello() {
throw "exception of world";
}
I want to test it, so I am writing a test:
test("function hello should throw exception", () {
expect(()=>hello(), throwsA("exception of world"));
});
You can see that I did not call hello()directly, I use instead ()=>hello().
This works, but I wonder if there is another way to write tests for it?
source
share