Closed ianlet closed 2 years ago
This isn't going to work I'm afraid. But you can easily define the launch_url in your config like this:
{
src_folders: ['tests/ui'],
launch_url: '${WEBAPP_URL}'
}
WEBAPP_URL
will be parsed automatically from process.env.WEBAPP_URL
.
This issue has been automatically marked as stale because it has not had any recent activity. If possible, please retry using the latest Nightwatch version and update the issue with any relevant details. If no further activity occurs, it will be closed. Thank you for your contribution.
Describe the bug
When running Nightwatch on multiple environments, options passed to the
setup
function are not passed down to child processes that are running tests in each environments.Custom runner
run-tests.js
```js // Dynamically starting my local server with a custom URL try { Nightwatch.cli(function(argv) { Nightwatch.CliRunner(argv) .setup({launch_url: WEBAPP_URL}) // Setup options with a custom `launch_url` .runTests() .catch((err) => { throw err; }) }); } catch (ex) { console.log('There was an error while starting the test runner:\n\n'); process.stderr.write(ex.stack + '\n'); process.exit(2); } ```
Sample test
sampleTest.js
```js module.exports = { sampleTest: function(browser) { browser .url(browser.launch_url) // This will be undefined .waitForElementVisible('body', 1000) .assert.containsText('body', 'Log In') .end(); } } ```
Run with command
Configuration
nightwatch.json
```js { src_folders: ['tests/ui'], selenium: { start_process: false, host: 'hub-cloud.browserstack.com', port: 443, }, common_capabilities: { 'acceptSslCerts': 'true', 'browserstack.console': 'info', 'browserstack.networkLogs': 'true', 'browserstack.local': true, 'browserstack.debug': true, }, test_settings: { default: {}, chrome: { desiredCapabilities: { browser: 'chrome', browser_version: 'latest', os: 'Windows', os_version: '10', }, }, firefox: { desiredCapabilities: { browser: 'firefox', browser_version: 'latest', os: 'Windows', os_version: '10', }, }, }, } ```
Additional information
This line of code https://github.com/nightwatchjs/nightwatch/blob/main/lib/runner/concurrency/child-process.js#L128 is where a child process is spawned with only the cli arguments but not the setup options.
Your Environment
nightwatch --version
yarn --version
node --version