-
Notifications
You must be signed in to change notification settings - Fork 113
feat: configuration callback composition #149
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
feat: configuration callback composition #149
Conversation
Codecov Report
@@ Coverage Diff @@ ## master #149 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 1 1 Lines 70 75 +5 Branches 13 14 +1 ========================================= + Hits 70 75 +5
Continue to review full report at Codecov.
|
Hi! 👋 Thanks for taking the time to put this together!
What I usually do is I create my "own" render method with the desired configuration, and then use it instead of the one coming from VTL. In the docs we have this example using React Testing Library, but the same idea still applies.
Would that suit your needs? I'd really like to stick to that pattern instead of increasing the API of the library, so that it stays simpler and more aligned with other libraries from the testing-library ecosystem.
We might want to document that Custom render method more prominently, though!
Hi @afontcu
thanks for your reaction :) I understand that you don't want to increase the API of the library, even though I will then need to copy/share the pattern with the composeConfigurationCallbacks manually between projects.
If you'd like I can change the MR to just adding examples. I'd then propose to add a shared-setup.js (naming ?) example in which:
- a "test-utils.js" provides a customRender function (with changed API / default options) as well as the
composeConfigurationCallbacksfunction - use cases can be shown for the customRender function
- use cases can be shown for composition with the original render function
What do you think?
Sure! For the time being I'd feel more comfortable with adding some examples on how to customise the render method. I'd start with a basic example (something simple such as adding i18n to all tests, or a common dependency)
Thanks for this! 🙌
completely forget about this MR 👀.
To me, wrapping the render method adds opacity, as it hides which dependencies the tested component actually has, but I'll finally close this MR ;)
Uh oh!
There was an error while loading. Please reload this page.
In two projects I am currently working on there are often common configurations needed to install components or plugins - or to setup the router and store instances.
To integrate multiple configuration setups I found it beneficial to compose them automatically like this:
I hope the example gives an impression of how this can help one to reuse configurations between tests. This allows to reduce the code that needs to be written per tests and to avoid duplications.
What do you think of this?
Two more things :)
typeof configurationCb")