jasmine:如何显示匹配器的成功消息

时间:2016-09-09 15:41:50

标签: jasmine jasmine-node

例如,我有以下规范:

 it('All set should pass', function(){
     expect(string1).myMatcherCheckIfEquil(string2);
     expect(string2).myMatcherCheckIfContain(string3);
     expect(num1).myMatcherCheckIfTrue(true);
 })

假设我的所有匹配器都有通过和失败的消息,例如:

  exports.matchers = {
        myMatcherCheckIfEquil: function () { 

            return {
                  compare: function (actual, expected) {
                   var result = { pass: actual == expected }
                   !result.pass ? result.message = "The string " + expected + ' does not equal to ' + actual : result.message = "The strings are equal";
                    return result;           

           }
     }
},  

是否可以在命令行中打印passe和失败的消息,如下例所示:

Spec started
F
  All set should pass:
      The strings are equal
      string2 does NOT contain string3
      The num1 is true

提前致谢。

0 个答案:

没有答案