How does jest get methods within components wrapped by Form.create ()

simple components:

export default class Test extends React.Component {
    constructor() {
        super();
        this.onChange = this.onChange.bind(this);
        this.state = {};
    }
    onChange(key, value) {}
    render() {
        return (
            <div className="daka-login">
            </div>
        );
    }
}

components wrapped by Form form components:

class Test extends React.Component {
    constructor() {
        super();
        this.onChange = this.onChange.bind(this);
        this.state = {};
    }
    onChange(key, value) {}
    render() {
        return (
            <div className="daka-login">
            </div>
        );
    }
}

const WrappedUserTest = Form.create()(Test);
export default WrappedUserTest;

onChange methods for simple components can be tested in the following ways:

mount(<Test {...props} />).instance().onChange()

but the package wrapped by the Form form will report an error. How should I modify it? thank you.

Mar.06,2021

Let me solve your problem perfectly

clipboard.png

Menu