Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Commit

Permalink
fix: report time for skipped tests so that netTime is computed correctly
Browse files Browse the repository at this point in the history
Closes #141
  • Loading branch information
KidkArolis authored and vojtajina committed Apr 12, 2013
1 parent b613c05 commit 4f5470d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,15 @@ var createMochaReporterConstructor = function(tc) {
});

runner.on('test end', function(test) {
var skipped = test.pending === true;

var result = {
id: '',
description: test.title,
suite: [],
success: test.state === 'passed',
skipped: test.pending === true,
time: test.duration,
skipped: skipped,
time: skipped ? 0 : test.duration,
log: test.$errors || []
};

Expand Down
18 changes: 18 additions & 0 deletions test/adapter.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,24 @@ describe('adapter mocha', function() {
});


it('should report time 0 for skipped tests', function () {
spyOn(tc, 'result').andCallFake(function(result) {
expect(result.skipped).toBe(true);
expect(result.time).toBe(0);
});

var mockMochaResult = {
pending: true,
parent: {root: true}
};

runner.emit('test', mockMochaResult);
runner.emit('test end', mockMochaResult);

expect(tc.result).toHaveBeenCalled();
});


it('should report failed result', function() {
spyOn(tc, 'result').andCallFake(function(result) {
expect(result.success).toBe(false);
Expand Down

0 comments on commit 4f5470d

Please sign in to comment.