Jasmine/Protractor: stop test on failure in beforeEach

前端 未结 4 1379
梦谈多话
梦谈多话 2021-02-15 08:18

I am currently writing tests protractor and I was wondering if there is some possibility to cancel test execution as soon as something in the beforeEach fails (and return some u

4条回答
  •  日久生厌
    2021-02-15 09:02

    jasmine.Env.prototype.bailFast = function() {
      var env = this;
      env.afterEach(function() {
        if (!this.results().passed()) {
          env.specFilter = function(spec) {
            return false;
          };
        }
      });
    };
    

    then just call:

    jasmine.getEnv().bailFast();
    

    (credit goes to hurrymaplelad who wrote an npm that does just that, however you don't need to use it)

提交回复
热议问题