-
-
Notifications
You must be signed in to change notification settings - Fork 747
-
I am writing some custom logging, due to our crazy system. I have all of it in place except 1 thing, I can't figure out how to grab the current test in the After hook... neither _after as a helper or After() as a Scenario header. You can pass "test" to a before, but you can't with an After. Any ideas how I can access the current Test?
If running a Break point in the "After" block the debugger gives a reference to a "currentTest" block that has all the information I need, but I can't find a way to access it.
After(async ({I}) => {
if(testPassed)
doThis()
else
DoThat()
});
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 1 comment
-
@Todaichi looks like you can use https://codecept.io/hooks/#event-listeners as a helper, smth like
const {Helper, event} = require('codeceptjs');
class SomeHelper extends Helper {
/**
* Constructor
* @param config
*/
constructor(config) {
super(config);
event.dispatcher.on(event.test.after, function (test) {
console.log(test)
})
}
}
module.exports = SomeHelper;
will give you access to test object after his execution.
Beta Was this translation helpful? Give feedback.