diff --git a/doc/events.md b/doc/events.md index 343e92e88..b2d123f48 100644 --- a/doc/events.md +++ b/doc/events.md @@ -16,3 +16,9 @@ * `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. * `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. + +* `BEGIN` - runner event. Emitted on runner start with 1 argument `data`: + * `data.suiteCollection` - suite collection which will be run + * `data.config` - gemini config + * `data.totalStates` - number of states in collection + * `data.browserIds` - all browser ids from config diff --git a/lib/runner/index.js b/lib/runner/index.js index 21b8cff0f..b22609fe8 100644 --- a/lib/runner/index.js +++ b/lib/runner/index.js @@ -46,6 +46,7 @@ module.exports = class TestsRunner extends Runner { _formatBeginEventData(suiteCollection) { return { + suiteCollection, config: this.config, totalStates: _.sumBy(suiteCollection.allSuites(), (suite) => suite.states.length), browserIds: this.config.getBrowserIds() diff --git a/test/unit/runner/index.js b/test/unit/runner/index.js index c688fe5b7..e65bce2bd 100644 --- a/test/unit/runner/index.js +++ b/test/unit/runner/index.js @@ -133,7 +133,18 @@ describe('runner', () => { return run(runner).then(() => assert.calledOnce(onBegin)); }); - it('should pass total number of states when emitting "BEGIN" event', () => { + it('should pass suite collection on "BEGIN" event', () => { + const runner = createRunner(); + const suiteCollection = {allSuites: sinon.stub()}; + const onBegin = sinon.spy().named('onBegin'); + + runner.on(Events.BEGIN, onBegin); + + return run(runner, suiteCollection) + .then(() => assert.calledWithMatch(onBegin, {suiteCollection})); + }); + + it('should pass total number of states on "BEGIN" event', () => { const runner = createRunner(); const suiteCollection = {allSuites: sinon.stub()}; const suites = [ @@ -150,7 +161,7 @@ describe('runner', () => { return run(runner, suiteCollection).then(() => assert.calledWithMatch(onBegin, {totalStates: 3})); }); - it('should pass all browser ids when emitting "BEGIN" event', () => { + it('should pass all browser ids on "BEGIN" event', () => { const runner = createRunner(); const onBegin = sinon.spy().named('onBegin'); @@ -161,7 +172,7 @@ describe('runner', () => { return run(runner).then(() => assert.calledWithMatch(onBegin, {browserIds: ['bro1', 'bro2']})); }); - it('should pass config when emitting "BEGIN" event', () => { + it('should pass config on "BEGIN" event', () => { const runner = createRunner(); const config = runner.config; const onBegin = sinon.spy().named('onBegin');