-
Notifications
You must be signed in to change notification settings - Fork 36
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 I run the snapshots in CI #16
Comments
Thanks @ForbesLindesay for opening this issue. |
I’m also interested in that ;-) I think it’s the most useful use case for snapshots in Styleguidist. |
I wouldn't say it's the most useful use case (snapshot testing gives you much more) :) |
Love the library so far! But not having this is a deal breaker for using it in our project. Keep up the good work @MicheleBertoli . |
Thanks @hugogrochau. In order to run the tests at build time, we'd need a way to get all the code snippets from Otherwise, we'd need to generate "real" test files (instead of running Jest through an endpoint), which would solve #18 as well. |
Not now, but it would be a useful feature. Feel free to send a pull request for that ;-) |
Would be great to generate "real" test files from examples, stored in every component folder (where jest expects them, aka. One issue that I encountered trying to implement it was that the One other issue would be that these test would be auto-generated and therefore you could not add extra test in the same files, so it would need a big disclaimer (eg. auto-generated, do not edit) But for my use case, having a non-crashing test, tree-snapshot test and also a visual-snapshot test (can be done with puppeteer) for every example in my readme would be just perfect. And having the README as the single source of truth for both docs and testing sounds nice. |
Any news on this issue? |
Hello @nanndoj we didn't receive any PR yet : ) |
It seems like it shouldn't be too hard to extract all code snippets from the markdown and generate a |
I'm glad to hear it shouldn't be too hard @kevinbarabash, would you be happy to submit a PR? |
@MicheleBertoli I'm not sure how much time I'll have. Here's a link to the code that I used in my own project for this: Khan/wonder-blocks@f0a4c75. Unfortunately, it doesn't handle some of the cases allowed by styleguide.config.js. It also doesn't handle the case where a example contains multiple components at the root level. |
I am very interested in this being supported. I am a little bit concerned however, of the difficulty of making sure that the snapshots are generated identically inside a standard jest environment and inside the browser at dev time. For example, I insert a custom wrapper component into my styleguidist config to give each example an appropriate context, I am not sure how snapguidist would be able to maintain this properly during CI if it was running outside of styleguidist. Has it been considered to actually run the standard styleguidist dev server at CI time and evaluate the tests in the actual browser? Granted, it feels odd to do that, but on the other hand if we think that the browser is a fine place to generate snapshots today, why not maintain the same during CI? I threw together a very quick POC of this to see what it would take and it was pretty small. Thoughts? |
Lovely, please submit a PR! |
I want to be able to test all the snapshots automatically on travis. When I run styleguidist build, it builds successfully even with invalid snapshots.
The text was updated successfully, but these errors were encountered: