Hi, I really like this library.
We should improve the docs with a dedicated section for best practices for writing unit tests.
Hey @giacomorebonato 馃憢
Yep, I agree on this. I've specifically left this out whilst I work out some of my personal patterns around this. Feel free to drop any examples in this thread and perhaps we could discuss and generate a PR for it. 馃憤
Glad that you are digging the library. 馃檹
Yes, it'll take some time... and I hope that I can help.
I'd love to see some examples also, I have no clue how to do useful tests for my stores/actions & function components using hooks. It's a very important thing to know before considering using a library and I hope we'll get something to start with soon :)
@adrienWeiss well you don't really need to test the hooks themselves.
You can test your mapping methods that you pass to the useStore hook, but that's pretty much it.
One of the benefits of using reducers and action creators is the pure concept around them.
Meaning that they only have inputs and outputs without side effects.
And in the case of easy-peasy, side effects are controlled via the injection patterns provided by the library itself
But I would definitely recommend having 100% code coverage on your actions.
I personally even test my thunks by mocking my dependencies with the injection helpers (axios/fetch/graphql, window, location, etc.)
I can provide an example tomorrow on how I test my store actions and thunks tomorrow if interested
Track the work in #69 馃憤
Most helpful comment
Yes, it'll take some time... and I hope that I can help.