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

Incomplete Hook Example #363

Open
mansidixit opened this issue Mar 21, 2018 · 1 comment
Open

Incomplete Hook Example #363

mansidixit opened this issue Mar 21, 2018 · 1 comment

Comments

@mansidixit
Copy link

Being new to Javascript and nightwatch , I am trying to implement hooks using nightwatch cucumber.
The example section that you have provided looks incomplete as the hook example doesnt have any hooks implemented.
https://github.com/mucsi96/nightwatch-cucumber/tree/master/examples/hooks-example

It would be very helpful if you correct it .

@josefsalyer
Copy link

I have found this pattern to work:

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

Before(() => new Promise(resolve => {
  console.log('Before start');
  setTimeout(() => {
    console.log('Before end');
    resolve();
  }, 1);
}));
//I do this to clear the session for login/logout scenarios
After(() => client.execute(`
  localStorage.clear();
  sessionStorage.clear();
`).deleteCookies().refresh());

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

2 participants