Execute code after Jasmine test failure

前端 未结 4 541
故里飘歌
故里飘歌 2021-01-12 08:15

Is it possible to do something only if a Jasmine test fails? Juxtaposed with afterEach() which executes after an it() regardless of outcome, I\'m l

4条回答
  •  情深已故
    2021-01-12 08:52

    Here's a hack to re-enable jasmine.getEnv().currentSpec in Jasmine 2 (sort of, result isn't the full spec object, but contains id, description, fullName, failedExpectations, and passedExpectations):

    jasmine.getEnv().addReporter({
        specStarted(result) {
            jasmine.getEnv().currentSpec = result;
        },
        specDone() {
            jasmine.getEnv().currentSpec = null;
        }
    });
    

提交回复
热议问题