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

require('nightwatch-cucumber').client's keys are hidden #322

Open
getkey opened this issue Dec 8, 2017 · 4 comments
Open

require('nightwatch-cucumber').client's keys are hidden #322

getkey opened this issue Dec 8, 2017 · 4 comments

Comments

@getkey
Copy link

getkey commented Dec 8, 2017

I'm submitting a ... (check one with "x")

[x] bug report
[ ] feature request
[ ] support request => Please do not submit support request here, instead use [Stack Overflow](https://stackoverflow.com/questions/tagged/nightwatch.js+cucumber)

Current behavior
My setup is very similar to the demo.
Logging the client object yields these results.

const { client } = require('nightwatch-cucumber');
console.log(client); // {}
console.log(Object.keys(client)); // []
console.log(Object.getOwnPropertyNames(client)); // []
console.log(client.options); // an object containing a bunch of stuff

So the properties are there, they are just invisible when you don't know their names. My guess is that it's caused by a Proxy with an ownKeys trap wrapping the actual client.

Expected/desired behavior
Logging or listing the keys of client should yield the same results as they would on the client that nigtwatch provides. Not doing so is confusing and make implementing nightwatch-cucumber harder for the user.

Reproduction of the problem
See current behavior.

What is the motivation / use case for changing the behavior?
Bugfixing.

Please tell us about your environment:
In case of a bug report please provide the following information:

  • output of the following command from your project root npm ls nightwatch cucumber nightwatch-cucumber && node --version
  • output of running nightwatch with --verbose flag
yarn list v1.2.1
warning You are using Node "9.2.0" which is not supported and may encounter bugs or unexpected behavior. Yarn supports the following semver range: "^4.8.0 || ^5.7.0 || ^6.2.2 || ^8.0.0"
warning Filtering by arguments is deprecated. Please use the pattern option instead.
├─ cucumber@3.1.0
├─ nightwatch-cucumber@8.2.10
└─ nightwatch@0.9.19
Done in 0.32s.
v9.2.0
@mucsi96
Copy link
Owner

mucsi96 commented Dec 9, 2017

Thanks for reporting this. I think the issue here that the client is not yet ready after

const { client } = require('nightwatch-cucumber');

statement. Can you retry the consoles within step definitions? The client should be ready at that moment. Basically this problem is the main case I introduced the Proxy.

@getkey
Copy link
Author

getkey commented Dec 10, 2017

I just tried inside the callback of the Given(/^I open Google's search page$/, () => {, I got the same result. Are you able to reproduce?

@anatoliyarkhipov
Copy link

As I understand, the client proxy should implement ownKeys in order to make Object.getOwnPropertyNames work correctly. Like that, for example:

function getClientProxy (subPages) {
  return new Proxy({}, {
+    ownKeys (target) {
+      return Object.getOwnPropertyNames(runner.nightwatchApi.getClientApi())
+    },
    // ...
  })
}

@mucsi96
Copy link
Owner

mucsi96 commented Feb 18, 2018

Thanks @anatoliyarkhipov for the tip! Will add this

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

No branches or pull requests

3 participants