-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Make namespaces available as named exports #3646
Conversation
lib/api/_loaders/_base-loader.js
Outdated
isRestrictedNamespace(parent, namespace) { | ||
if (!parent) { | ||
return false; | ||
} | ||
|
||
// do not load these namespaces on parent (page objects and within-context). | ||
const namespacesRestrictedForParent = ['client']; | ||
|
||
const isRestrictedNamespace = namespace | ||
&& namespacesRestrictedForParent.some((ns) => namespace.toString().startsWith(ns)); | ||
|
||
return isRestrictedNamespace; | ||
} |
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.
This change here is for the discussion we had that we don't need to load all the namespaces directly onto the page objects but only a few like cookies
and a11y
. So, with this, we can restrict the namespaces we do not want to load on page-objects.
This was actually added here because page objects already had a client
property (set to NightwatchClient
) and so we could not add the client
namespace commands directly onto page-objects, but it also serves the purpose mentioned above. And since we are no longer loading the commands onto client
namespace, we can safely remove this as well if we do not want this feature at this point.
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.
Great work on this pull request! LGTY!!
Windows build failing, and I suspect increasing timeout will fix the issue.
Maybe, but in the last 4 build failures, 5 tests failed cumulatively, and all are different. So, not sure which test to increase the timeout for if a different test fails every time. |
@garg3133 maybe try increasing the default timeout? |
ce24453
to
1fde06c
Compare
This PR makes the namespaces specified in the
namespaced-api.js
file available as named exports.To test this PR, copy/move the
navigateTo.js
andgetTitle.js
(or any other command files) to theclient
sub-directory. Doing so will make those commands available on theclient
namespace.In your test, use it as:
In above test, the commands will return the namespace only instead of the whole
browser
object. While the commands executed usingbrowser.client.commandName
will still return the wholebrowser
object.