-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
Generating a test based on source examples #34
Comments
Not sure I can help you much with this. And I agree that it’s not in the scope of this project. But if you need the examples loader I can extract it to a separate package. |
I tried to build something, but I had to stop here. |
But leaving that bug aside, I was able to run a test for one component using this code (
I also needed a bit of webpack config for it -
I run the tests with:
Result: |
@sapegin I made some more progress, but I need to change one thing in styleguidist: instead of:
we would do:
Then it would be possible to reuse that loader. Otherwise it always looks for the config path in If you could change this for me, it would be great! :) |
@mik01aj You have push access ;-) I’ll make a new release. |
@sapegin I tried, but it's difficult because the config is needed pretty much everywhere. I believe it should be passed explicitly to every "part", rather than |
Maybe the |
That’s difficult but important task. But I’m still not sure about the best (or at least good) way to solve it. Passing the config (not just a file path) explicitly would be the best but seems impossible with loaders. But we can start with just a file name, it’s better than nothing anyway. |
Better than nothing, don’t know how to improve it ;-) |
So I added one more commit and finally got it working. https://gist.github.com/mik01aj/5b0be7da5453b84a8a2a51b57611c2c7 |
So, to sum up, I was able to setup the code for my project (code in gist) but it's hacky as it uses some undocumented APIs (setting globals manually, |
Cool! I’d suggest to close it now until anyone wants more. |
FYI: I updated my gist for v3.0. |
I’m working on Node API and thinking about removing this hack. But I want to preserve functionality you need. Check #183 for details. |
It would be cool if we could have a task to run all the code examples from the docs and check that they don't throw exceptions both when used with
ReactDOM.render
andReactDOMServer.renderToString
. I'd like to put it innpm test
task for my project and have it checked with CI.We just need to get the examples using
examples.loader
, and do it for all thecode
chunks.I would even implement it myself, but I can't figure out how. I thought I could write something similar to mocha-loader, but I just don't get what's going on there (it's a pitch loader, whatever that really means).
Or maybe enhanced-require (unmaintained 😞) in Node would help? I have no idea.
Webpack docs about usage in Node.js might be useful.
I do not argue that we need a feature like this in react-styleguidist, but I'd like to have this for my project, and imho having a recipe how to do this could be also useful for others.
The text was updated successfully, but these errors were encountered: