Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught exception not thrown in DevTools #5698

Closed
ben-x-dev opened this issue Nov 14, 2019 · 7 comments
Closed

Uncaught exception not thrown in DevTools #5698

ben-x-dev opened this issue Nov 14, 2019 · 7 comments
Labels
stage: needs investigating Someone from Cypress needs to look at this stale no activity on this issue for a long period type: bug

Comments

@ben-x-dev
Copy link

ben-x-dev commented Nov 14, 2019

Current behavior:

The rightclick method is throwing an error unlike trigger('contextmenu'). As you can see from the screenshot below, the right click works because the context menu opens up but cypress' test fails. Can't see any js error doing the right click on the page being tested.
image

Desired behavior:

It should work just like trigger('contextmenu'). Using that is the current workaround to allow tests like this to pass.

Steps to reproduce: (app code and test code)

Try this simple test:

context('App Tests', () => {
  beforeEach(() => {
    cy.visit('https://design.infor.com/code/ids-enterprise/latest/demo/components/datagrid/test-contextmenu-firstclick.html');
  })

  it('test right click', () => {
    cy.get('[aria-rowindex="1"] > [aria-colindex="1"] > .datagrid-cell-wrapper').rightclick();
  });
});

Versions

latest

@jennifer-shehane
Copy link
Member

.rightclick() by design does not behave exactly like .trigger('contextmenu'), it takes into account several over things that occurs when a user would normally rightclick and triggers other events accordingly (like mouseover for example).

If you solely want to trigger the event, then using .trigger() is the correct workaround.

When you see Cypress mentioning an uncaught exception thrown from a cross origin script. So this error could be triggered during other events outside of contextmenu (like mouseover).

This situation is strange the error is no longer printing to the console when Cypress catches it. This is a bug and we should have someone look into this.

You can ignore uncaught:exceptions by adding the code below:

Cypress.on('uncaught:exception', (err, runnable) => {
  // returning false here prevents Cypress from
  // failing the test
  return false
})

context('App Tests', () => {
  beforeEach(() => {
    cy.visit('https://design.infor.com/code/ids-enterprise/latest/demo/components/datagrid/test-contextmenu-firstclick.html')
  })

  it('test right click', () => {
    cy.get('[aria-rowindex="1"] > [aria-colindex="1"] > .datagrid-cell-wrapper').rightclick()
  })
})

When adding this code, then rerunning the Cypress test - we now see an error in the devTools console. It appears that an error is being thrown through the popup menu widget during keydown events - where this is undefined.

I'm not sure why keydown events would be fired during .rightclick() and will have to check with @bkucera, but I would think this is not intended.

Screen Shot 2019-11-14 at 11 29 32 AM

Screen Shot 2019-11-14 at 11 30 36 AM

@ben-x-dev
Copy link
Author

Thanks! Looks like you figured out the root of the problem already.
Btw it would really help to include something like this in the docs:

Add this to print your application's error stack trace on the devTools console:
Cypress.on('uncaught:exception', () => false);

@jennifer-shehane
Copy link
Member

jennifer-shehane commented Nov 15, 2019

@nbcp This is not the designed behavior - this is a bug. The uncaught exception should be thrown to the DevTools.

We found the root of the issue though, which is a bit confusing how this is related, but the popup's third party code was at some point evaluating window as undefined, which is why the error was being thrown in the first place.

The code for the essential issue here is done in cypress-io/cypress#5709, but has yet to be released. The code above will run without exception when that is released.
We'll update this issue and reference the changelog when it's released.

@jennifer-shehane jennifer-shehane added stage: pending release type: bug and removed stage: needs investigating Someone from Cypress needs to look at this labels Nov 15, 2019
@jennifer-shehane jennifer-shehane changed the title Rightclick method issue Uncaught exception not thrown in DevTools Nov 15, 2019
@jennifer-shehane
Copy link
Member

Actually, I am going to reopen this to track the issue of the uncaught exception not being thrown to DevTools.

@jennifer-shehane jennifer-shehane added the stage: needs investigating Someone from Cypress needs to look at this label Nov 15, 2019
@ben-x-dev
Copy link
Author

Sweet! Thanks @jennifer-shehane

@cypress-app-bot
Copy link
Collaborator

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.

@cypress-app-bot cypress-app-bot added the stale no activity on this issue for a long period label May 17, 2023
@cypress-app-bot
Copy link
Collaborator

This issue has been closed due to inactivity.

@cypress-app-bot cypress-app-bot closed this as not planned Won't fix, can't repro, duplicate, stale Jun 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stage: needs investigating Someone from Cypress needs to look at this stale no activity on this issue for a long period type: bug
Projects
None yet
Development

No branches or pull requests

3 participants