Hi, there is a nice guide which discusses how to test Apollo Queries: https://blog.apollographql.com/testing-apollos-query-component-d575dc642e04
But, I cannot find a way of how to test “onSuccess” and onError" callbacks. In these callbacks I perform activities that update some objects (e.g. set userID in a MOBX store).
Yet, I do not know how to access and test it. Any help is greatly appreciated.
Example:
onCompleted = (data: Yoga.AuthPayload | {}) => {
this.props.store.setUser((data as Data).resume.user);
};
onError = () => {
this.props.store.logout();
};
<Query
query={RESUME}
variables={{ token: this.props.token }}
onCompleted={this.onCompleted}
onError={this.onError}
>
...