question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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 })
  })
})

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:17 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
github-actions[bot]commented, Dec 14, 2021

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.

1reaction
you1annacommented, Jul 7, 2022

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: Cannot read property 'isTTY' of undefined
I have installed twilio latest version in my angular project. But when the project runs, it says that "Cannot read property 'isTTY' of...
Read more >
cannot read properties of undefined (reading 'snapshot')
When I call toMatchImageSnapshot() function, it will give me the below error. TypeError: Cannot read properties of undefined (reading '_counters'). Open side ...
Read more >
How to Avoid the Infamous "Cannot read properties of ... - Bitovi
With TypeScript, there are two ways of interpreting null and undefined ... avoid the 'Cannot read properties of undefined' runtime TypeError.
Read more >
Prevent “Cannot read property '…' of undefined” errors with ...
Every developer who did some JavaScript has got errors like “Cannot read property '…' of undefined”. There is one simple way to prevent...
Read more >
percy-cypress - bytemeta
[TypeScript] percySnapshot - TypeError: Cannot read properties of undefined (reading 'isTTY'). Previous Next. Make software development more efficient, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found