Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

114
Views
How to constructor inject dependencies to cypress cucumber step classes

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();
       });

} ```
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!