Scenario name using Codecept and Cucumber

Hello)
I use CodeceptJs with Cucumber. For reporting in LambdaTest need to get Scenario name from Ccucumber.
Trying to use Behavior Driven Development | CodeceptJS
ex:
‘use strict’;

Before((test) => {
// eslint-disable-next-line no-console
console.log(‘!!!’ + test.Scenario.title);
});

But in my view dont see Before execution at all… Log is empty.
Please can you give an advice?

Hi, I don’t know if I understand your question very well, but I have a similar problem.
I found an outlet for something that might help you.

Using the Custom plugin you can create a script

After that I created a scprit using the internal API

my script looked like this:

const { event } = require('codeceptjs');

let ScenarioName = '';

module.exports = function () {
  event.dispatcher.on(event.test.before, test => {
    ScenarioName = test.title;
    console.log(ScenarioName);
  });
};

module.exports.ScenarioName = ScenarioName;

is working, it prints in the console the name of the scenario.
If you need, I’ll explain better how to put it.

But the problem I’m facing is that to get the name it executes reading the codecept.conf and I would like to put the scenario name inside my Appium helper, in

exports.config = {
  output: './output',
  helpers: {
    Appium: {
      app: process.env.APP,
      host: 'hub-cloud.browserstack.com',
      port: 4444,
      platform: process.env.PLATFORM,
      user: process.env.BROWSERSTACK_USER,
      key: process.env.BROWSERSTACK_APIKEY,
      desiredCapabilities: {
        build: process.env.BUILD,
        device: process.env.DEVICE,
        name: **ScenarioName**,
        os_version: process.env.OS_VERSION,
        idle_timout: 900,
        automationName: process.env.AUTOMATION_NAME,
        noReset: false,
        newCommandTimout: '90',
        autoGrantPermissions: true,
        disableAnimation: true,
      },
    },

but it is not being possible because, first he sends the capabilities and then runs the script of the scenario.