-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add global app
property.
#3549
Add global app
property.
#3549
Conversation
@garg3133 why do we need this? |
@swrdfish This was a suggestion made by Vishal to have an |
Sound good, also can you add a simple test? |
I tried to look through the code, but couldn't find any tests written for any of the other global variables. So, maybe we can just have a example test written in |
lib/index.js
Outdated
@@ -359,6 +359,20 @@ Object.defineProperty(Nightwatch, 'browser', { | |||
} | |||
}); | |||
|
|||
Object.defineProperty(Nightwatch, 'app', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: we can use defineProperties
, and define both app
and browser
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC Object.defineProperties
cannot be used to add the same descriptor to two properties, but is used to add all the properties in one go. But since all the properties are added to Nightwatch
separately in this file, it makes more sense to me to use defineProperty
only just to have a consistent pattern through the file.
But if the problem is with the repetition of the same descriptor for the two properties, we can maybe do something like this?
const nightwatchApiDescriptor = {
configurable: true,
get() {
if (global.browser) {
return global.browser;
}
const err = new TypeError('Nightwatch client is not yet available.');
err.addDetailedErr = true;
throw err;
}
};
Object.defineProperty(Nightwatch, 'browser', nightwatchApiDescriptor);
Object.defineProperty(Nightwatch, 'app', nightwatchApiDescriptor);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, can you do the refactoring to avoid repeating the code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
should we add a basic high-level in apidemos test using global app property? for example:
|
No description provided.