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

How to test a component with a Popover inside #765

Closed
MaximeConan opened this issue Jul 2, 2021 · 2 comments
Closed

How to test a component with a Popover inside #765

MaximeConan opened this issue Jul 2, 2021 · 2 comments

Comments

@MaximeConan
Copy link

Hi everyone,

I'm actually trying to add unit tests on a component which contains de Popover inside and if I simulate a click on the Trigger, I have the following error : DOMRect is not defined

The test implementation is really basic, I use jest and react-testing-library and I simulate my click like this :

 const trigger = getByTestId('__protected-input-trigger__')
 fireEvent.click(trigger)

The trigger :

<PopoverTrigger
  data-testid="__protected-input-trigger__"
  as={Button}
  tabIndex={0}
  state="tertiary"
  size="small"
>
    <Pencil1Icon />
</PopoverTrigger>

Has someone the same behaviour ?

Thanks by advance !

@benoitgrelard
Copy link
Collaborator

Hi @MaximeConan,

It sounds like you'd need to mock that class as it's not a real DOM environment.
Have a look at this comment here: #420 (comment)

I'll close your issue for now, but feel free to keep discussing or reopen it if this doesn't fix your issues.

@MaximeConan
Copy link
Author

MaximeConan commented Jul 2, 2021

You are awesome @benoitgrelard , thank you ! 🎉

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

2 participants