Created
June 18, 2018 09:31
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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