Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom error message of Matcher #272

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/jasmine-core/jasmine.js
Expand Up @@ -516,8 +516,8 @@ if (isCommonJS) exports.xit = xit;
*
* @param {Object} actual Actual value to test against and expected value
*/
var expect = function(actual) {
return jasmine.getEnv().currentSpec.expect(actual);
var expect = function(actual, message, notMessage) {
return jasmine.getEnv().currentSpec.expect(actual, message, notMessage);
};
if (isCommonJS) exports.expect = expect;

Expand Down Expand Up @@ -2204,9 +2204,15 @@ jasmine.Spec.prototype.addMatcherResult = function(result) {
this.results_.addResult(result);
};

jasmine.Spec.prototype.expect = function(actual) {
jasmine.Spec.prototype.expect = function(actual, message, notMessage) {
var positive = new (this.getMatchersClass_())(this.env, actual, this);
positive.not = new (this.getMatchersClass_())(this.env, actual, this, true);
if (message) {
positive.message = function(){return message};;
}
if (notMessage) {
positive.not.message = function(){return notMessage};;
}
return positive;
};

Expand Down