Skip to content

Instantly share code, notes, and snippets.

@paulbjensen
Created June 18, 2018 09:31
Show Gist options
  • Save paulbjensen/58f90134a0685bb8e5d5d5224346220d to your computer and use it in GitHub Desktop.
Save paulbjensen/58f90134a0685bb8e5d5d5224346220d to your computer and use it in GitHub Desktop.
Version 2 of our hooks.js file, part of an article on Medium
/*eslint no-console: ["error", { allow: ["log"] }] */
// Dependencies
const { After, Before, AfterAll } = require('cucumber');
const scope = require('./support/scope');
Before(async () => {
});
After(async () => {
if (scope.browser && scope.context.currentPage) {
const cookies = await scope.context.currentPage.cookies();
if (cookies && cookies.length > 0) {
await scope.context.currentPage.deleteCookie(...cookies);
}
await scope.context.currentPage.close();
scope.context.currentPage = null;
}
});
AfterAll(async () => {
if (scope.browser) await scope.browser.close();
scope.api.shutdown(() => console.log('\nAPI is shut down'));
scope.web.shutdown(() => console.log('Web is shut down'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment