As part of the setup, we can choose to have Nightwatch create some example tests.
We have a problem when we run this in Windows, because the config files are created with double Backslash, if we need to execute on Linux OS agent in CI/CD, we can not find any path.
For example:
This config file was created for the CLI with backslashes:
```js
// Refer to the online docs for more details:
// https://nightwatchjs.org/gettingstarted/configuration/
//
// _ _ _ _ _ _ _
// | \ | |(_) | | | | | | | |
// | \| | _ __ _ | |__ | |_ __ __ __ _ | |_ ___ | |__
// | . ` || | / _` || '_ \ | __|\ \ /\ / / / _` || __| / __|| '_ \
// | |\ || || (_| || | | || |_ \ V V / | (_| || |_ | (__ | | | |
// \_| \_/|_| \__, ||_| |_| \__| \_/\_/ \__,_| \__| \___||_| |_|
// __/ |
// |___/
module.exports = {
// An array of folders (excluding subfolders) where your tests are located;
// if this is not specified, the test source must be passed as the second argument to the test runner.
src_folders: ['tests\\specs'],
// See https://nightwatchjs.org/guide/concepts/page-object-model.html
page_objects_path: ['tests\\page-objects'],
// See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
custom_commands_path: ['tests\\custom-commands'],
// See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-assertions.html
custom_assertions_path: ['tests\\custom-assertions'],
// See https://nightwatchjs.org/guide/extending-nightwatch/adding-plugins.html
// plugins: [],
// See https://nightwatchjs.org/guide/concepts/test-globals.html
globals_path: '',
webdriver: {},
test_settings: {
default: {
disable_error_log: false,
launch_url: 'http://localhost',
screenshots: {
enabled: false,
path: 'screens',
on_failure: true
},
desiredCapabilities: {
browserName: 'chrome'
},
webdriver: {
start_process: true,
server_path: ''
},
},
chrome: {
desiredCapabilities: {
browserName: 'chrome',
'goog:chromeOptions': {
// More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
//
// w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
w3c: true,
args: [
//'--no-sandbox',
//'--ignore-certificate-errors',
//'--allow-insecure-localhost',
//'--headless'
]
}
},
webdriver: {
start_process: true,
server_path: '',
cli_args: [
// --verbose
]
}
},
}
};
```
Run with command
On a local machine with Windows 10.
$ npm init nightwatch
Then push the code and try to run on an Ubuntu agent.
Verbose output
debug.log
```txt
PS C:\dev\pre-stream\01> npm init nightwatch
_ _ _ _ _ _ _
| \ | |(_) | | | | | | | |
| \| | _ __ _ | |__ | |_ __ __ __ _ | |_ ___ | |__
| . ` || | / _` || '_ \ | __|\ \ /\ / / / _` || __| / __|| '_ \
| |\ || || (_| || | | || |_ \ V V / | (_| || |_ | (__ | | | |
\_| \_/|_| \__, ||_| |_| \__| \_/\_/ \__,_| \__| \___||_| |_|
__/ |
|___/
===============================
Nightwatch Configuration Wizard
===============================
Just answer a few questions to get started with Nightwatch:
We'll setup everything for you :-)
? What is your Language - Test Runner setup? JavaScript - Nightwatch Test Runner
? Where do you want to run your e2e tests? On my local machine
? Where you'll be testing on? Chrome
? Where do you plan to keep your end-to-end tests? tests
? What is the base_url of your project? http://localhost
Installing the following packages:
- nightwatch
Installing nightwatch
Done!
Generting a configuration file based on your responses...
√ Success! Configuration file generated at: "C:\dev\pre-stream\01\nightwatch.conf.js".
Installing/Updating the following webdrivers:
- chromedriver
Installing webdriver for Chrome (chromedriver)...
Done!
Generating example files...
√ Success! Generated some example files at 'tests'.
Nightwatch setup complete!!
Join our Discord community and instantly find answers to your issues or queries. Or just join and say hi!
https://discord.gg/SN8Da2X
Visit our GitHub page to report bugs or raise feature requests:
https://github.com/nightwatchjs/nightwatch
RUN NIGHTWATCH TESTS
To run all examples, run:
npx nightwatch .\tests\specs
To run a single example (ecosia.js), run:
npx nightwatch .\tests\specs\basic\ecosia.js
PS C:\dev\pre-stream\01>
```
Configuration
nightwatch.conf.js
```js
// Refer to the online docs for more details:
// https://nightwatchjs.org/gettingstarted/configuration/
//
// _ _ _ _ _ _ _
// | \ | |(_) | | | | | | | |
// | \| | _ __ _ | |__ | |_ __ __ __ _ | |_ ___ | |__
// | . ` || | / _` || '_ \ | __|\ \ /\ / / / _` || __| / __|| '_ \
// | |\ || || (_| || | | || |_ \ V V / | (_| || |_ | (__ | | | |
// \_| \_/|_| \__, ||_| |_| \__| \_/\_/ \__,_| \__| \___||_| |_|
// __/ |
// |___/
module.exports = {
// An array of folders (excluding subfolders) where your tests are located;
// if this is not specified, the test source must be passed as the second argument to the test runner.
src_folders: ['tests\\specs'],
// See https://nightwatchjs.org/guide/concepts/page-object-model.html
page_objects_path: ['tests\\page-objects'],
// See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html
custom_commands_path: ['tests\\custom-commands'],
// See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-assertions.html
custom_assertions_path: ['tests\\custom-assertions'],
// See https://nightwatchjs.org/guide/extending-nightwatch/adding-plugins.html
// plugins: [],
// See https://nightwatchjs.org/guide/concepts/test-globals.html
globals_path: '',
webdriver: {},
test_settings: {
default: {
disable_error_log: false,
launch_url: 'http://localhost',
screenshots: {
enabled: false,
path: 'screens',
on_failure: true
},
desiredCapabilities: {
browserName: 'chrome'
},
webdriver: {
start_process: true,
server_path: ''
},
},
chrome: {
desiredCapabilities: {
browserName: 'chrome',
'goog:chromeOptions': {
// More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/
//
// w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78)
w3c: true,
args: [
//'--no-sandbox',
//'--ignore-certificate-errors',
//'--allow-insecure-localhost',
//'--headless'
]
}
},
webdriver: {
start_process: true,
server_path: '',
cli_args: [
// --verbose
]
}
},
}
};
```
Describe the bug
As part of the setup, we can choose to have Nightwatch create some example tests. We have a problem when we run this in Windows, because the config files are created with double Backslash, if we need to execute on Linux OS agent in CI/CD, we can not find any path.
For example: This config file was created for the CLI with backslashes:
https://github.com/charlyautomatiza/boilerplate-nightwatchjs-test/blob/main/nightwatch.conf.js
If we run on a Windows agent local and in CI/CD, it run ok as you can see in this Action: https://github.com/charlyautomatiza/boilerplate-nightwatchjs-test/runs/7188654332?check_suite_focus=true
But if we need to run the same tests with the same config file but in Ubuntu in CI/CD, we have an error, as you can see on this Action: https://github.com/charlyautomatiza/boilerplate-nightwatchjs-test/runs/7188605373?check_suite_focus=true
If config file is created with slashes instead of backslashes it could be compatible with both Windows and Linux, isn't it?
For example:
Sample test
nightwatch.conf.js
```js // Refer to the online docs for more details: // https://nightwatchjs.org/gettingstarted/configuration/ // // _ _ _ _ _ _ _ // | \ | |(_) | | | | | | | | // | \| | _ __ _ | |__ | |_ __ __ __ _ | |_ ___ | |__ // | . ` || | / _` || '_ \ | __|\ \ /\ / / / _` || __| / __|| '_ \ // | |\ || || (_| || | | || |_ \ V V / | (_| || |_ | (__ | | | | // \_| \_/|_| \__, ||_| |_| \__| \_/\_/ \__,_| \__| \___||_| |_| // __/ | // |___/ module.exports = { // An array of folders (excluding subfolders) where your tests are located; // if this is not specified, the test source must be passed as the second argument to the test runner. src_folders: ['tests\\specs'], // See https://nightwatchjs.org/guide/concepts/page-object-model.html page_objects_path: ['tests\\page-objects'], // See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html custom_commands_path: ['tests\\custom-commands'], // See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-assertions.html custom_assertions_path: ['tests\\custom-assertions'], // See https://nightwatchjs.org/guide/extending-nightwatch/adding-plugins.html // plugins: [], // See https://nightwatchjs.org/guide/concepts/test-globals.html globals_path: '', webdriver: {}, test_settings: { default: { disable_error_log: false, launch_url: 'http://localhost', screenshots: { enabled: false, path: 'screens', on_failure: true }, desiredCapabilities: { browserName: 'chrome' }, webdriver: { start_process: true, server_path: '' }, }, chrome: { desiredCapabilities: { browserName: 'chrome', 'goog:chromeOptions': { // More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/ // // w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78) w3c: true, args: [ //'--no-sandbox', //'--ignore-certificate-errors', //'--allow-insecure-localhost', //'--headless' ] } }, webdriver: { start_process: true, server_path: '', cli_args: [ // --verbose ] } }, } }; ```
Run with command
On a local machine with Windows 10.
Then push the code and try to run on an Ubuntu agent.
Verbose output
debug.log
```txt PS C:\dev\pre-stream\01> npm init nightwatch _ _ _ _ _ _ _ | \ | |(_) | | | | | | | | | \| | _ __ _ | |__ | |_ __ __ __ _ | |_ ___ | |__ | . ` || | / _` || '_ \ | __|\ \ /\ / / / _` || __| / __|| '_ \ | |\ || || (_| || | | || |_ \ V V / | (_| || |_ | (__ | | | | \_| \_/|_| \__, ||_| |_| \__| \_/\_/ \__,_| \__| \___||_| |_| __/ | |___/ =============================== Nightwatch Configuration Wizard =============================== Just answer a few questions to get started with Nightwatch: We'll setup everything for you :-) ? What is your Language - Test Runner setup? JavaScript - Nightwatch Test Runner ? Where do you want to run your e2e tests? On my local machine ? Where you'll be testing on? Chrome ? Where do you plan to keep your end-to-end tests? tests ? What is the base_url of your project? http://localhost Installing the following packages: - nightwatch Installing nightwatch Done! Generting a configuration file based on your responses... √ Success! Configuration file generated at: "C:\dev\pre-stream\01\nightwatch.conf.js". Installing/Updating the following webdrivers: - chromedriver Installing webdriver for Chrome (chromedriver)... Done! Generating example files... √ Success! Generated some example files at 'tests'. Nightwatch setup complete!! Join our Discord community and instantly find answers to your issues or queries. Or just join and say hi! https://discord.gg/SN8Da2X Visit our GitHub page to report bugs or raise feature requests: https://github.com/nightwatchjs/nightwatch RUN NIGHTWATCH TESTS To run all examples, run: npx nightwatch .\tests\specs To run a single example (ecosia.js), run: npx nightwatch .\tests\specs\basic\ecosia.js PS C:\dev\pre-stream\01> ```
Configuration
nightwatch.conf.js
```js // Refer to the online docs for more details: // https://nightwatchjs.org/gettingstarted/configuration/ // // _ _ _ _ _ _ _ // | \ | |(_) | | | | | | | | // | \| | _ __ _ | |__ | |_ __ __ __ _ | |_ ___ | |__ // | . ` || | / _` || '_ \ | __|\ \ /\ / / / _` || __| / __|| '_ \ // | |\ || || (_| || | | || |_ \ V V / | (_| || |_ | (__ | | | | // \_| \_/|_| \__, ||_| |_| \__| \_/\_/ \__,_| \__| \___||_| |_| // __/ | // |___/ module.exports = { // An array of folders (excluding subfolders) where your tests are located; // if this is not specified, the test source must be passed as the second argument to the test runner. src_folders: ['tests\\specs'], // See https://nightwatchjs.org/guide/concepts/page-object-model.html page_objects_path: ['tests\\page-objects'], // See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-commands.html custom_commands_path: ['tests\\custom-commands'], // See https://nightwatchjs.org/guide/extending-nightwatch/adding-custom-assertions.html custom_assertions_path: ['tests\\custom-assertions'], // See https://nightwatchjs.org/guide/extending-nightwatch/adding-plugins.html // plugins: [], // See https://nightwatchjs.org/guide/concepts/test-globals.html globals_path: '', webdriver: {}, test_settings: { default: { disable_error_log: false, launch_url: 'http://localhost', screenshots: { enabled: false, path: 'screens', on_failure: true }, desiredCapabilities: { browserName: 'chrome' }, webdriver: { start_process: true, server_path: '' }, }, chrome: { desiredCapabilities: { browserName: 'chrome', 'goog:chromeOptions': { // More info on Chromedriver: https://sites.google.com/a/chromium.org/chromedriver/ // // w3c:false tells Chromedriver to run using the legacy JSONWire protocol (not required in Chrome 78) w3c: true, args: [ //'--no-sandbox', //'--ignore-certificate-errors', //'--allow-insecure-localhost', //'--headless' ] } }, webdriver: { start_process: true, server_path: '', cli_args: [ // --verbose ] } }, } }; ```
Your Environment
nightwatch --version
npm --version
node --version