Skip to content

Commit

Permalink
handling the case when auto_start_session will be false
Browse files Browse the repository at this point in the history
(cherry picked from commit 0d5a9a0)
  • Loading branch information
harshit-bs committed Aug 17, 2023
1 parent 187db59 commit dab1de6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
12 changes: 12 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const Settings = require('./settings/settings.js');
const ElementGlobal = require('./api/_loaders/element-global.js');
const NightwatchClient = require('./core/client.js');
const namespacedApi = require('./core/namespaced-api.js');
const {NightwatchEventHub} = require('./runner/eventHub');

const {Logger} = Utils;

Expand Down Expand Up @@ -138,6 +139,17 @@ module.exports.createClient = function({
})
.then(_ => {
return client.api;
})
.catch((error) => {
if (this.settings.test_runner?.type === 'cucumber' && NightwatchEventHub.isAvailable) {
const NightwatchFormatter = require('./runner/test-runners/cucumber/nightwatch-format');

NightwatchFormatter.setCapabilities({
error: error
});
}

throw error;
});
}
};
Expand Down
6 changes: 0 additions & 6 deletions lib/runner/test-runners/cucumber/_setup_cucumber_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,6 @@ Before(function({pickle, testCaseStartedId}) {
if (options.auto_start_session || typeof options.auto_start_session == 'undefined') {
return this.client.launchBrowser().then(browser => {
this.browser = browser;
}).catch(error => {
NightwatchFormatter.setCapabilities({
error: error
});

throw error;
});
}
});
Expand Down
8 changes: 0 additions & 8 deletions lib/transport/selenium-webdriver/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,14 +317,6 @@ class Transport extends BaseTransport {
const error = this.handleConnectError(err);
this.showConnectSpinner(colors.red(`Failed to connect to ${this.serviceName} on ${host} with ${colors.stack_trace(portStr)}.`), 'warn');

if (this.settings.test_runner?.type === 'cucumber' && NightwatchEventHub.isAvailable) {
const NightwatchFormatter = require('../../runner/test-runners/cucumber/nightwatch-format.js');

NightwatchFormatter.setCapabilities({
error: error
});
}

throw error;
}
}
Expand Down

0 comments on commit dab1de6

Please sign in to comment.