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

Commit 7d04923

Browse files
committed
feat: Pass suiteCollection on BEGIN event to allow to modify it
1 parent 1f905cc commit 7d04923

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

doc/events.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,9 @@
1616
* `START_BROWSER` - emitted on browser session start. Emitted with [browser instance](../lib/browser/new-browser.js). If handler returns a promise tests will be executed in this session only after the promise is resolved.
1717

1818
* `STOP_BROWSER` - emitted right before browser session end. Emitted with [browser instance](../lib/browser/new-browser.js). If handler returns a promise quit will be performed only after the promise is resolved.
19+
20+
* `BEGIN` - runner event. Emitted on runner start with 1 argument `data`:
21+
* `data.suiteCollection` - suite collection which will be run
22+
* `data.config` - gemini config
23+
* `data.totalStates` - number of states in collection
24+
* `data.browserIds` - all browser ids from config

lib/runner/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ module.exports = class TestsRunner extends Runner {
4646

4747
_formatBeginEventData(suiteCollection) {
4848
return {
49+
suiteCollection,
4950
config: this.config,
5051
totalStates: _.sumBy(suiteCollection.allSuites(), (suite) => suite.states.length),
5152
browserIds: this.config.getBrowserIds()

test/unit/runner/index.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,18 @@ describe('runner', () => {
133133
return run(runner).then(() => assert.calledOnce(onBegin));
134134
});
135135

136-
it('should pass total number of states when emitting "BEGIN" event', () => {
136+
it('should pass suite collection on "BEGIN" event', () => {
137+
const runner = createRunner();
138+
const suiteCollection = {allSuites: sinon.stub()};
139+
const onBegin = sinon.spy().named('onBegin');
140+
141+
runner.on(Events.BEGIN, onBegin);
142+
143+
return run(runner, suiteCollection)
144+
.then(() => assert.calledWithMatch(onBegin, {suiteCollection}));
145+
});
146+
147+
it('should pass total number of states on "BEGIN" event', () => {
137148
const runner = createRunner();
138149
const suiteCollection = {allSuites: sinon.stub()};
139150
const suites = [
@@ -150,7 +161,7 @@ describe('runner', () => {
150161
return run(runner, suiteCollection).then(() => assert.calledWithMatch(onBegin, {totalStates: 3}));
151162
});
152163

153-
it('should pass all browser ids when emitting "BEGIN" event', () => {
164+
it('should pass all browser ids on "BEGIN" event', () => {
154165
const runner = createRunner();
155166
const onBegin = sinon.spy().named('onBegin');
156167

@@ -161,7 +172,7 @@ describe('runner', () => {
161172
return run(runner).then(() => assert.calledWithMatch(onBegin, {browserIds: ['bro1', 'bro2']}));
162173
});
163174

164-
it('should pass config when emitting "BEGIN" event', () => {
175+
it('should pass config on "BEGIN" event', () => {
165176
const runner = createRunner();
166177
const config = runner.config;
167178
const onBegin = sinon.spy().named('onBegin');

0 commit comments

Comments
 (0)