Skip to content

Instantly share code, notes, and snippets.

@wolframkriesing
Created February 22, 2016 23:33
Show Gist options
  • Save wolframkriesing/fa5bfd16e45af3cf5757 to your computer and use it in GitHub Desktop.
Save wolframkriesing/fa5bfd16e45af3cf5757 to your computer and use it in GitHub Desktop.
import assert from 'assert';
import {assertThat, instanceOf, throws} from 'hamjest';
class MyError extends Error {
constructor(...args) {
super(...args);
}
}
function throwingFunction() {
throw new MyError();
}
describe('catch my error', () => {
it('finds error', () => {
assertThat(throwingFunction, throws(instanceOf(MyError)));
});
});
@rluba
Copy link

rluba commented Feb 23, 2016

Must be the ES6 class syntax. Seems like new MyError() instanceOf MyError is falsy — odd.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment