62

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失敗し た場合はsubmit element should be clicked1スキップする必要があります

編集:私はちょうど私のテストを間違っているようです、質問を削除する前にしばらく待ちます

編集:

私がコメントで答えたように-私はすでにモカグーグルグループでこの答えを受け取りました、しかし私が質問に言及していない他のいくつかの制限があります-私はgrunt-simple-mochaを使用していますそして私がコードを調べたので-私がオプションをmochaコンストラクターに渡す

コマンドラインからのオプションがSuiteインスタンスに渡される場所を見つけることができませんでした、そしてそれが私が見るようにそれがあるかもしれない唯一の行は

suite.bail(this.bail());

私には奇妙に見えます

私はmochagithubページで問題を開くと思います、多分彼らは後で保釈設定で渡されたオプションを拡張するでしょう、あるいは私が間違ったことと他の方法で私の問題を解決する方法を私に説明するだけです

編集:そして今、https://github.com/visionmedia/mocha/commit/f0b441ceef4998e570a794dcff951bf2330eb0c5によると、 最新のモカにはボックスからの保釈オプションがあります。著者に感謝します!

4

1 に答える 1

130

Mocha は、最初のテスト失敗後の保釈をサポートしていますが、それはあなたが望むものですか?

からmocha --help:

-b, --bail                      bail after first test failure
于 2012-12-19T19:43:12.667 に答える