-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
in test mode is there a way for browser side to know in test? #3610
Comments
from exports.getDocument = () => {
return new Promise((resolve) => {
const url = `http://${config.address || "localhost"}:${config.port || "8080"}`;
jsdom.JSDOM.fromURL(url, { resources: "usable", runScripts: "dangerously" }).then((dom) => {
dom.window.name = "jsdom";
global.window = dom.window;
// Following fixes `navigator is not defined` errors in e2e tests, found here
// https://www.appsloveworld.com/reactjs/100/37/mocha-react-navigator-is-not-defined
global.navigator = {
useragent: "node.js"
};
dom.window.fetch = fetch;
dom.window.onload = () => {
global.document = dom.window.document;
resolve();
};
});
});
}; we are setting here |
I meant the code running inside MM.. a module to test the refreshable compliments remote file and have it locally we need to 'change' the configured url on the fly to it will pull a different file. but i have another way... if the url starts with tests and there is another parm (url2...) |
and I meant you maybe can use if (global.window.name === "jsdom")` {
console.log("running in test");
} |
ok, thx |
this didn't work... global not defined |
so for code running in browser omit the if (window.name === "jsdom")` {
console.log("running in test");
} |
hm.. doesn't fail, but doesn't work // in test mode only
if (window.name === "jsdom") {
// check for (undocumented) remote file2 to change test new load
if(this.config.remoteFile2!== null && this.config.remoteFileRefreshInterval!==null){
console.log("running in test");
this.config.remoteFile=this.config.remoteFile2
}
} for changing the remote file to prove that the cycle and fetch work , only wanted to fake a new file in test mode in test and in non-test window.name is empty this is in the getDom() callback also empty outside the module register
|
code in pr #3630 |
in helper side one can test the process.env.JEST_WORKER_ID
not available in module side
I am helping user with new compliments parm test
The text was updated successfully, but these errors were encountered: