cypress: Cannot read properties of undefined (reading 'cookies')
Current behavior
Not sure why, but every now and again multiple members of our team get the error above in the Cypress test window along with this stack trace:
TypeError: Cannot read properties of undefined (reading 'cookies')
at <embedded>:4613:284999
From previous event:
at $Cypress.automation (http://e2e.localhost:4000/__cypress/runner/cypress_runner.js:147779:12)
at Object.getCookies (http://e2e.localhost:4000/__cypress/runner/cypress_runner.js:140904:29)
at Object.clearCookies (http://e2e.localhost:4000/__cypress/runner/cypress_runner.js:140910:77)
at Object.clearCurrentSessionData (http://e2e.localhost:4000/__cypress/runner/cypress_runner.js:140901:127)
at http://e2e.localhost:4000/__cypress/runner/cypress_runner.js:140354:110
looks like something in the cypress runner that clears session between tests is failing.
Desired behavior
No response
Test code to reproduce
it’s inconsistent when it happens, so it’s hard for me to make a clear repro. But here is our cypress config:
import { defineConfig } from "cypress";
import { gql } from "@apollo/client";
import { makeAdminApolloClient } from "./src/utility/admin-gql-client";
import { readPdf } from "./src/utility/read-pdf";
export default defineConfig({
hosts: {
// normally, cypress doesn't work with subdomains of localhost; this makes
// it work
// https://github.com/cypress-io/cypress/issues/1488#issuecomment-396435553
"*.localhost": "127.0.0.1",
},
e2e: {
projectId: process.env.CYPRESS_PROJECT_ID,
baseUrl: process.env.CYPRESS_BASE_URL,
fileServerFolder: ".",
fixturesFolder: "./src/fixtures",
specPattern: "./src/integration/**/*.cy.{js,jsx,ts,tsx}",
modifyObstructiveCode: false,
supportFile: "./src/support/e2e.ts",
video: true,
screenshotsFolder: "./screenshots",
videosFolder: "./videos",
chromeWebSecurity: false, // allows to go cross-origin
retries: 3,
defaultCommandTimeout: 10_000,
});
Cypress Version
12.9.0
Node version
16.16.0
Operating System
macOS 13.2.1
Debug Logs
No response
Other
No response
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 1
- Comments: 32 (14 by maintainers)
We see this error occasionally when running our component tests in CI (Jenkins).