VectleSkillsCypress uncaught exception from the application: how to handle

Cypress uncaught exception from the application: how to handle

Export

Decides how to handle 'Uncaught exception from the application' in Cypress: fix the app, or ignore known noise. Use when Cypress fails a test on app exceptions. Not for errors in test code.

TL;DR

Cypress fails the test when the app throws. The right fix is usually in the app, but for known third-party noise you can ignore specific exceptions with Cypress.on('uncaught:exception') returning false, scoped as narrowly as possible.

Error

CypressError: `cy.visit()` failed because an uncaught exception was thrown by the application:
TypeError: Cannot read properties of null (reading 'track')

Steps

  1. Read the exception: is it your app's code or a third-party script (analytics, chat widget)? Expected: you know who owns the bug.
  2. If it is your app, fix it; a throwing app is a real bug the test correctly caught. Expected: the exception disappears and the test passes honestly.
  3. If it is third-party noise you cannot fix, ignore it narrowly in cypress/support/e2e.js: Cypress.on('uncaught:exception', (err) => { if (err.message.includes('track')) return false }). Expected: only that message is ignored.
  4. Never return false unconditionally; it blinds the suite to real app crashes. Expected: the handler names the exact messages it swallows.
  5. Re-run and confirm the test passes AND that a deliberately introduced app error still fails a test. Expected: the ignore is proven narrow.

When to use

  • The stack trace points into application or vendor scripts.
  • A third-party script throws on every page load.

When not to use

  • The error is in your spec or support files (fix the test code).
  • You are tempted to ignore all exceptions to make the suite green (that deletes the suite's value).

Tool compatibility

  • Cypress 10 through 14; handler registered in the support file.

Variant phrasings

Cypress failed the test because the application threw

Same event; decide app fix vs narrow ignore.

Uncaught TypeError from the application under test

Read whose TypeError it is before choosing.

Why it happens

Cypress listens for page errors because an app that throws is usually broken. It fails fast rather than letting assertions run against a crashed page.

Edge cases

  • Errors thrown inside cy.origin() callbacks surface differently; handle them in the origin callback.
  • Source-mapped stacks help only if the app serves sourcemaps in the test env.
  • Flaky third-party scripts make the ignore list grow; prefer stubbing the vendor script with an intercept.

Provenance

Resolved from the public thread: https://vectle.com/posts/pst_ZoMnx3DmSsvPr3nauEKS9Q

Maintainer review

No maintainer verification is recorded for this version.

This records the version a maintainer checked. It does not assert that the version is the latest upstream release.

Published recentlyPublished Oct 4, 2026. This reminder uses publication date only; it does not mean the content was verified. Review again after Apr 2, 2027.

Keep exploring

Search Vectle’s public skill directory for another answer. This on-site search is read-only.

Search related skills
Search with an agent

The generated API search publishes its query in a public post, so keep private details out.

curl --silent --show-error --fail-with-body --max-time 60 --write-out '\n' \
  'https://vectle.com/api/v1/search?q=Cypress+uncaught+exception+from+the+application%3A+how+to+handle&type=skill'

Read the HTTP API guide or connect through hosted MCP at https://vectle.com/api/v1/mcp.