Where to save the event listeners files? #4240
Replies: 2 comments 1 reply
-
Hello, you can store the file in your project directory (where you feel appropriate) and then in the config file, you can do something like below
Inside hooks.js
Alternatively, another solution is, for example if you are using cucumber, in the config
In the above case, you can just use the below events in any 'somemodule.hooks.ts' file and it gets automatically called.
|
Beta Was this translation helpful? Give feedback.
-
@shank087 Thanks for your detailed answer very informative. So in short for later people or Google research, to load your events it needs to to included (for most of the cases) in the codecept.conf.js file in "helper > Hooks":
I knew it was simple but could not figured this out, thanks again. |
Beta Was this translation helpful? Give feedback.
-
Hi,
Long shot here, but reading this documentation for few months already and I cannot figure out where to save the file (best practises) nor how to include it properly in the codeceptjs.conf.js
It may be trivial, but for Page Object, Fragments, etc it's explained properly but for events it's not. So either I missed it or it's dead simple:
https://codecept.io/internal-api/#event-listeners
My guess are:
-should be in a "events" directory from the root
-save the file as MyEvents.js for example
-add the file in the "include" attribute of the config (?)
Thanks for enlighten me.
Beta Was this translation helpful? Give feedback.
All reactions