nightwatch-cucumber
nightwatch-cucumber copied to clipboard
Incomplete Hook Example
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 .
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());