UNPKG

@itwin/certa

Version:

A mocha-based integration test runner

52 lines 2.33 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); /*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ const electron_1 = require("electron"); // NB: This has to happen _before_ we import mocha! window._CertaConsole = (name, args = [""]) => { if (args.length === 0) args.push(""); return electron_1.ipcRenderer.sendSync("certa-console", name, ...args); }; require("../../utils/initLogging"); const Mocha = require("mocha"); window.onerror = (_message, _source, _lineno, _colno, error) => { const { message, stack } = error || {}; electron_1.ipcRenderer.send("certa-error", { message, stack }); }; window.onunhandledrejection = (event) => { const { message, stack } = event.reason; electron_1.ipcRenderer.send("certa-error", { message, stack }); }; window.mocha = new Mocha(); require("../../utils/initMocha"); async function startCertaTests(entryPoint) { try { // Setup source maps window.sourceMapSupport = require("source-map-support"); require("../../utils/initSourceMaps"); // Load tests // Note that we need to use a script tag instead of `require` here - that way debuggers can break on the first statement and resolve breakpoints. const script = document.createElement("script"); script.src = entryPoint; const loaded = new Promise((res, rej) => { script.onload = res; script.onerror = rej; }); document.head.appendChild(script); await loaded; // Execute tests mocha.run((failedCount) => electron_1.ipcRenderer.send("certa-done", failedCount)); } catch ({ message, stack }) { electron_1.ipcRenderer.send("certa-error", { message, stack }); } } const certaSendToBackend = async (name, args) => electron_1.ipcRenderer.sendSync("certa-callback", { name, args }); // Expose some globals window.startCertaTests = startCertaTests; window._CertaSendToBackend = certaSendToBackend; //# sourceMappingURL=initElectronTests.js.map