Skip to content

Commit

Permalink
feat(adapter): add executedExpectationsCount to result
Browse files Browse the repository at this point in the history
This change allow detect tests without expectations in reporter
  • Loading branch information
MilanLempera committed Mar 15, 2016
1 parent 631f42d commit 666c207
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
26 changes: 26 additions & 0 deletions test/adapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 666c207

Please sign in to comment.