Skip to content
This repository has been archived by the owner on Sep 21, 2022. It is now read-only.

Commit

Permalink
fix: bug with count of failed tests in the statistic
Browse files Browse the repository at this point in the history
  • Loading branch information
rostik404 committed Jun 6, 2017
1 parent 212a02e commit ef550c5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 25 deletions.
4 changes: 0 additions & 4 deletions doc/programmatic-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ Returns promise that resolve to a stats object with following keys:

* `skipped` — number of skipped tests.

* `errored` — number of errored tests.

Rejects promise if critical error occurred.

## Running tests
Expand Down Expand Up @@ -197,8 +195,6 @@ Returns promise that resolve to a stats object with following keys:

* `skipped` — number of skipped tests.

* `errored` — number of errored tests.

* `passed` — number of passed tests.

* `failed` — number of failed tests.
Expand Down
7 changes: 1 addition & 6 deletions lib/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,7 @@ function runGemini(method, paths, options) {
new: options.new
});
})
.then((stats) => {
if (stats.failed > 0 || stats.errored > 0) {
return 2;
}
return 0;
})
.then((stats) => stats.failed > 0 ? 2 : 0)
.catch(handleErrors)
.then(exit);
}
Expand Down
3 changes: 1 addition & 2 deletions lib/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const STATS = {
updated: 'updated',
passed: 'passed',
failed: 'failed',
errored: 'errored',
skipped: 'skipped',
warned: 'warned',
retries: 'retries'
Expand All @@ -27,7 +26,7 @@ module.exports = class Stats {
runner
.on(RunnerEvents.SKIP_STATE, (test) => this._addStat(STATS.skipped, test))
.on(RunnerEvents.WARNING, (test) => this._addStat(STATS.warned, test))
.on(RunnerEvents.ERROR, (test) => this._addStat(STATS.errored, test))
.on(RunnerEvents.ERROR, (test) => this._addStat(STATS.failed, test))
.on(RunnerEvents.UPDATE_RESULT, (test) => {
return test.updated ? this._addStat(STATS.updated, test) : this._addStat(STATS.passed, test);
})
Expand Down
25 changes: 12 additions & 13 deletions test/unit/stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@ describe('Stats', () => {
assert.equal(stats.getResult().warned, 1);
});

it('should count errored tests', () => {
runner.emit(RunnerEvents.ERROR, makeStateResult());

assert.equal(stats.getResult().errored, 1);
});

it('should count updated tests', () => {
runner.emit(RunnerEvents.UPDATE_RESULT, makeStateResult({updated: true}));

Expand All @@ -45,6 +39,12 @@ describe('Stats', () => {
assert.equal(stats.getResult().passed, 1);
});

it('should count failed tests on "ERROR" event', () => {
runner.emit(RunnerEvents.ERROR, makeStateResult());

assert.equal(stats.getResult().failed, 1);
});

it('should count failed tests on "TEST_RESULT" event', () => {
runner.emit(RunnerEvents.TEST_RESULT, makeStateResult({equal: false}));

Expand Down Expand Up @@ -79,7 +79,7 @@ describe('Stats', () => {
assert.equal(stats.getResult().total, 2);
});

it('should getResult full stat', () => {
it('should return correct full statistic', () => {
runner.emit(RunnerEvents.UPDATE_RESULT, makeStateResult({updated: true, name: 'updated'}));
runner.emit(RunnerEvents.RETRY, makeStateResult({name: 'passed'}));
runner.emit(RunnerEvents.TEST_RESULT, makeStateResult({equal: true, name: 'passed'}));
Expand All @@ -92,8 +92,7 @@ describe('Stats', () => {
total: 6,
updated: 1,
passed: 1,
failed: 1,
errored: 1,
failed: 2,
skipped: 1,
warned: 1,
retries: 1
Expand All @@ -105,7 +104,7 @@ describe('Stats', () => {
runner.emit(RunnerEvents.ERROR, makeStateResult({name: 'some-state'}));

assert.equal(stats.getResult().skipped, 0);
assert.equal(stats.getResult().errored, 1);
assert.equal(stats.getResult().failed, 1);
});

it('should not count test result twice for same state and browser', () => {
Expand All @@ -118,10 +117,10 @@ describe('Stats', () => {
runner.emit(RunnerEvents.ERROR, test);

assert.equal(stats.getResult().total, 1);
assert.equal(stats.getResult().errored, 1);
assert.equal(stats.getResult().failed, 1);
});

it('should create suite key by suite full name and suite browser id divided by space', () => {
it('should correctly handle tests with the similar titles', () => {
const test1 = makeStateResult({
suite: {fullName: 'some case'},
browserId: 'bro'
Expand All @@ -135,6 +134,6 @@ describe('Stats', () => {
runner.emit(RunnerEvents.ERROR, test2);

assert.equal(stats.getResult().total, 2);
assert.equal(stats.getResult().errored, 2);
assert.equal(stats.getResult().failed, 2);
});
});

0 comments on commit ef550c5

Please sign in to comment.