- Expose ReactN and use setGlobal from Cypress to create a state for testing.
I was able to do it.
App.tsx
function App() {
const [fusens] = useGlobal("fusens");
return (...);
}
index.tsx
setGlobal(INITIAL_GLOBAL_STATE);
const movidea = {
getGlobal,
setGlobal,
};
const debug = {};
declare global {
interface Window {
debug: any;
movidea: typeof movidea;
}
}
window.movidea = movidea;
window.debug = debug;
For an explanation, see Expose ReactN.
- I have setGlobal, etc. in movidea (app name) to make it easier for users (mainly me) to hack when the app is released, but I think it is also possible to design it in the debug and remove it in the release build.
test code cypress/…/adjust_font_size.js
For setTimeout see ✅The hook is not responding when setGlobal from Cypress.
This page is auto-translated from /nishio/ReactNを露出してCypressから使う using DeepL. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. I’m very happy to spread my thought to non-Japanese readers.