从规格跳过后续摩卡试验如果失败(Skip subsequent Mocha tests from s

2019-07-05 23:29发布

我不能找到一种方法如何停止的某些部分it ,如果他们中的一个失败的运行距离

我使用的是mocha-as-promised ,所以代码看起来可能是usuall不同

describe("remote promises", function() {
  describe("browsing", function() {
    describe("getting page", function() {
      it("should navigate to test page and check title", function() {
        this.timeout(TIMEOUT);
        return browser.get("http://admc.io/wd/test-pages/guinea-pig.html").then(function() {
          return browser.title();
        }).then(function(title) {
          return assert.ok(~title.indexOf("I am a page title - Sauce Labs"), "Wrong title!");
        });
      })
      it("submit element should be clicked1", function() {
        this.timeout(TIMEOUT);
        return browser.elementById("submit").then(function(el) {
          return browser.clickElement(el);
        }).then(function() {
            return browser["eval"]("window.location.href");
          }).then(function(location) {
            assert.ok(~location.indexOf("http://"), "Wrong location!");
          });
      })
    });
    describe("clicking submit", function() {
      it("submit element should be clicked2", function() {
        this.timeout(TIMEOUT);
        return browser.elementById("submit").then(function(el) {
          return browser.clickElement(el);
        }).then(function() {
            return browser["eval"]("window.location.href");
          }).then(function(location) {
            assert.ok(~location.indexOf("http://"), "Wrong location!");
          });
      });
    });

  });
});

我想,如果should navigate to test page and check title失败,则submit element should be clicked1应该跳过

编辑:看来我只是把我的测试中出错,会等待一段时间删除问题之前,

编辑:

正如我在评论说 - 我已经接受了摩卡谷歌群体这个答案,但也有问题,我没有提到的一些其他限制 - 我使用的咕噜,简单摩卡和我检查代码 - 没有保释选项时,我选项传递给摩卡构造

我没能找到其中的命令行选项都传递给套件实例,而唯一的线,其中可能因为我看到它是一个

suite.bail(this.bail());

这看起来奇怪,我

我想我会在摩卡github上的网页打开的问题,也许他们会后延长保释设置选项传递,或者只是给我解释一下我做错了什么,我怎么能解决我的其他方式的问题

编辑:现在,根据https://github.com/visionmedia/mocha/commit/f0b441ceef4998e570a794dcff951bf2330eb0c5最新的摩卡具有从盒子保释选项。 感谢作者!

Answer 1:

摩卡支持第一次测试失败后想逃,是你想要的吗?

mocha --help

-b, --bail                      bail after first test failure


文章来源: Skip subsequent Mocha tests from spec if one fails