I am trying to access the file name each test runs in from the afterTest hook in my wdio config file. However, none of the parameters provided to the hook includes the file name. I tried maybe getting the file name from the onWorkerStart hook, since the specs parameter provided to that hook includes the file name, so something like this:
onWorkerStart(cid, caps, specs) {
const fileName = specs[0];
}
But I'm not sure how to access the fileName variable I created in the onWorkerStart hook in my afterTest hook. I tried maybe using it as a global variable:
onWorkerStart(cid, caps, specs) {
global.fileName = specs[0];
}
afterTest() {
console.log(global.fileName);
}
But this just prints "undefined". And if I print it from the onWorkerStart hook too, it does in fact print the name of the file from there first, but then "undefined" from the afterTest hook.