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

Commit ef550c5

Browse files
committed
fix: bug with count of failed tests in the statistic
1 parent 212a02e commit ef550c5

File tree

4 files changed

+14
-25
lines changed

4 files changed

+14
-25
lines changed

doc/programmatic-api.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,6 @@ Returns promise that resolve to a stats object with following keys:
164164

165165
* `skipped` — number of skipped tests.
166166

167-
* `errored` — number of errored tests.
168-
169167
Rejects promise if critical error occurred.
170168

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

198196
* `skipped` — number of skipped tests.
199197

200-
* `errored` — number of errored tests.
201-
202198
* `passed` — number of passed tests.
203199

204200
* `failed` — number of failed tests.

lib/cli/index.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,7 @@ function runGemini(method, paths, options) {
113113
new: options.new
114114
});
115115
})
116-
.then((stats) => {
117-
if (stats.failed > 0 || stats.errored > 0) {
118-
return 2;
119-
}
120-
return 0;
121-
})
116+
.then((stats) => stats.failed > 0 ? 2 : 0)
122117
.catch(handleErrors)
123118
.then(exit);
124119
}

lib/stats.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ const STATS = {
88
updated: 'updated',
99
passed: 'passed',
1010
failed: 'failed',
11-
errored: 'errored',
1211
skipped: 'skipped',
1312
warned: 'warned',
1413
retries: 'retries'
@@ -27,7 +26,7 @@ module.exports = class Stats {
2726
runner
2827
.on(RunnerEvents.SKIP_STATE, (test) => this._addStat(STATS.skipped, test))
2928
.on(RunnerEvents.WARNING, (test) => this._addStat(STATS.warned, test))
30-
.on(RunnerEvents.ERROR, (test) => this._addStat(STATS.errored, test))
29+
.on(RunnerEvents.ERROR, (test) => this._addStat(STATS.failed, test))
3130
.on(RunnerEvents.UPDATE_RESULT, (test) => {
3231
return test.updated ? this._addStat(STATS.updated, test) : this._addStat(STATS.passed, test);
3332
})

test/unit/stats.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ describe('Stats', () => {
2727
assert.equal(stats.getResult().warned, 1);
2828
});
2929

30-
it('should count errored tests', () => {
31-
runner.emit(RunnerEvents.ERROR, makeStateResult());
32-
33-
assert.equal(stats.getResult().errored, 1);
34-
});
35-
3630
it('should count updated tests', () => {
3731
runner.emit(RunnerEvents.UPDATE_RESULT, makeStateResult({updated: true}));
3832

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

42+
it('should count failed tests on "ERROR" event', () => {
43+
runner.emit(RunnerEvents.ERROR, makeStateResult());
44+
45+
assert.equal(stats.getResult().failed, 1);
46+
});
47+
4848
it('should count failed tests on "TEST_RESULT" event', () => {
4949
runner.emit(RunnerEvents.TEST_RESULT, makeStateResult({equal: false}));
5050

@@ -79,7 +79,7 @@ describe('Stats', () => {
7979
assert.equal(stats.getResult().total, 2);
8080
});
8181

82-
it('should getResult full stat', () => {
82+
it('should return correct full statistic', () => {
8383
runner.emit(RunnerEvents.UPDATE_RESULT, makeStateResult({updated: true, name: 'updated'}));
8484
runner.emit(RunnerEvents.RETRY, makeStateResult({name: 'passed'}));
8585
runner.emit(RunnerEvents.TEST_RESULT, makeStateResult({equal: true, name: 'passed'}));
@@ -92,8 +92,7 @@ describe('Stats', () => {
9292
total: 6,
9393
updated: 1,
9494
passed: 1,
95-
failed: 1,
96-
errored: 1,
95+
failed: 2,
9796
skipped: 1,
9897
warned: 1,
9998
retries: 1
@@ -105,7 +104,7 @@ describe('Stats', () => {
105104
runner.emit(RunnerEvents.ERROR, makeStateResult({name: 'some-state'}));
106105

107106
assert.equal(stats.getResult().skipped, 0);
108-
assert.equal(stats.getResult().errored, 1);
107+
assert.equal(stats.getResult().failed, 1);
109108
});
110109

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

120119
assert.equal(stats.getResult().total, 1);
121-
assert.equal(stats.getResult().errored, 1);
120+
assert.equal(stats.getResult().failed, 1);
122121
});
123122

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

137136
assert.equal(stats.getResult().total, 2);
138-
assert.equal(stats.getResult().errored, 2);
137+
assert.equal(stats.getResult().failed, 2);
139138
});
140139
});

0 commit comments

Comments
 (0)