Hi there,
Is there a best practice for writing unit tests to test components and renderers?
Thanks
Hi there,
Is there a best practice for writing unit tests to test components and renderers?
Thanks
This link will be helpful.
Hi, this doesnt seem to cover writing unit tests.
Currently have this issue when trying to write a test for my controller
TypeError: Cannot read property 'scope' of undefined
16 | it('WHEN component is loaded THEN render element', () => {
17 | const handleChange = jest.fn();
> 18 | const { getByTestId } = render(<TextFieldControl
| ^
19 | data={'foo bar'}
20 | handleChange={handleChange}
21 | path={'bar.foo'}
Hi @JustKyle,
There are multiple ways of testing your components:
JsonFormsStateProvider
in your test, see here for an example. However this is an “internal” component and therefore not intuitive to use, for example to test emitted changes you need a special emitter, see here. Note that the wrapped component needs to be handed over the props in the same way as the JsonFormsDispatch
receives in the normal use case (e.g. a control schema
is still the parent schema at that point of time)JsonForms
and make sure to handover schema and uischema so that your renderer wins. See for example here.