Playing better with Cypress

This item is very much related to: Exception in nrWrapper
But the other one is closed, so trying to re-raise the discussion here.

Cypress and NewRelic does not play nicely.

Just ignoring the error on the cypress using some form of :


Is obviously just ignoring it and we want to avoid this, not ignore it…

At least in our case, we also do not want to load newrelic JS on cypress tests in any case.
So there are two obvious options:

  1. In the case of cypress tetsing, block the load of newrelic scripts.
  2. Or, In the case of cypress testing, do not load the newrelic scripts.

The first option, which means, in the cypress browser, use “blockHosts” and block scripts from ‘’ does not work because the issue is already on the bootstrap script in the ‘NREUM’ thingi.
The second option might be possible, e.g. somehow detecting cypress on the newrelic agent and not serving the NREUM script.
Basically sending a flag from cypress to skip this, (as an example on the python agent):

I am wondering if anyone else is coming across this and found a good solution.

Welcome to the community @avner1. :slight_smile: Definitely interested in hearing solutions from other community members. Also wanted to share this doc Compatibility and requirements for Browser Monitoring that includes specs for Cypress that could be helpful.

he problematic piece of code seems to be:

But it seems that when running through cypress, params doesn’t exist on t.

Can we simply not conditionally run this piece, or actually handle the error?

if(t.params){ t.params.status=e.status; ... }

for example. I’ve not looked too hard at which this code does though.

@avner1 Thanks for the question here!

While in the future, we’re looking at the browser agent so that it plays better with Cypress, I found this community thread that may help in pointing you toward a solution. There are a few topics that veer into different directions on this one, but one or two possible solutions from others so I wanted to make you aware of it.

Exception in nrWrapper

Hope that helps, thank you!