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

Commit

Permalink
feat: remove deprecated END_TEST event
Browse files Browse the repository at this point in the history
  • Loading branch information
j0tunn committed Nov 2, 2017
1 parent df35579 commit 9c7c8e2
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 40 deletions.
1 change: 0 additions & 1 deletion lib/constants/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ module.exports = {
WARNING: 'warning',
ERROR: 'err', // unable to call it `error` because `error` handling is a special case for EventEmitter

END_TEST: 'endTest', // Deprecated, will be removed in the next major version - 5.0.0
CAPTURE: 'capture', // Deprecated, will be removed in the next major version - 5.0.0

TEST_RESULT: 'testResult',
Expand Down
7 changes: 3 additions & 4 deletions lib/runner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,16 @@ module.exports = class TestsRunner extends Runner {
runner.on(Events.END_SUITE, (data) => this._suiteMonitor.suiteFinished(data.suite, data.browserId));

runner.on(Events.CAPTURE, (result) => this._handleResult(result, Events.CAPTURE));
runner.on(Events.TEST_RESULT, (result) => this._handleResult(result, [Events.END_TEST, Events.TEST_RESULT]));
runner.on(Events.TEST_RESULT, (result) => this._handleResult(result, Events.TEST_RESULT));
runner.on(Events.UPDATE_RESULT, (result) => this._handleResult(result, Events.UPDATE_RESULT));

this._browserRunners.push(runner);
return runner.run(suiteCollection, this._stateProcessor);
}

_handleResult(result, events) {
_handleResult(result, event) {
this._saveCoverage(result);

[].concat(events).forEach((event) => this.emit(event, result));
this.emit(event, result);
}

_saveCoverage(data) {
Expand Down
1 change: 0 additions & 1 deletion test/unit/gemini.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ describe('gemini', () => {
Events.WARNING,
Events.ERROR,

Events.END_TEST,
Events.CAPTURE,

Events.TEST_RESULT,
Expand Down
35 changes: 1 addition & 34 deletions test/unit/runner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ describe('runner', () => {

[
Events.CAPTURE,
Events.TEST_RESULT,
Events.UPDATE_RESULT
].forEach((event) => {
describe(`on ${event}`, () => {
Expand All @@ -511,40 +512,6 @@ describe('runner', () => {
testCoverage(event);
});
});

describe('on testResult', () => {
testPassthrough(Events.TEST_RESULT, 'should passthrough "testResult" event');

it('should passthrough "endTest" event', () => {
stubBrowserRunner((runner) => runner.emit(Events.TEST_RESULT, {foo: 'bar'}));

const runner = createRunner();
const onEndTest = sinon.spy().named('onEndTest');

runner.on(Events.END_TEST, onEndTest);

return run(runner)
.then(() => {
assert.calledOnce(onEndTest);
assert.calledWith(onEndTest, {foo: 'bar'});
});
});

it('should emit "testResult" event after "endTest" one', () => {
stubBrowserRunner((runner) => runner.emit(Events.TEST_RESULT));

const runner = createRunner();
const onEndTest = sinon.spy().named('onEndTest');
const onTestResult = sinon.spy().named('onTestResult');

runner.on(Events.END_TEST, onEndTest);
runner.on(Events.TEST_RESULT, onTestResult);

return run(runner).then(() => assert.callOrder(onEndTest, onTestResult));
});

testCoverage(Events.TEST_RESULT);
});
});
});

Expand Down

0 comments on commit 9c7c8e2

Please sign in to comment.