Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix abortOnAssertionFailure issue with waitFor commands #3932

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions lib/core/asynctree.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ class AsyncTree extends EventEmitter{
if (childNode) {
const result = await this.runChildNode(childNode);

if (result instanceof Error && result.namespace === 'verify') {
return null;
}

return result;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/testsuite/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const SuiteRetries = require('./retries.js');
const NightwatchClient = require('../core/client.js');
const Concurrency = require('../runner/concurrency');
const ElementGlobal = require('../api/_loaders/element-global.js');
const {Logger, Screenshots, Snapshots, alwaysDisplayError, isString, isFunction, SafeJSON} = require('../utils');
const {Logger, Screenshots, Snapshots, alwaysDisplayError, isString, isFunction, SafeJSON, isDefined} = require('../utils');
const NightwatchInspectorServer = require('./nightwatch-inspector');
const {DEFAULT_RUNNER_EVENTS, NightwatchEventHub} = require('../runner/eventHub');
const {GlobalHook, TestSuiteHook} = DEFAULT_RUNNER_EVENTS;
Expand Down Expand Up @@ -863,7 +863,7 @@ class TestSuite {
return this.retryCurrentTestCase();
}

if ((possibleError instanceof Error) && this.shouldSkipTestsOnFail()) {
if ((possibleError instanceof Error && (possibleError?.abortOnFailure ?? true)) && this.shouldSkipTestsOnFail()) {
throw possibleError;
}

Expand Down
9 changes: 9 additions & 0 deletions test/apidemos/waitFor-commands/waitForElementTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
describe('test wait for element commands', function() {
it('waitForElementVisible command - failure', function() {
browser.waitForElementVisible('#weblogin', 100, 90, false);
});

it('waitForElementNotVisible command - failure', function() {
browser.waitForElementNotVisible('#badElement', 100, 90, false);
});
});
43 changes: 43 additions & 0 deletions test/src/apidemos/waitFor-commands/testWaitForCommands.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
const path = require('path');
const assert = require('assert');
const MockServer = require('../../../lib/mockserver.js');
const Mocks = require('../../../lib/command-mocks.js');
const common = require('../../../common.js');
const {settings} = common;
const NightwatchClient = common.require('index.js');

describe('waitFor commands tests', function() {
beforeEach(function(done) {
this.server = MockServer.init();
this.server.on('listening', () => {
done();
});
});

afterEach(function(done) {
this.server.close(function() {
done();
});
});

it('run waitFor api demo tests ', function() {
const testsPath = path.join(__dirname, '../../../apidemos/waitFor-commands/waitForElementTest.js');

Mocks.visible('0', false);

const globals = {
waitForConditionPollInterval: 50,

reporter(results) {
assert.ok(results.lastError, 'should return NightwatchAssertError');
assert.strictEqual(results.skipped, 0, 'should not skip any tests');
}
};

return NightwatchClient.runTests(testsPath, settings({
output: false,
globals
}));
});

});
Loading