codeceptjs
Version:
Supercharged End 2 End Testing Framework for NodeJS
18 lines (15 loc) • 495 B
JavaScript
import { isFunction, isAsyncFunction } from './utils.js'
import output from './output.js'
export default async function (hook, stage) {
if (!hook) return
if (!isFunction(hook)) {
throw new Error('CodeceptJS 3 allows bootstrap/teardown hooks only as async functions. More info: https://bit.ly/codecept3Up')
}
if (stage) output.log(`started ${stage} hook`)
if (isAsyncFunction(hook)) {
await hook()
} else {
hook()
}
if (stage) output.log(`finished ${stage} hook`)
}