Is there a way to constructor inject dependencies to cypress cucumber step classes. I am using cypress-cucumber-preprocessor. I have some service classes and it will be convenient if there is a way to inject them instead of manually initializing them inside the steps. If I declare a class as below, the compiler is not happy. If we can not achieve what I have coded below, Is there a way to initialize an instance that lives within the scenario lifetime and is available to all steps? Thanks in advance.
import { Before, After, Given, When, Then } from 'cypress-cucumber-preprocessor/steps';
import { LoginPage } from "../../../support/PageObjects/LoginPage";
export class Login {
constructor(private service:MyService)
{
}
Given("I am logged in", () => {
let bla = service.method1();
});
When("I navigate to {menuItem}", (menuItem) => {
let blabla = service.method2();
});
} ```