@virtualstate/app-history
Version:
Native JavaScript [app-history](https://github.com/WICG/app-history) implementation
66 lines • 2.16 kB
JavaScript
/* c8 ignore start */
// import {run, dispatchEvent, addEventListener} from "@opennetwork/environment";
import process from "./node-process.js";
import { getConfig } from "./config.js";
console.log("====== START NEW SET OF TESTS ======");
if (typeof process !== "undefined") {
process.on("uncaughtException", (...args) => {
console.log("process uncaught exception", ...args);
process.exit(1);
});
process.on("unhandledRejection", (...args) => {
console.log("process unhandled rejection", ...args);
process.exit(1);
});
process.on("error", (...args) => {
console.log("process error", ...args);
process.exit(1);
});
}
async function runTests() {
await import("./app-history.class.js");
if (typeof window === "undefined" && typeof process !== "undefined") {
await import("./app-history.imported.js");
if (getConfig().FLAGS?.includes("WEB_PLATFORM_TESTS")) {
await import("./app-history.playwright.wpt.js");
}
if (getConfig().FLAGS?.includes("PLAYWRIGHT")) {
await import("./app-history.playwright.js");
}
}
else {
await import("./app-history.scope.js");
}
}
if (typeof window === "undefined") {
console.log("Running tests within shell");
}
else {
if (sessionStorage.testsRanInThisWindow) {
throw new Error("Tests already ran in this window, network navigation caused");
}
sessionStorage.setItem("testsRanInThisWindow", "1");
console.log("Running tests within window");
}
let exitCode = 0, caught = undefined;
try {
await runTests();
}
catch (error) {
caught = error;
exitCode = 1;
console.error("Caught test error!");
if (typeof window === "undefined" && typeof process !== "undefined") {
console.error(caught);
}
else {
throw await Promise.reject(caught);
}
}
// Settle tests, allow for the above handlers to fire if they need to
await new Promise(resolve => setTimeout(resolve, 200));
if (typeof process !== "undefined" && exitCode) {
process.exit(exitCode);
}
export default exitCode;
//# sourceMappingURL=index.js.map