percy-cypress: [TypeScript] percySnapshot - TypeError: Cannot read properties of undefined (reading 'isTTY')

The problem

Running percy exec -- cypress run gives me the following errors:

TypeError: Cannot read properties of undefined (reading 'isTTY')
      at PercyLogger.write (http://localhost:3000/__cypress/tests?p=cypress/support/index.js:5511:27)
      at PercyLogger.log (http://localhost:3000/__cypress/tests?p=cypress/support/index.js:5498:12)
      at Object.isPercyEnabled (http://localhost:3000/__cypress/tests?p=cypress/support/index.js:5839:11)
      at async Context.eval (http://localhost:3000/__cypress/tests?p=cypress/support/index.js:5148:10)

I was able to narrow down where the error/failed tests were stemming from, and it looks like all my tests pass if I comment out lines where I’m using percyScreenshot. The odd thing is that running cypress open works fine and passes all tests as expected.

Environment

  • Node version: 14.18.0
  • @percy/cli version: 1.0.0-beta.70
  • Version of Percy SDK you’re using:
  • If needed, a build or snapshot ID:
  • OS version:
  • Type of shell command-line [interface]:

Code to reproduce issue

The error occurs exactly at line 7, so removing/deleting that line (cy.percySnapshot(...) results in a passing test.

const screenWidths = [375, 768, 1280]

describe("ordering stocks", () => {
  it("should visit homepage", () => {
    cy.visit("/")
    cy.findByText(/My text/)
    cy.percySnapshot("DSC homepage", { widths: screenWidths })
  })
})

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 19 (6 by maintainers)

Most upvoted comments

This issue is stale because it has been open for more than 14 days with no activity. Remove stale label or comment or this will be closed in 14 days.

Any updates on this, I get a similar error on Cypress v9.7.0 with the latest Percy installed

npx percy exec – cypress run --spec cypress/integration/RandR/Visual/*

     TypeError: Cannot read properties of undefined (reading 'write')
      at Function../node_modules/@percy/sdk-utils/dist/logger.js.logger.log (https://site1.dev/__cypress/tests?p=cypress/integration/RandR/Visual/pdf.spec.js:37669:53)
      at Object.info (https://site1.dev/__cypress/tests?p=cypress/integration/RandR/Visual/pdf.spec.js:37615:29)
      at Object.isPercyEnabled (https://site1.dev/__cypress/tests?p=cypress/integration/RandR/Visual/pdf.spec.js:37815:11)
      at async Context.eval (https://site1.dev/__cypress/tests?p=cypress/integration/RandR/Visual/pdf.spec.js:37450:10)

Any ideas?

was a resolution to this? I’m getting this sporadically in my build environment it will be 1 out of 300 test maybe but enough to be annoying.

We are on Cypress 9.6.1 and just using cypress default prepossessing with webpack.