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

Fixes/3540 undhandled promises for wait commands #3570

Conversation

gravityvi
Copy link
Member

@gravityvi gravityvi commented Jan 13, 2023

Changes

  • refactors runChildNode in asynctree.js
  • fixed a test

Impacts

Comment on lines +132 to +143
if (this.shouldRejectNodePromise(err, node)) {
node.reject(err);
} else {
this.currentNode.resolve(err);
node.resolve(err);
}

if (this.shouldRejectParentNodePromise(err)) {
if (this.shouldRejectParentNodePromise(err, node)) {
parent.reject(err);
}
} else {
node.resolveValue = result;
this.resolveNode(this.currentNode, result);
this.resolveNode(node, result);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of using this.currentNode which might have changed during execution (When there are events like abortOnFailure currentNode is shifted to rootNode), I've changed it node which is stored in the context while executing this function.

@@ -48,7 +48,7 @@ describe('expect(element.<command>) - passed', function() {
const testsPath = path.join(__dirname, '../../../apidemos/expect-global/expect.js');

Mocks.elementNotSelected();
Mocks.elementProperty('0', 'className', {value: ['div-container']});
Mocks.elementProperty('0', 'className', {value: ['container']});
Copy link
Member Author

@gravityvi gravityvi Jan 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is fixing a test which not reported earlier. The Nightwatch-test running inside this test has two expect out of which one should fail but without this change there would be two failures.
Nightwatch-Test: https://github.com/nightwatchjs/nightwatch/tree/main/test/apidemos/expect-global/expect.js

@gravityvi gravityvi marked this pull request as ready for review January 16, 2023 07:32
@beatfactor beatfactor merged commit 58ce1be into nightwatchjs:main Jan 19, 2023
harshit-bs pushed a commit to harshit-bs/nightwatch that referenced this pull request Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nightwatch + Cucumber.js, waitFor-type commands abort execution when failing inside a custom command
2 participants