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

ResizeObserver is not defined in testing #1673

Closed
3 of 10 tasks
efriandika opened this issue May 16, 2023 · 5 comments
Closed
3 of 10 tasks

ResizeObserver is not defined in testing #1673

efriandika opened this issue May 16, 2023 · 5 comments
Assignees
Labels
community For issues that have been raised by folks outside the core Salt team priority: medium 😠 testing type: documentation Improvements or additions to documentation

Comments

@efriandika
Copy link

efriandika commented May 16, 2023

Package name(s)

Core v1.4.0 (@salt-ds/core)

Description

I just added SaltProvider to our team react app,
Then I get this below error when running our unit test:

ResizeObserver is not defined
ReferenceError: ResizeObserver is not defined

Steps to reproduce

Add SaltProvider to our team react app,
Then create a unit test.

Expected behavior

There is better way to handle ResizeObserver

Operating system

  • macOS
  • Windows
  • Linux
  • iOS
  • Android

Browser

  • Chrome
  • Safari
  • Firefox
  • Edge

Are you a JPMorgan Chase & Co. employee?

  • I am an employee of JPMorgan Chase & Co.
@efriandika efriandika added status: awaiting triage Automatically added to new issues. Should be removed once they have been triaged. type: bug 🪲 Something isn't working labels May 16, 2023
@efriandika efriandika changed the title ResizeObserver is not defined ResizeObserver is not defined in testing May 16, 2023
@efriandika
Copy link
Author

Currently by adding:

class ResizeObserver {
can solve this.

However, It would be great if there is a better way to handle this out of the box

@origami-z
Copy link
Contributor

This is a limitation of your unit test framework (assuming jsdom). Nothing really can be done from Salt side.

@origami-z origami-z removed the status: awaiting triage Automatically added to new issues. Should be removed once they have been triaged. label May 22, 2023
@efriandika
Copy link
Author

Thanks for the reply @origami-z ,
I know it's limitation of JSdom. If you think it really can't be done from salt side. I suggest that it worth to mention in documentation.

@origami-z origami-z added the type: documentation Improvements or additions to documentation label May 22, 2023
@james-nash james-nash added the community For issues that have been raised by folks outside the core Salt team label May 25, 2023
@james-nash

This comment was marked as outdated.

@joshwooding
Copy link
Contributor

joshwooding commented Jul 10, 2023

Hi @efriandika, sorry for the slow reply. As @origami-z said, this is a limitation of JSDom and quite a common one. I would either recommend using a test framework which has support for browser features or poly-filling/mocking it.

I think you'll run into this with almost any component library so I'm not sure how critical it is to document, as other component libraries seem not to document it.

I will close this for now, and if it has a lot of support, we can revisit this decision.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community For issues that have been raised by folks outside the core Salt team priority: medium 😠 testing type: documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants