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

Trigger hover to check a tooltip with Angular (v5) and Material #953

Closed
maxime1992 opened this issue Nov 23, 2017 · 4 comments
Closed

Trigger hover to check a tooltip with Angular (v5) and Material #953

maxime1992 opened this issue Nov 23, 2017 · 4 comments

Comments

@maxime1992
Copy link

maxime1992 commented Nov 23, 2017

Current behavior:

I cannot display a tooltip built with Angular Material

Desired behavior:

Trigger hover to show the tooltip

How to reproduce:

Here's a stackblitz repro with the editor:

https://stackblitz.com/edit/angular-material2-issue-iyyert

And the same but just the app running into the browser:

https://angular-material2-issue-iyyert.stackblitz.io

Test code:

  cy.get('span').invoke('trigger', 'mouseover');
  cy.get('mat-tooltip-component').contains('Tooltip!');

Additional Info (images, stack traces, etc)

Related to #10

  • Operating System: Ubuntu 17.10 - 64 bits
  • Cypress Version: 1.1.1
  • Browser Version: Chrome 62.0.3202.89
@brian-mann
Copy link
Member

Using invoke('trigger') is simply calling the "trigger" method on the jquery wrapped DOM element. Since angular isn't bound to jquery events, that's why its not triggering.

You never have to do this anymore, because our own (and very real) cy.trigger() now exists and works in every situation you would have otherwise used invoke('trigger').

Change to that and it will work.

I have updated my comments on that old issue, and we have lots of docs in many places explaining this.

#10 (comment)

@azollai
Copy link

azollai commented Sep 25, 2018

It was only working to me with .trigger('mouseenter'). None of 'mouseover' and 'hover' was working.

Also: be sure that you are getting the right element with the tooltip directive before your .trigger call :)

@palakdua27
Copy link

@azollai , still not working for me :-
cy.get('[data-testid="SortByTitle"]').trigger('mouseenter')

@maxime1992
Copy link
Author

maxime1992 commented Oct 30, 2020

@brian-mann you said:

You never have to do this anymore, because our own (and very real) cy.trigger() now exists and works in every situation you would have otherwise used invoke('trigger').

But Cypress doc seems to have a different opinion on that:

image

I did what azollai mentionned and it worked though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants