在jasmine或mocha中声明“待定”规范/测试

时间:2012-07-17 08:21:06

标签: jasmine mocha

我想描述应该在代码中的规范,但稍后会添加它们的实现。在测试结果中,我希望看到它们既没有通过也没有失败,而是“正在等待”实现。

我很有兴趣是否可以在摩卡或茉莉花中开箱即用。

由于

3 个答案:

答案 0 :(得分:57)

您可以使用xit(而不是it)和xdescribe(而不是描述)在mocha和jasmine中声明已禁用的功能。

如果您希望测试显示为挂起,则在mocha中,您可以在调用it()函数时将第二个参数留空。例如:

describe('Something', function () {
    it('Should be pending')
    xit('Should be disabled, i.e not appear on the list')
});

更新:如果发生此合并,则{MOO} / xit的行为可能会在Mocha中发生变化:https://github.com/visionmedia/mocha/pull/510

答案 1 :(得分:20)

从Jasmine 2.0开始,为规范编写xit()而不是it()会将其标记为待处理(正如已接受答案的评论中所述)。

另外,您可以在规范中的任何位置调用pending()函数将其标记为待处理:

it("can be declared by calling 'pending' in the spec body", function() {
  expect(true).toBe(false);
  pending();
});

另请参阅documentation on pending specs in Jasmine 2.0

答案 2 :(得分:15)

在mocha中,您还可以使用skip

describe('my module', function() {
  it.skip('works', function() {
    // nothing yet
  });
});

您也可以describe.skip跳过整个部分。

相关问题