You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1) page
works:
The following error originated from your test code, not from Cypress.
> expected 'The following error originated from your application code, not from Cypress.\n\n > Uncaught Muahahaha!\n\nWhen Cypress detects uncaught errors originating from your application it will automatically fail the current test.\n\nThis behavior is configurable, and you can choose to turn this off by listening to the `uncaught:exception` event.' to equal 'Error: Uncaught Muahahaha!'
When Cypress detects uncaught errors originating from your test code it will automatically fail the current test. (and Mocha's done() called multiple times)
+ expected - actual
-'The following error originated from your application code, not from Cypress.\n\n > Uncaught Muahahaha!\n\nWhen Cypress detects uncaught errors originating from your application it will automatically fail the current test.\n\nThis behavior is configurable, and you can choose to turn this off by listening to the `uncaught:exception` event.'
+'Error: Uncaught Muahahaha!'
AssertionError: The following error originated from your test code, not from Cypress.
> expected 'The following error originated from your application code, not from Cypress.\n\n > Uncaught Muahahaha!\n\nWhen Cypress detects uncaught errors originating from your application it will automatically fail the current test.\n\nThis behavior is configurable, and you can choose to turn this off by listening to the `uncaught:exception` event.' to equal 'Error: Uncaught Muahahaha!'
When Cypress detects uncaught errors originating from your test code it will automatically fail the current test.
at $Cy.eval (webpack://cypress-test-tiny/./cypress/e2e/spec.cy.js:7:29)
Desired behavior
uncaught:exception should be given the uncaught error from the app like the docs say.
/// <reference types="cypress" />describe('page',()=>{it('works',(done)=>{// this event will automatically be unbound when this// test ends because it's attached to 'cy'cy.on('uncaught:exception',(err,runnable)=>{expect(err.message).to.equal('Error: Uncaught Muahahaha!')// using mocha's async done callback to finish// this test so we prove that an uncaught exception// was throwndone()// return false to prevent the error from// failing this testreturnfalse})cy.visit('/')cy.get('button').click()})})
Cypress Version
13.7.0
Node version
21.7.1
Operating System
macOS 14.2.1
Debug Logs
No response
Other
No response
The text was updated successfully, but these errors were encountered:
This used to work for us, but in the past few months we now see the Cypress error wrapping our error. I'm not positive if it used to only be our error that came through to the callback, or if our message was being unwrapped.
That is, I'm not sure if exact equals on err.message was working because our test was doing expect(err.message).to.contain('Failed to load Google Captcha API') and that was working. For the past couple months we've been seeing:
expected 'The following error originated from your application code, not from Cypress. It was caused by an unhandled promise rejection.\n\n > An unknown error has occurred: [object Event]\n\nWhen Cypress detects uncaught errors originating from your application it will automatically fail the current test.\n\nThis behavior is configurable, and you can choose to turn this off by listening to the uncaught:exception event.' to include 'Failed to load Google Captcha API'
Which, that'd be fine, except for some reason our message gets converted to [object Event]. 🤔
Current behavior
The instructions on https://docs.cypress.io/api/cypress-api/catalog-of-events#To-catch-a-single-uncaught-exception on how to catch a single uncaught exception from the app do not work.
uncaught:exception
is being given the cypress runner error and not the uncaught error from the application.Desired behavior
uncaught:exception
should be given the uncaught error from the app like the docs say.Test code to reproduce
https://github.com/steinybot/cypress-test-tiny/tree/uncaught-exception-in-test
Cypress Version
13.7.0
Node version
21.7.1
Operating System
macOS 14.2.1
Debug Logs
No response
Other
No response
The text was updated successfully, but these errors were encountered: