Skip to content

Commit

Permalink
logs session capability logs
Browse files Browse the repository at this point in the history
(cherry picked from commit 9842ff7)
  • Loading branch information
harshit-bs committed Jul 31, 2023
1 parent 03810e8 commit a6cf54f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/runner/test-runners/cucumber/_setup_cucumber_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Before(function({pickle, testCaseStartedId}) {
const webdriver = {};

process.env.CUCUMBER_TEST_CASE_STARTED_ID = testCaseStartedId;
// eslint-disable-next-line no-console
console.log('setup_cucumber_before', 'PID:', process.pid, 'testCaseStartedId:', testCaseStartedId);

if (this.parameters['webdriver-host']) {
webdriver.host = this.parameters['webdriver-host'];
Expand Down
13 changes: 13 additions & 0 deletions lib/runner/test-runners/cucumber/nightwatch-format.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ module.exports = class NightwatchFormatter extends Formatter {
static setCapabilities(data) {
data = {...data, testCaseStartedId: process.env.CUCUMBER_TEST_CASE_STARTED_ID};

// eslint-disable-next-line no-console
console.log('nightwatch_format_set_capability', 'PID:', process.pid, 'testCaseStartedId:', process.env.CUCUMBER_TEST_CASE_STARTED_ID);

if (isFunction(process.send)) {
process.send({'jsonEnvelope': SafeJSON.stringify({
session: {
Expand All @@ -39,6 +42,9 @@ module.exports = class NightwatchFormatter extends Formatter {
}

onSessionCapabilities(envelope) {
// eslint-disable-next-line no-console
console.log('nightwatch_format_onSessionCapabilities', 'PID:', process.pid, 'testCaseStartedId:', envelope.testCaseStartedId);

this.report.session = this.report.session || {};

this.report.session[envelope.testCaseStartedId] = envelope;
Expand Down Expand Up @@ -82,6 +88,13 @@ module.exports = class NightwatchFormatter extends Formatter {
this.report.testCaseFinished = this.report.testCaseFinished || {};
this.report.testCaseFinished[result.testCaseStartedId] = result;

if (!this.report.session[result.testCaseStartedId]) {
throw new Error('Session capabilities not found for', result.testCaseStartedId);
}

// eslint-disable-next-line no-console
console.log('nightwatch_format_onTestCaseFinished', 'PID:', process.pid, 'testCaseStartedId:', result.testCaseStartedId);

NightwatchEventHub.emit(TestCaseFinished, {
envelope: result,
report: this.report
Expand Down

0 comments on commit a6cf54f

Please sign in to comment.