Skip to content

Commit

Permalink
Test that custom matchers can supply custom errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Jared Deckard committed Mar 24, 2017
1 parent c42b197 commit 25d9a39
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions spec/core/ExpectationSpec.js
Expand Up @@ -384,6 +384,42 @@ describe("Expectation", function() {
message: "I'm a custom message"
});
});

it("reports a custom error message to the spec", function() {
var customError = new Error("I am a custom error");
var matchers = {
toFoo: function() {
return {
compare: function() {
return {
pass: false,
message: "I am a custom message",
error: customError
};
}
};
}
},
addExpectationResult = jasmine.createSpy("addExpectationResult"),
expectation;

expectation = new jasmineUnderTest.Expectation({
actual: "an actual",
customMatchers: matchers,
addExpectationResult: addExpectationResult
});

expectation.toFoo("hello");

expect(addExpectationResult).toHaveBeenCalledWith(false, {
matcherName: "toFoo",
passed: false,
expected: "hello",
actual: "an actual",
message: "I am a custom message",
error: customError
});
});

});

0 comments on commit 25d9a39

Please sign in to comment.