gpt4 book ai didi

javascript - 以任何方式为 Jasmine 中的残疾人套房提供理由

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:13:48 25 4
gpt4 key购买 nike

目前,我们可以通过这种方式使用 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() 函数也保持不变。谢谢!

最佳答案

挂起消息未在套件中实现,但您可以覆盖 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

关于javascript - 以任何方式为 Jasmine 中的残疾人套房提供理由,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37791690/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com