Having test code:
it('componentDidUpdate should mount and change props', () => {
const onChange = jest.fn();
const wrapper = enzyme
.mount(
withTestTheme(
<JsonInput
onChange={onChange}
onValueChange={mockOnValueChange}
value={exampleJsonStringValidated}
/>),
);
expect(wrapper.instance().JsonInputRef).toBeTruthy;
});
I got:
Property 'JsonInputRef' does not exist on type 'Component<{}, {}, any>'.ts(2339)
I want to find the ref (text-area) and then check validity properties in order to write unit test that is why I need it.
render function:
render() {
const { height = '', onValueChange, ...restProps } = this.props;
return (
<StyledTextArea
ref={this.JsonInputRef}
{...restProps}
onChange={this.handleValueChange}
height={height}
/>
);
}
Similar question, but does not work: React/JestJS/Enzyme: How to test for reference function?