I have a setup for an external application and start it within a const, then put it in the window.remote the configuration of the appConfig
export const setupRemote = () => {
if (isRemoteAvailable) {
try {
...
const allowAppInstance = SetupConfig.start(remoteInstance);
window.setup = {
appConfig: allowAppInstance,
};
} catch (e) {
console.error(e);
}
}
};
here I export
export const appSetupConfig = () => window.setup.appConfig;
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 'appConfig' of undefined
43 | };
44 |
> 45 | export const appSetupConfig = () => window.setup.appConfig;
Is there any way to mock window.setup.appConfig to pass the test? I really don't know what to do and what am i doing wrong
Via Active questions tagged javascript - Stack Overflow https://ift.tt/2FdjaAW
Comments
Post a Comment