如果一个失败,跳过后续的摩卡testing
如果其中一个失败,我无法find一个办法来阻止it
的一部分运行
我正在使用mocha-as-promised
promise,所以代码看起来可能与使用不同
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
跳过
编辑:似乎我只是让我的testing错误,将等待一段时间才删除问题
编辑:
正如我回答评论 – 我已经收到摩卡谷歌组的答案,但也有一些其他的限制,我没有提到的问题 – 我使用grunt-simple-mocha和当我检查的代码 – 有没有保释选项,当我将选项传递给摩卡构造函数
我没有find从命令行选项传递到套件实例,唯一的行,可能是因为我看到它是
suite.bail(this.bail());
这对我来说很奇怪
我想我会在mocha github页面上打开问题,也许他们会延长通过选项与保释设置稍后,或者只是解释我什么我做错了,我怎么能以其他方式解决我的问题
编辑:现在,根据https://github.com/visionmedia/mocha/commit/f0b441ceef4998e570a794dcff951bf2330eb0c5最新摩卡有保释从框中选项。 感谢作者!
摩卡在第一次testing失败后支持bailing,那是你想要的吗?
从mocha --help
:
-b, --bail bail after first test failure