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

@storybook/addon-storyshots: Inconsistency in framework string for react-native. #3375

Closed
dawnmist opened this issue Apr 6, 2018 · 5 comments

Comments

@dawnmist
Copy link

dawnmist commented Apr 6, 2018

I have been working on putting together a typescript definition file for the storyshots addon, and when tracking through options provided to functions in the code noticed that the 'framework' string for react-native changes from 'react-native' to 'rn' when the react-native loader is used.

Affected lines:
https://github.com/storybooks/storybook/blob/9b3f63b304c381db4457449c32d37f03ce8e0a9a/addons/storyshots/src/rn/loader.js#L6-L9
https://github.com/storybooks/storybook/blob/9b3f63b304c381db4457449c32d37f03ce8e0a9a/addons/storyshots/src/rn/loader.js#L18-L23

Is this string supposed to be different in the Context information to what is required in the initStoryshots function options? It looked like the change in value may have been an oversight from refactoring, so I figured I'd check, as I need to specify the correct list of values in both the Context and the Options framework values for the typescript type definitions.

@igor-dv
Copy link
Member

igor-dv commented Apr 6, 2018

'rn' is used internally only. It is used to prevent image snapshots to be called for rn.

@dawnmist
Copy link
Author

dawnmist commented Apr 7, 2018

The output from the load function is used when creating the context information that is passed to the options.test function, so it is leaking out into user code as well.
https://github.com/storybooks/storybook/blob/9b3f63b304c381db4457449c32d37f03ce8e0a9a/addons/storyshots/src/index.js#L39
https://github.com/storybooks/storybook/blob/9b3f63b304c381db4457449c32d37f03ce8e0a9a/addons/storyshots/src/index.js#L56
https://github.com/storybooks/storybook/blob/9b3f63b304c381db4457449c32d37f03ce8e0a9a/addons/storyshots/src/index.js#L82-L90
If the user does not set a test function but does set a custom renderer, it leaks through into the custom renderer via the context information that is sent to the default snapshotWithOptions test function.
https://github.com/storybooks/storybook/blob/9b3f63b304c381db4457449c32d37f03ce8e0a9a/addons/storyshots/src/test-bodies.js#L4-L10
Anywhere where the context value is passed to is receiving the 'rn' value rather than the initial 'react-native' value for the framework field in the context.

@igor-dv
Copy link
Member

igor-dv commented Apr 7, 2018

I see. So probably changing it back to the 'react-native' will be a good thing.

@stale
Copy link

stale bot commented Apr 28, 2018

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Apr 28, 2018
@stale
Copy link

stale bot commented May 28, 2018

Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants