Hi, I implemented the event listener feature to push results to browser stack at the end of execution. Now my tests are being migrated as Cucumber feature files and scenarios. I’d like to know what would be the equivalent of event.test.passed for bdd scenario and also how to fetch the scenario name. Can someone help?
module.exports = function () {
event.dispatcher.on(event.test.passed, function (test) {
let testName = test.title.replace(/[&/\#,+()$~%.'":*?<>{}]/g, “”);
I.executeScript(
browserstack_executor: {"action": "setSessionName", "arguments": {"name": "${testName}"}}
);
I.executeScript(
‘browserstack_executor: {“action”: “setSessionStatus”, “arguments”: {“status”:“passed”,“reason”: “Test Passed!”}}’
);
});
event.dispatcher.on(event.test.failed, function (test, error) {
let testName = test.title.replace(/[&/\#,+()$~%.‘“:*?<>{}]/g, “”);
const errorMessage = String(
error.message
.replace(/[\r\n]/g, “”)
.replace(/”/g, “”)
.replace(/’/g, “”)
);
I.executeScript(
browserstack_executor: {"action": "setSessionName", "arguments": {"name": "${testName}"}}
);
I.executeScript(
browserstack_executor: {"action": "setSessionStatus", "arguments": {"status":"failed","reason": "${errorMessage}"}}
);
});
};