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

97
Views
How can I exclude script tag from Cypress run?

I have a script tag that has to be active in production but can't be called when Cypress is running. As we run Cypress against our prod build as well, I can't use process.env.NODE_ENV to exclude it.

Is there any way to exclude a piece of code when Cypress is running?

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

0

As long as you can identify the the script exactly, you can modify the page source before it loads with cy.intercept()

cy.intercept(url, (req) => {
  req.continue((res) => {
    const scriptToRemove = '<script something-that-defines-the-script></script>'
    res.body = res.body.replace(scriptToRemove, '')
  })
}).as('page')

cy.visit(url)

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!