【问题标题】:Any way to provide reason to a disabled suite in Jasmine以任何方式为 Jasmine 中的残疾人套房提供理由
【发布时间】:2016-10-13 23:40:27
【问题描述】:

目前,我们可以通过这种方式使用 pend() 函数为待定规范提供理由 -

xit("pending spec", function(){
    //Skipped spec
}).pend("This is a reason");

上述函数的输出将是 -

Sample Test: pending spec
This is a reason
Executed 1 of 1 specs (1 PENDING)

现在,如何获得禁用套件的相同原因?

xdescribe('Disabled suite' , function(){
    it('example spec', function(){
        //example
    });
}).pend("This is a reason");

上述禁用套件的输出是 -

No reason given

即使我使用pend() 函数也保持不变。谢谢!

【问题讨论】:

  • 尚不支持套件上的待处理消息。自己看:github.com/jasmine/jasmine/blob/master/src/core/Suite.js#L45
  • 感谢@FlorentB。我希望能找到某种方法来实现这一点。我知道pend() 不起作用,但我们还有其他方法可以做到吗?如果不添加自定义功能,简单地显示“没有给出理由”是没有意义的。谢谢!

标签: javascript jasmine protractor automated-tests test-suite


【解决方案1】:

未在套件上实现待处理消息,但您可以覆盖 pend 方法以使其在每个规范上写入消息:

jasmine.Suite.prototype.pend = function(message){
    this.markedPending = true;
    this.children.forEach(spec => spec.pend(message));
};

用法:

xdescribe('Suite', function() {


}).pend("Feature not yet implemented");

Suite.js的源代码:

https://github.com/jasmine/jasmine/blob/master/src/core/Suite.js#L45

【讨论】:

  • 酷,我忘了我可以覆盖实现.. 谢谢!
猜你喜欢
  • 2020-06-20
  • 2015-03-05
  • 2023-04-07
  • 1970-01-01
  • 2010-10-04
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多