Skip to content

Commit

Permalink
Send POST_SESSION_EVENT with capabilities on session creation. (#4024)
Browse files Browse the repository at this point in the history
  • Loading branch information
garg3133 authored Feb 16, 2024
1 parent 88df1d8 commit 40be23a
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions lib/runner/test-runners/cucumber/nightwatch-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const {Logger, SafeJSON, isFunction} = Utils;
const {Formatter} = require('@cucumber/cucumber');

const {NightwatchEventHub, CUCUMBER_RUNNER_EVENTS: {
TestStarted,
TestStarted,
TestFinished,
TestCaseStarted,
TestCaseFinished,
Expand All @@ -28,11 +28,20 @@ module.exports = class NightwatchFormatter extends Formatter {
data = {...data, testCaseStartedId: process.env.CUCUMBER_TEST_CASE_STARTED_ID};

if (isFunction(process.send)) {
process.send({'jsonEnvelope': SafeJSON.stringify({
session: {
...data,
workerId: process.env.CUCUMBER_WORKER_ID
}})});
process.send({
'jsonEnvelope': SafeJSON.stringify({
session: {
...data,
workerId: process.env.CUCUMBER_WORKER_ID
}
}),
'POST_SESSION_EVENT': SafeJSON.stringify({
session: {
...data,
workerId: process.env.CUCUMBER_WORKER_ID
}
})
});
} else {
NightwatchFormatter.eventBroadcaster?.emit('envelope', {session: data});
}
Expand Down Expand Up @@ -143,7 +152,7 @@ module.exports = class NightwatchFormatter extends Formatter {
if (!NightwatchEventHub.isAvailable) {
return;
}

const handlers = {
meta: this.onMeta,
gherkinDocument: this.onGherkinDocument,
Expand All @@ -161,7 +170,7 @@ module.exports = class NightwatchFormatter extends Formatter {
testStepStarted: this.onTestStepStarted,
session: this.onSessionCapabilities
};

const cucumberEvent = Object.keys(envelope)[0];
if (cucumberEvent && handlers[cucumberEvent]) {
handlers[cucumberEvent].call(this, envelope[cucumberEvent]);
Expand Down

0 comments on commit 40be23a

Please sign in to comment.