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
Unable to get Storyshots working with storybooks/react-native 6.0.1-alpha.7. #323
Comments
@CameronSilverTXI hey thanks for reporting this and for the feedback. I'm not sure about how to get storyshots working but I will have a go soon. However please try reducing the version to 6.3 since 6.4 storybook isn't compatible with react native yet, that could be what's causing your issue. |
Hi @dannyhw , Thanks for the tip about trying version 6.3 of StoryShots - unfortunately it didn't seem to change the outcome. |
@CameronSilverTXI I'm experiencing a similar issue an issue as well using My init call:
My error is different though:
As a sanity check to see if the options to
But I receive the same error trace, suggesting either it's happening before configuration code is even reached, or that configuration is simply being ignored. |
I will at some point work on getting snapshots to work, however there are other issues I need to work on first. I will get to it though. If anyone wants to try in the meantime I'd be happy to assist. |
would a storybook/testing-react-native cover some of the same usecase? or is the snapshot functionality more important? |
Hey @dannyhw My jest setup is using the // jest.config.js
// https://docs.expo.dev/guides/testing-with-jest/#jest-configuration
const untranspiledModulePatterns = [
"(jest-)?react-native",
"@react-native(-community)?",
"expo(nent)?",
"@expo(nent)?/.*",
"@expo-google-fonts/.*",
"react-navigation",
"@react-navigation/.*",
"@unimodules/.*",
"unimodules",
"sentry-expo",
"native-base",
"react-native-svg",
"@storybook/react-native",
"@storybook/addon",
"@?dripsy",
"solito",
"moti",
]
const nodeModulesIgnorePattern = `node_modules/(?!(${untranspiledModulePatterns.join(
"|"
)}))`
module.exports = {
preset: "jest-expo",
transformIgnorePatterns: [nodeModulesIgnorePattern, "\\.pnp\\.[^\\/]+$"],
timers: "fake",
transform: {
"^.+\\.(js|ts|tsx)$": ["babel-jest", { cwd: __dirname }],
},
} The important bit here is that both @storybook/react-native and a few of the @storybook/addon-* modules require transformation by babel. You may need to add other modules to I then include my stories like this: // __tests__/storyshots.test.js
import initStoryshots from "@storybook/addon-storyshots"
import path from "path"
require(path.join(__dirname, "../.storybook/storybook.requires.js"))
initStoryshots({
framework: "react-native",
configPath: path.join(__dirname, "../.storybook/main.js"),
}) The important bit here is to require the |
@jorihardman hey thanks for sharing! Sorry about the lack of documentation, I've never really tried to use storyshots so I wouldn't have known where to start. This has helped me to understand a lot better the issue. I'll be happy to work on improving the experience with storyshots in the future especially now that I understand it a bit better. Thanks again for looking in to this. If you have suggestions on how to improve documentation or make the setup easier then I'd be happy to review/accept PRs and if not I can take on your input and add it to the TODO's 🙂 |
Describe the bug
Unable to run story-shots with
6.0.1-alpha.7
.To Reproduce
I followed the guide (which is excellent 👍 ) to add the alpha to my project, and Storybook itself works really well; however story-shots fails.
With story-shots configured to point to
.storybook
, I get the following error when runningyarn test
:If I set story-shots to point to
.storybook/main.js
, I get the following error when runningyarn test
:Code snippets
I created a minimal React-Native app to demonstrate the problem (again, using the guide):
System:
This isn't a huge blocker for us, since Storybook itself is far more beneficial than story-shots; however it's a nice additional test for automation.
Thanks for taking a look!
The text was updated successfully, but these errors were encountered: