hermione-global-hook
Version:
Plugin to use global hooks
24 lines (19 loc) • 535 B
JavaScript
;
const parseConfig = require('./config');
/**
* @param {Object} hermione
* @param {Object} options
*/
module.exports = (hermione, opts) => {
const config = parseConfig(opts);
if (!config.enabled) {
return;
}
const {beforeEach, afterEach} = config;
hermione.on(hermione.events.AFTER_TESTS_READ, (collection) => {
collection.eachRootSuite((root) => {
beforeEach && root.beforeEach(beforeEach);
afterEach && root.afterEach(afterEach);
});
});
};