From 5abc7457cd73a4a4ba70b3c9ceeadac6d42bbd76 Mon Sep 17 00:00:00 2001 From: Julie Ralph Date: Mon, 8 Feb 2016 23:39:21 -0800 Subject: [PATCH] chore(jasmine): update MatchFactory to allow message as function --- index.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index e37287a..d22198a 100644 --- a/index.js +++ b/index.js @@ -192,7 +192,7 @@ jasmine.Expectation.prototype.wrapCompare = function(name, matcherFactory) { var result = matcherCompare.apply(null, args); return webdriver.promise.when(result.pass).then(function(pass) { - var message = ""; + var message = ''; if (!pass) { if (!result.message) { @@ -200,7 +200,11 @@ jasmine.Expectation.prototype.wrapCompare = function(name, matcherFactory) { args.unshift(name); message = expectation.util.buildFailureMessage.apply(null, args); } else { - message = result.message; + if (Object.prototype.toString.apply(result.message) === '[object Function]') { + message = result.message(); + } else { + message = result.message; + } } }