A Reactive Form method to make the building of storybook tests for UI components leveraging Angular Reactive Forms easier. #28726
michael-lloyd-morris
started this conversation in
Ideas
Replies: 1 comment
-
|
Bump so this doesn't get autoclosed. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is your feature request related to a problem? Please describe.
I have recently figured out how to effectively create Reactive Form components that can be stood up in Storybook and tested. The process can be seen in action in the code in this branch of the tutorial repository I wrote to document this:
https://github.com/michael-lloyd-morris/storybook-angular-reactive-forms/tree/ch3-simple-reactive-form-component
Reactive Form UI components must be attached to a form. They are guided to this attachment through an application service known as the ControlContainer. In testing this must be mocked, and here is the code to do so:
The decorator of the story that uses this is then provided with the mock like so
This works, but it is awkward.
Describe the solution you'd like
I'd like to be able to just have a new method that can be put in the decorator
The form definition would be identical in all respects to the argument one would give the Reactive Form Builder.
It would create a provider for the story that satisfies the ControlContainer service requirement, but it would also pass an additional member of the object received by the play function of the story called reactiveForm to enable the test inspection of the form state as the UI control under test is interacted with. So in action a story leveraging the requested code fully would look like this.
Describe alternatives you've considered
No response
Are you able to assist to bring the feature to reality?
yes, I can
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions