-
-
Notifications
You must be signed in to change notification settings - Fork 94
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 do you write tests for components using react-sizeme? #150
Comments
I have the same problem. The children are not rendered yet so the snapshot is not really that useful. Currently, I'm setting It would be great to have a solution to this issue. |
I have the following code in my jest setup file so it's configured globally and only effects the test environment: import sizeMe from "react-sizeme";
sizeMe.noPlaceholders = true; |
Good tip @kaitmore - we should add this to the docs. |
I am using a library that's using sizeme, and unfortunately it doesn't seem to be picking up the noPlaceholders global if I try and set it in my setupTests.js. Any ideas? |
thanks @kaitmore, works like a charm. |
@scottdickerson , I'm not using react-sizeme directly either, it is loaded through another component. And I don't have such a problem. Maybe the lib you're using gets loaded first before you test kicks in; therefore it is too late to set the global flag? just guess |
@scottdickerson check where your application's sizeme version and the library's sizeme version is the same. If not |
Workaround from @kaitmore should be added to the documentation. |
I'm using react-sizeme within create-react-app and am trying to write tests using jest.
When I try and do a snapshot test, this is the JSON.
How can I write tests that wait until the initial sizing render has finished? Would also be helpful to see how people write tests that adjust to different viewport widths (see unanswered question: https://stackoverflow.com/questions/46221210/jest-enzyme-how-to-test-at-different-viewports)
The text was updated successfully, but these errors were encountered: