Debian Codegraph @

wasm/browser/tests/selenium_runner_firefox.js

raw
1 import fs from "fs";
2 import { spawn } from "child_process";
3 import MochaWebdriverRunner from "mocha-webdriver-runner";
4 const { runMochaWebDriverTest } = MochaWebdriverRunner;
5
6 const httpServerPs = spawn(`node tests/server.cjs`, {
7 shell: true,
8 env: { PATH: process.env.PATH, PORT: "8082" },
9 });
10
11 httpServerPs.stdout.on("data", (d) => console.log(d.toString()));
12 httpServerPs.stderr.on("data", (d) => console.log(d.toString()));
13
14 const webDriverCapabilities = {
15 browserName: "firefox",
16 "moz:firefoxOptions": {
17 args: ["--no-sandbox", "--headless"],
18 },
19 };
20
21 const CI_BIN = process.env["FIREFOX_BIN"];
22 if (CI_BIN && fs.existsSync(CI_BIN)) {
23 webDriverCapabilities["moz:firefoxOptions"]["binary"] = CI_BIN;
24 }
25
26 (async function () {
27 let result;
28 await new Promise((resolve) => setTimeout(resolve, 1000));
29 try {
30 result = await runMochaWebDriverTest(
31 webDriverCapabilities,
32 "http://localhost:8082/index.html?ci=true",
33 {
34 reporter: "mocha-junit-reporter",
35 reporterOptions: {
36 mochaFile: "tests/results-firefox.junit.xml",
37 useFullSuiteTitle: true,
38 rootSuiteTitle: undefined,
39 },
40 },
41 );
42 } catch (error) {
43 console.error(error);
44 process.exit(-1);
45 }
46 httpServerPs.kill();
47 if (result && result.success) {
48 process.exit(0);
49 } else {
50 console.error(JSON.stringify(result || {}, null, 2));
51 process.exit(0);
52 }
53 })();