-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Option to enable shallow rendering #995
Comments
I think adding a new |
FYI, I am trying v3 alpha and there is a problem with storyshots addon and the fact that it try to require "react-test-renderer/shallow" which does not exist in react 16 alpha (which is require since the last 3 "stable" react-native releases...) |
Thanks for the heads up @MoOx, this was a mistake. |
This little snippet works fine for me! |
@heinzmuller feel like sending a PR to add it to |
@tmeasday I'll try to get a PR for this later this evening |
Working for me, feel free to close this issue :) |
@MoOx You can close this issue yourself I think? |
Let's leave this open until it is merged and released. |
@tmeasday I forgot to test, but will decorators make it so the shallow snapshot is only the decorator? If they do, we could probably add for how to conditionally add decorators when not running jest tests (I already do this for some snapshots) I'll test this later also |
Released. 🎉 Closing 😀 |
@heinzmuller Yes, your concern is right, decorators are added to the snapshot, so component under story is not rendered at all. I am afraid that conditionally adding decorators is not an option when decorators provide context to component under story, e.g. my stories are decorated with Thus we need to find a way to omit decorators in outputed snapshot, but still render them to provide context. |
@irnc I've been pondering this one a little bit. If you were writing a shallow snapshot test case by hand that required some kind of context, how would you do it? i.e. what does the raw code look like? I've been trying to figure out how we can take the right snapshot but still have the context. |
I don't know, I newer used shallow rendering before storyshots. Looking into Looking into |
Given that the current semantics of a story and a decorator is that they could return multiple nested elements, we couldn't expect it to work for shallow rendering. For shallow rendering to make sense, we need to constrain story function to return only one element (i.e. element without children), and decorators accounted separately from story function. If needed to separate context setting decorators from stories, we would split That should be considered a breaking change, as decorators may be used as integral part of a story rendering. Thus we shouldn't change |
Hmm, yes I was thinking about this possibility, but it's not very user-friendly, there are a lots of use-cases where you want to use a
I'm not sure what you mean by this? |
Did any of you ever find a solution to shallow render snapshots but omit the decorator? |
Currently snap are by default fully rendered. I found this not optimal in some cases (especially for complex components that have a lots of children).
I didn't find any option to enable shallow rendering that would produce lighter snaps.
Are you open for such an addition? (eg: shallowRendering option)
The text was updated successfully, but these errors were encountered: