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

119
Views
Is there a way to share fixtures while using cy.fixture in class between methods

I am doing my first steps in Cypress and issue which I meet is that I replicate the code so I wish to make it better. I've tried to use cy.fixture in a constructor but it failed, so I am looking for a way to use cy.fixture only once in class and assign result to this which can be used in other methods.

class LoginPage{

navigate(){
    cy.fixture('urls.json').then((url) => {
        cy.visit(url.baseUrl);
    })
}

checkIfRedirected(){
    cy.reload()
    cy.fixture('urls.json').then((url) => {
        cy.url().should('equal', url.claimUrl)
    })
}

}

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

It is possible to import the fixture at the top of the LoginPage

import url from './cypress/fixture/urls.json'

class LoginPage {

  navigate() {
    cy.visit(url.baseUrl);
  }

  checkIfRedirected(){
    cy.reload()
    cy.url().should('equal', url.claimUrl)
  }
}
about 4 years ago · Juan Pablo Isaza Report
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!