fava
Version:
A wannabe tiny largely-drop-in replacement for ava that works in the browser too.
28 lines (27 loc) • 711 B
JavaScript
/* IMPORT */
import { NOOP } from './constants.js';
/* MAIN */
class Hooks {
constructor() {
/* VARIABLES */
this.hooks = {
before: NOOP,
after: NOOP,
beforeEach: NOOP,
afterEach: NOOP
};
/* PRIVATE API */
this.makeHookSetter = (hook) => {
return (fn) => {
this.hooks[hook] = fn;
};
};
/* API */
this.before = this.makeHookSetter('before');
this.after = this.makeHookSetter('after');
this.beforeEach = this.makeHookSetter('beforeEach');
this.afterEach = this.makeHookSetter('afterEach');
}
}
/* EXPORT */
export default Hooks;