我找不到一种方法,如果其中一个失败了,如何阻止it
的某些部分运行
我使用的是mocha-as-promised
,所以代码看起来可能和所有代码都不一样
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
次失败
编辑:
EDIT:
正如我在 comments 中回答的那样——我已经在mocha google Group中收到了这个答案,但还有一些我没有提到的限制——我使用grunt simple mocha,并且我判断了代码——当我将选项传递给mocha constructor时,没有保释选项
我没有找到命令行中的选项被传递到Suite实例的位置,我看到的唯一一行可能是
suite.bail(this.bail());
这对我来说很奇怪
我想我会在mocha github页面上讨论这个问题,也许他们会在稍后通过保释设置来扩展已通过的选项,或者只是解释我做错了什么,以及如何以其他方式解决我的问题
EDIT: and now, according to 100 latest Mocha have bail option from the box. Thanks to authors!