https://cypress.io logo
Hey, I am starting to introduce Cypress to our com...
# e2e-testing
w
Hey, I am starting to introduce Cypress to our company and am writing the first e2e tests right now. We are using a CookieBanner from CodeCentric which I would like to disable programatically. Working with
cypress open
and having an actual browser where the test runs the following code is working:
Copy code
ts
beforeEach(() => {
    Cypress.on("window:before:load", (window) => {
    window.localStorage.setItem("some_key", "some_value")
    window.localStorage.setItem("another_key", "another_value");
  })
})
But running this with
cypress run --headless --browser electron
does not work and it seems like that the items are not set inside
localStorage
. I tried to check it with
Copy code
ts
expect(localStorage.getItem("some_key")).to.not.be.null;
expect(localStorage.getItem("another_key")).to.not.be.null;
Is there a way to set some
localStorage
items in the headless mode to get rid of my cookie banner?