davidjbradshaw / iframe-resizer

Keep iFrames sized to their content.

Home Page:https://iframe-resizer.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can I write a test to test what happens when iframeresizer onMessage is invoked?

msarauer opened this issue · comments

Is there a way to simulate onMessage being invoked in react-testing-library? I've tried:

      const iframe = screen.getByTitle('iframe') as HTMLIFrameElement
      const TEST_MESSAGE = 'test-message'
      iframe.contentWindow?.postMessage(TEST_MESSAGE, window.location.origin)

but that doesn't seem to work.

Good question, I think that is more for Stack Overflow