Skip to content

Commit

Permalink
feat: pass mocha suite on 'beforeFileRead' and 'afterFileRead' events
Browse files Browse the repository at this point in the history
  • Loading branch information
eGavr committed Mar 15, 2017
1 parent 6f9ae05 commit 3e25894
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ hermione.only.in('chrome');
hermione.only.notIn('ie8');
```

`hermione.only.in` will run tests only in the specified browsers and skip the rest silently.
`hermione.only.in` will run tests only in the specified browsers and skip the rest silently.

`hermione.only.notIn` will run tests in all browsers except the specified ones.

Expand Down Expand Up @@ -547,8 +547,8 @@ Property name | Description

Event | Description
------------------------- | -------------
`BEFORE_FILE_READ` | Will be triggered on test files parsing before reading the file. The handler accepts data object with `file`, `browser` (browser id string) and `hermione` (helper which will be available in test file) fields.
`AFTER_FILE_READ` | Will be triggered on test files parsing right after reading the file. The handler accepts data object with `file`, `browser` (browser id string) and `hermione` (helper which will be available in test file) fields.
`BEFORE_FILE_READ` | Will be triggered on test files parsing before reading the file. The handler accepts data object with `file`, `browser` (browser id string), `hermione` (helper which will be available in test file) and `suite` (collection of tests in a file; provides the ability to subscribe on `test` and `suite` events) fields.
`AFTER_FILE_READ` | Will be triggered on test files parsing right after reading the file. The handler accepts data object with `file`, `browser` (browser id string), `hermione` (helper which will be available in test file) and `suite` (collection of tests in a file; provides the ability to subscribe on `test` and `suite` events) fields.
`RUNNER_START` | Will be triggered before test execution. If a handler returns a promise, tests will be executed only after the promise is resolved. The handler accepts an instance of a runner as the first argument. You can use this instance to emit and subscribe to any other available events.
`RUNNER_END` | Will be triggered after test execution. If a handler returns a promise, tests will be executed only after the promise is resolved.
`SESSION_START` | Will be triggered after browser session initialization. If a handler returns a promise, tests will be executed only after the promise is resolved. The handler accepts an instance of webdriverIO as the first argument and an object with a browser identifier as the second.
Expand Down
3 changes: 2 additions & 1 deletion lib/runner/mocha-runner/mocha-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ module.exports = class MochaAdapter {
const emit_ = (event, file) => emit(event, {
file,
hermione: global.hermione,
browser: this._browserAgent.browserId
browser: this._browserAgent.browserId,
suite: this.suite
});
this.suite.on('pre-require', (ctx, file) => emit_(RunnerEvents.BEFORE_FILE_READ, file));
this.suite.on('post-require', (ctx, file) => emit_(RunnerEvents.AFTER_FILE_READ, file));
Expand Down
7 changes: 4 additions & 3 deletions test/lib/runner/mocha-runner/mocha-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -569,11 +569,12 @@ describe('mocha-runner/mocha-adapter', () => {
MochaStub.prototype.suite.emit(mochaEvent, {}, '/some/file.js');

assert.calledOnce(emit);
assert.calledWith(emit, RunnerEvents[hermioneEvent], sinon.match({
assert.calledWith(emit, RunnerEvents[hermioneEvent], {
file: '/some/file.js',
hermione: global.hermione,
browser: 'bro'
}));
browser: 'bro',
suite: mochaAdapter.suite
});
});
});
});
Expand Down

0 comments on commit 3e25894

Please sign in to comment.