cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
47.02k stars 3.18k forks source link

cy.log in Cypress.on(..) swallows the subject #14270

Closed psech closed 3 years ago

psech commented 3 years ago

It looks very similar to https://github.com/cypress-io/cypress/issues/8084

Current behaviour

/support/index.js

Cypress.on('uncaught:exception', (err, runnable) => {
  cy.log('Uncaught Exception', err);
  return false;
});

Spec

cy.get(selectors.archive.archiveNameInput)
  .clear()
  .type(archiveName);

Somewhere around clear() we face an uncaught:exception

Args: TypeError: The following error originated from your application code, not from Cypress. > Cannot set property 'status' of undefined

In Cypress, we experience the following

cy.type() failed because it requires a DOM element.

The subject received was:

  > null

The previous command that ran was:

  > cy.log()
cypress

When I comment out the cy.log('Uncaught Exception', err); it works fine.

Desired behaviour

The cy.log should not swallow the subject.

Versions

Cypress: 6.20 Chrome: 87 macOS Big Sur: 11.1

jennifer-shehane commented 3 years ago

Duplicate of https://github.com/cypress-io/cypress/issues/6316

Calling Cypress commands does not work outside of the context of a test - so does not work when called within a Cypress event listener.