fix (test): make dynamic import testable from jest

This commit is contained in:
MickaelK 2023-10-20 23:57:29 +11:00
parent b8b2a86374
commit afc687b0a6

View file

@ -39,7 +39,10 @@ async function load(route, opts) {
} else if (typeof spinner === "string") {
spinnerID = setTimeout(() => $root.innerHTML = spinner, spinnerTime);
}
const module = await import("../.." + route);
const module = window.env === "test" ?
require("../.." + route) :
await import("../.." + route);
clearTimeout(spinnerID);
if (typeof module.default !== "function") {
console.error(module, module.default);