8000 feat: Pass suiteCollection on BEGIN event to allow to modify it by j0tunn · Pull Request #728 · gemini-testing/gemini · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Sep 21, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/events.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions lib/runner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
17 changes: 14 additions & 3 deletions test/unit/runner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 >

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 = [
Expand All @@ -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 >

Expand All @@ -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 >
Expand Down
0