-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Storyshots provide absolute vs relative path when a story is in storiesOf or CSF format when setting up custom directory #12513
Comments
That's pretty tricky and thank you for tracking it down. @jonniebigodes Unfortunately fixing the problem is probably a breaking change, so I think for now our best bet is to document this, maybe in the Storyshots README or in a section of the official docs that describes the StoryContext (which I don't think exists, but probably should) WDYT? |
Related: #7109 |
We are using both APIs in parallel, so we ended up with the following:
@shilman what do you think, does this look reliable? |
@latviancoder that's a pretty cool ... workaround is a nice way to say it 😄 |
@shilman like you've mentioned this is a breaking change, we could probably use the workaround supplied by @latviancoder in both the addon Readme and the workflows/snapshot page to expand visibility. @latviancoder as you've supplied (at the lack of a better word) a workaround, if you're willing create the pull request and i'll gladly review it and we could merge it. If not i can take care of it. I'll leave it up to you, just let me know. Also currently there's no concrete documentation for the StoryContext and it would be on our best interest to give some context to the community on how it works, we have brief references about it through out the documentation, but nothing concrete. I would be more than thankful for your help on this one. I'm going to take a look where we could place it and i'll let you know. |
In the workaround above the |
Chore: Update documentation for issue #12513
Chore: Update documentation for issue #12513
OK, I worked out the source of the problem here. The TLDR is that the issue stems from the Slightly more involved explanation:
So the fix here is to add the One other wrinkle: it's not exactly clear, but it looks like webpack doesn't actually return an absolute path for the filename from I suspect there might be dragons here, I'm not sure if we should rush this through for 6.1 or not. If someone wants to have a go at sending a PR to the babel plugin adding the |
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! |
I ran into this today using Storyshots with simple snapshot testing as well. Is there a workaround to continue to use CSF while also having the snapshots colocated within the component directories? |
This appears to still be an issue. Are there any changes that could help to sidestep it? |
@GriffinSauce the suggested that I provided worked for our scenario really well for us but if you have the capacity, I would strongly suggest to migrate to CSF or MDX stories as it solves a lot of incompatibility issues with newer versions of Storybook. |
Thanks @GasimGasimzada I was actually migrating to CSF and the problem appeared 😅 I managed to make it work with two actions:
Not very happy about the last thing... we're not using image snapshots (regular text snapshots) so I couldn't find anything like |
@GriffinSauce This is a long shot but you might be able to derive a class from Stories2SnapsConverter and sanitize the filename to your needs. I found it from their docs reference and it is specifically mentioned that:
|
The future of storyshots is the test-runner: And use the play function for expectations: We will not be making any improvement / changes to storyshots. |
Describe the bug
This is related to #10673 and #9084
I have been trying to understand this issue for a while now and finally I think I found the culprit for one of my problems. We have the following structure for saving visual test snapshots relative to components:
In order to achieve that, we are passing
getMatchOptions
function storyshots-puppeteer package'simageSnapshot
function. This function was very simple:This used to work fine with
storiesOf
format because the fileName that is provided forstoriesOf
stories are always in absolute format:However, with CSF stories, the path start relative to initial test suite:
This created the problem of stories being written to random location and it was hard to find because we are running our visual tests in a Docker container. Now that we know the reason, we have solved the issue by removing the absolute path ourselves and setting it up:
To Reproduce
Steps to reproduce the behavior:
getMatchOptions
functionExpected behavior
The path should either be consistent for both story formats or documented somewhere; so that, we are aware of it.
System:
6.0.21
The text was updated successfully, but these errors were encountered: