Skip to content
Discussion options

You must be logged in to vote

I finally found the solution to my own answer.

I was correctly trying to click on the dropdown by using screen.getByRole('button', {name:'Show'}). However, there was always an error message saying:

ReferenceError: ResizeObserver is not defined

Because of that it couldn't open the dropdown.

Everything was working as expected, as soon as I mocked global.ResizeObserver using this article. Here's a full example for anyone facing the same issue:

describe('MyComponent', () => {
  beforeAll(() => {
    global.ResizeObserver = class ResizeObserver {
      observe() {
        // do nothing
      }
      unobserve() {
        // do nothing
      }
      disconnect() {
        // do nothing
      }

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by julisch94
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant