Skip to content

Commit

Permalink
Added regression test to go along with 5b3bb87
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Jun 10, 2015
1 parent 5b3bb87 commit 91a789e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/unexpected.spec.js
Expand Up @@ -3982,6 +3982,30 @@ describe('unexpected', function () {
});
});
});

describe('when the error mode of the assertion changes after the assertion has failed', function () {
it('serializes the error with the error mode that was in effect at the time of its creation', function () {
var clonedExpect = expect.clone().addAssertion('to be equal to foo', function (expect, subject) {
this.errorMode = 'nested';
try {
expect(subject, 'to equal', 'foo');
} catch (e) {
this.errorMode = 'default';
throw e;
}
});

expect(function () {
clonedExpect('bar', 'to be equal to foo');
}, 'to throw',
"expected 'bar' to be equal to foo\n" +
" expected 'bar' to equal 'foo'\n" +
"\n" +
" -bar\n" +
" +foo"
);
});
});
});

it('truncates the stack when a custom assertion throws a regular assertion error', function () {
Expand Down

0 comments on commit 91a789e

Please sign in to comment.