-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Open
Labels
Description
Describe the bug
When using the programmatic API, the runTests function does not throw an error if the test fails, nor does it return any data about the tests that ran.
Sample test
You can see my docker setup as described here #2483
I did not expect runTests to return anything since that is not documented, however that might be a good feature to add
const Nightwatch = require('nightwatch');
(async function() {
const runner = Nightwatch.CliRunner({
config: './nightwatch.conf.js',
env: 'default'
});
// here you can overwrite any nightwatch config setting
const settings = {
src_folders: ['test']
};
runner.setup(settings);
await runner.startWebDriver();
try {
let testResults = await runner.runTests();
console.log(testResults);
}
catch (err) {
console.log('I ERRRORRED');
console.error('An error occurred:', err);
}
await runner.stopWebDriver();
}());
Successful test
module.exports = {
'Demo test Google' (browser) {
browser
.url('http://www.google.com')
.waitForElementVisible('body', 2000);
browser.end();
}
};
Unsuccessful test
module.exports = {
'Demo test Google' (browser) {
browser
.url('http://www.google.com')
.waitForElementVisible('bodya', 2000);
browser.end();
}
};
The result is the same for both tests, runTests does not throw an error for the unsuccessful test. I can see the error in the console from nightwatch, however the catch does not get hit and the text 'I ERRRORRED' is not printed.
Verbose output
node app.js
[Test Script] Test Suite
========================
ℹ Connected to localhost on port 9515 (1149ms).
Using: chrome (85.0.4183.121) on Linux platform.
Running: Demo test Google
✖ Timed out while waiting for element <bodya> to be present for 2000 milliseconds. - expected "visible" but got: "not found" (2105ms)
at Object.Demo test Google (/src/test/test_script.js:7:5)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
FAILED: 1 assertions failed (3.983s)
_________________________________________________
TEST FAILURE: 1 assertions failed, 0 passed (5.567s)
✖ test_script
– Demo test Google (3.983s)
Timed out while waiting for element <bodya> to be present for 2000 milliseconds. - expected "visible" but got: "not found" (2105ms)
at Object.Demo test Google (/src/test/test_script.js:7:5)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Configuration
module.exports = {
webdriver: {
start_process: true,
server_path: '/usr/bin/chromedriver',
port: 9515
},
test_settings: {
default: {
desiredCapabilities: {
browserName: 'chrome',
chromeOptions: {
binary: '/usr/bin/chromium-browser',
args: ['--no-sandbox']
}
}
}
}
};
Your Environment
You can see my docker setup as described here #2483
Reactions are currently unavailable