Source code

Revision control

Copy as Markdown

Other Tools

function assertThrownErrorContains(thunk, substr) {
try {
thunk();
} catch (e) {
if (e.message.indexOf(substr) !== -1)
return;
throw new Error("Expected error containing " + substr + ", got " + e);
}
throw new Error("Expected error containing " + substr + ", no exception thrown");
}