nightwatch-cucumber icon indicating copy to clipboard operation
nightwatch-cucumber copied to clipboard

Incomplete Hook Example

Open mansidixit opened this issue 6 years ago • 1 comments

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 .

mansidixit avatar Mar 21 '18 22:03 mansidixit

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());

josefsalyer avatar May 22 '18 12:05 josefsalyer