From 666c20730d3a5bf2e27794a9176187967e66239f Mon Sep 17 00:00:00 2001 From: Milan Lempera Date: Mon, 14 Mar 2016 12:35:30 +0100 Subject: [PATCH] feat(adapter): add executedExpectationsCount to result This change allow detect tests without expectations in reporter --- src/adapter.js | 3 ++- test/adapter.spec.js | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/adapter.js b/src/adapter.js index 7bd18ee..6cb3366 100644 --- a/src/adapter.js +++ b/src/adapter.js @@ -230,7 +230,8 @@ function KarmaReporter(tc, jasmineEnv) { skipped : skipped, success : specResult.failedExpectations.length === 0, suite : [], - time : skipped ? 0 : new Date().getTime() - specResult.startTime + time : skipped ? 0 : new Date().getTime() - specResult.startTime, + executedExpectationsCount : specResult.failedExpectations.length + specResult.passedExpectations.length }; // generate ordered list of (nested) suite names diff --git a/test/adapter.spec.js b/test/adapter.spec.js index 51f9b26..2790a25 100644 --- a/test/adapter.spec.js +++ b/test/adapter.spec.js @@ -96,13 +96,39 @@ describe('jasmine adapter', function(){ }); + it('should report executedExpectCount 0 if no expectations', function(){ + karma.result.and.callFake(function(result){ + expect(result.executedExpectationsCount).toBe(0); + }); + + reporter.specDone(spec.result); + + expect(karma.result).toHaveBeenCalled(); + }); + + it('should report fail result', function(){ karma.result.and.callFake(function(result){ expect(result.success).toBe(false); expect(result.log.length).toBe(1); + expect(result.executedExpectationsCount).toBe(1); + }); + + spec.result.failedExpectations.push( {} ); + reporter.specDone(spec.result); + + expect(karma.result).toHaveBeenCalled(); + }); + + + it('should report executedExpectCount as sum of passed and failed expectations', function(){ + karma.result.and.callFake(function(result){ + expect(result.executedExpectationsCount).toBe(2); }); + spec.result.passedExpectations.push( {} ); spec.result.failedExpectations.push( {} ); + reporter.specDone(spec.result); expect(karma.result).toHaveBeenCalled();