I have a setup for an external application and start it within a const, then put it in the const allowAppInstance the configuration of the appConfig
export const setupRemote = () => {
if (isRemoteAvailable) {
try {
...
const allowAppInstance = SetupConfig.start(remoteInstance);
return {
allowAppInstance,
};
} catch (e) {
console.error(e);
}
}
};
here I export
export const appSetupConfig = () => setupRemote().allowAppInstance;
in the component, I get this setup and put it in a const
import { appSetupConfig } from '.../myapp'
useEffect(() => {
const allowAppInstance = appSetupConfig();
...the rest of code
}, []);
the application works, but when I run the tests, jest doesn't let it pass, it causes this error:
TypeError: Cannot read property 'allowAppInstance' of null
43 | };
44 |
> 45 | export const appSetupConfig = () => setupRemote().allowAppInstance;
Is there any way to mock allowAppInstance to pass the test? I really don't know what to do and what am I doing wrong