Description
-
I add hook to file codecept.conf.js as:
exports.config = {
hooks: ['./someHook.ts'], -
from https://codecept.io/hooks/#custom-hooks I copy your example
const event = require('codeceptjs').event;
module.exports = function() {
event.dispatcher.on(event.test.before, function (test) {
console.log('--- I am before test --');
});
}
to new file ./someHook.ts
after run codeceptjs i see this:
PS C:_git\sandbox> npm run run:tests
typescript-boilerplate@1.0.0 run:tests
codeceptjs run
CodeceptJS v3.1.3
Using test root "C:_git\sandbox"
(node:3740) UnhandledPromiseRejectionWarning: Error: CodeceptJS 3 allows bootstrap/teardown hooks only as async functions. More info: https://bit.ly/codecept3Up
at module.exports (C:_git\sandbox\node_modules\codeceptjs\lib\hooks.js:7:11)
at C:_git\sandbox\node_modules\codeceptjs\lib\codecept.js:101:39
at Array.forEach ()
at Codecept.runHooks (C:_git\sandbox\node_modules\codeceptjs\lib\codecept.js:101:23)
at Codecept.init (C:_git\sandbox\node_modules\codeceptjs\lib\codecept.js:57:10)
at module.exports (C:_git\sandbox\node_modules\codeceptjs\lib\command\run.js:24:14)
at Command. (C:_git\sandbox\node_modules\codeceptjs\bin\codecept.js:9:11)
at Command.listener (C:_git\sandbox\node_modules\commander\index.js:315:8)
at Command.emit (events.js:400:28)
at Command.parseArgs (C:_git\sandbox\node_modules\commander\index.js:651:12)
(Use node --trace-warnings ...
to show where the warning was created)
(node:3740) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To te
rminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict
(see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:3740) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Please upgrade your documentation page, with working example.