115
rated 0 times
[
116]
[
1]
/ answers: 1 / hits: 36077
/ 6 Years ago, fri, february 9, 2018, 12:00:00
I have a function which throws an object, how can I assert that the correct object is thrown in jest?
it('should throw', () => {
const errorObj = {
myError: {
name: 'myError',
desc: 'myDescription'
}
};
const fn = () => {
throw errorObj;
}
expect(() => fn()).toThrowError(errorObj);
});
https://repl.it/repls/FrayedViolentBoa
More From » reactjs