bt-runner 3.0.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/index.js +7 -62
  2. package/dist/index_debug.js +25 -18
  3. package/dist/{IRunner.js → util/Config.js} +0 -0
  4. package/dist/util/Server.js +64 -0
  5. package/{tmp/browsertests-9PMQFx/index1.html → dist/util/generateHtml.js} +10 -5
  6. package/dist/{getPort.js → util/getPort.js} +3 -2
  7. package/dist/util/index.js +21 -0
  8. package/dist/util/runTests.js +45 -0
  9. package/package.json +2 -5
  10. package/dist/generate.js +0 -62
  11. package/dist/server.js +0 -18
  12. package/tmp/.gitkeep +0 -0
  13. package/tmp/browsertests-9PMQFx/index2.html +0 -25
  14. package/tmp/browsertests-CRhBRJ/index1.html +0 -25
  15. package/tmp/browsertests-CRhBRJ/index2.html +0 -25
  16. package/tmp/browsertests-CRhBRJ/mocha.test.js +0 -100
  17. package/tmp/browsertests-CRhBRJ/nightwatch.json +0 -1
  18. package/tmp/browsertests-Ef8QDb/index1.html +0 -25
  19. package/tmp/browsertests-Ef8QDb/index2.html +0 -25
  20. package/tmp/browsertests-Ef8QDb/mocha.test.js +0 -100
  21. package/tmp/browsertests-Ef8QDb/nightwatch.json +0 -1
  22. package/tmp/browsertests-FNrySD/index1.html +0 -25
  23. package/tmp/browsertests-FNrySD/index2.html +0 -25
  24. package/tmp/browsertests-FNrySD/mocha.test.js +0 -100
  25. package/tmp/browsertests-FNrySD/nightwatch.json +0 -1
  26. package/tmp/browsertests-HnV7W1/index1.html +0 -25
  27. package/tmp/browsertests-HnV7W1/index2.html +0 -25
  28. package/tmp/browsertests-HnV7W1/mocha.test.js +0 -100
  29. package/tmp/browsertests-HnV7W1/nightwatch.json +0 -1
  30. package/tmp/browsertests-Kr11Ep/index1.html +0 -25
  31. package/tmp/browsertests-Kr11Ep/index2.html +0 -25
  32. package/tmp/browsertests-Kr11Ep/mocha.test.js +0 -100
  33. package/tmp/browsertests-Kr11Ep/nightwatch.json +0 -1
  34. package/tmp/browsertests-QTo9jV/index1.html +0 -25
  35. package/tmp/browsertests-QTo9jV/index2.html +0 -25
  36. package/tmp/browsertests-QTo9jV/mocha.test.js +0 -100
  37. package/tmp/browsertests-QTo9jV/nightwatch.json +0 -1
  38. package/tmp/browsertests-VXReLQ/index1.html +0 -25
  39. package/tmp/browsertests-VXReLQ/index2.html +0 -25
  40. package/tmp/browsertests-VXReLQ/mocha.test.js +0 -100
  41. package/tmp/browsertests-VXReLQ/nightwatch.json +0 -1
  42. package/tmp/browsertests-dat86a/index1.html +0 -25
  43. package/tmp/browsertests-dat86a/index2.html +0 -25
  44. package/tmp/browsertests-dat86a/mocha.test.js +0 -94
  45. package/tmp/browsertests-dat86a/nightwatch.json +0 -1
  46. package/tmp/browsertests-eI4Px3/index1.html +0 -25
  47. package/tmp/browsertests-eI4Px3/index2.html +0 -25
  48. package/tmp/browsertests-eI4Px3/mocha.test.js +0 -100
  49. package/tmp/browsertests-eI4Px3/nightwatch.json +0 -1
  50. package/tmp/browsertests-eQY4O5/index1.html +0 -25
  51. package/tmp/browsertests-eQY4O5/index2.html +0 -25
  52. package/tmp/browsertests-eQY4O5/mocha.test.js +0 -100
  53. package/tmp/browsertests-eQY4O5/nightwatch.json +0 -1
  54. package/tmp/browsertests-gOUWdm/index1.html +0 -25
  55. package/tmp/browsertests-gOUWdm/index2.html +0 -25
  56. package/tmp/browsertests-gOUWdm/mocha.test.js +0 -100
  57. package/tmp/browsertests-gOUWdm/nightwatch.json +0 -1
  58. package/tmp/browsertests-jhoSdz/index1.html +0 -25
  59. package/tmp/browsertests-jhoSdz/index2.html +0 -25
  60. package/tmp/browsertests-jhoSdz/mocha.test.js +0 -100
  61. package/tmp/browsertests-jhoSdz/nightwatch.json +0 -1
  62. package/tmp/browsertests-koaNEn/index1.html +0 -25
  63. package/tmp/browsertests-koaNEn/index2.html +0 -25
  64. package/tmp/browsertests-koaNEn/mocha.test.js +0 -100
  65. package/tmp/browsertests-koaNEn/nightwatch.json +0 -1
  66. package/tmp/browsertests-ngYMnq/index1.html +0 -25
  67. package/tmp/browsertests-ngYMnq/index2.html +0 -25
  68. package/tmp/browsertests-ngYMnq/mocha.test.js +0 -100
  69. package/tmp/browsertests-ngYMnq/nightwatch.json +0 -1
  70. package/tmp/browsertests-oAq8xk/index1.html +0 -25
  71. package/tmp/browsertests-oAq8xk/index2.html +0 -25
  72. package/tmp/browsertests-oAq8xk/mocha.test.js +0 -100
  73. package/tmp/browsertests-oAq8xk/nightwatch.json +0 -1
  74. package/tmp/browsertests-q1rpZj/index1.html +0 -25
  75. package/tmp/browsertests-q1rpZj/index2.html +0 -25
  76. package/tmp/browsertests-q1rpZj/mocha.test.js +0 -100
  77. package/tmp/browsertests-q1rpZj/nightwatch.json +0 -1
  78. package/tmp/browsertests-zYgHlc/index1.html +0 -25
  79. package/tmp/browsertests-zYgHlc/index2.html +0 -25
  80. package/tmp/browsertests-zYgHlc/mocha.test.js +0 -100
  81. package/tmp/browsertests-zYgHlc/nightwatch.json +0 -1
package/dist/index.js CHANGED
@@ -27,39 +27,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  return (mod && mod.__esModule) ? mod : { "default": mod };
28
28
  };
29
29
  Object.defineProperty(exports, "__esModule", { value: true });
30
- const child_process = __importStar(require("child_process"));
31
30
  const path = __importStar(require("path"));
32
- const puppeteer_1 = __importDefault(require("puppeteer"));
33
31
  const helpers_1 = require("yargs/helpers");
34
32
  const yargs_1 = __importDefault(require("yargs/yargs"));
35
- const generate_1 = __importDefault(require("./generate"));
36
- const getPort_1 = __importDefault(require("./getPort"));
37
- const rimraf = require("rimraf");
33
+ const util_1 = require("./util");
38
34
  async function run() {
39
- const port = await (0, getPort_1.default)();
40
- const args = await (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
41
- .option("config", {
35
+ const port = await (0, util_1.getPort)();
36
+ const args = await (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv)).option("config", {
42
37
  alias: "c",
43
38
  type: "string",
44
39
  description: "select a config file",
45
40
  default: "nbt.json"
46
- })
47
- .option("port", {
48
- alias: "p",
49
- type: "number",
50
- description: "select a port",
51
- default: 9515
52
41
  }).argv;
53
- const nbt = require(path.join(process.cwd(), args.config));
54
- const tempFolder = (0, generate_1.default)(nbt.runners, nbt.additionalScripts);
55
- const testFolder = path.resolve(nbt.testFolder);
56
- const httpServerProc = child_process.spawn("node", [`${__dirname}/../dist/server.js`, tempFolder, testFolder], {
57
- stdio: "inherit",
58
- env: { ...process.env, PORT: port.toString() }
59
- });
42
+ const config = require(path.join(process.cwd(), args.config));
43
+ const server = util_1.Server.create(config, port).start();
60
44
  let exitCode = 0;
61
45
  try {
62
- const success = await runTests(port, nbt.runners);
46
+ const success = await (0, util_1.runTests)(port, config.runners);
63
47
  if (!success)
64
48
  exitCode = 1;
65
49
  }
@@ -68,47 +52,8 @@ async function run() {
68
52
  exitCode = 1;
69
53
  }
70
54
  finally {
71
- httpServerProc.kill("SIGINT");
72
- rimraf.sync(tempFolder);
55
+ server.stop();
73
56
  }
74
57
  process.exit(exitCode);
75
58
  }
76
- async function runTests(serverPort, testRunners) {
77
- const browser = await puppeteer_1.default.launch({
78
- headless: true,
79
- args: ["--disable-gpu", "--disable-dev-shm-usage", "--disable-setuid-sandbox", "--no-sandbox"]
80
- });
81
- const page = await browser.newPage();
82
- page.on("console", (message) => {
83
- console.log.apply(console, message.args().map((arg) => arg.remoteObject().value));
84
- });
85
- for (let i = 0; i < testRunners.length; i++) {
86
- const runner = testRunners[i];
87
- const runnerNumber = i + 1;
88
- console.log(`Running test runner ${runnerNumber}`);
89
- await page.goto(`http://localhost:${serverPort}/test-browser/index${runnerNumber}.html`);
90
- const globals = runner.globals ?? [];
91
- globals.push("mocha");
92
- const result = await page.evaluate(async (globals) => {
93
- for (const glob of globals) {
94
- if (typeof window[glob] === "undefined") {
95
- console.log(`Required library '${glob}' not loaded. Aborting...`);
96
- return { failures: 1 };
97
- }
98
- }
99
- return new Promise((resolve) => window.mocha.run(function (failures) {
100
- resolve({ failures: failures });
101
- }));
102
- }, runner.globals ?? []);
103
- if (result.failures != 0) {
104
- await browser.close();
105
- return false;
106
- }
107
- console.log();
108
- console.log();
109
- }
110
- await browser.close();
111
- return true;
112
- }
113
- function cleanup(httpServerProc, tempFolder) { }
114
59
  run();
@@ -23,28 +23,35 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  __setModuleDefault(result, mod);
24
24
  return result;
25
25
  };
26
- var __importDefault = (this && this.__importDefault) || function (mod) {
27
- return (mod && mod.__esModule) ? mod : { "default": mod };
28
- };
29
26
  Object.defineProperty(exports, "__esModule", { value: true });
30
- const express_1 = __importDefault(require("express"));
31
- const express_http_proxy_1 = __importDefault(require("express-http-proxy"));
32
27
  const path = __importStar(require("path"));
33
- const generate_1 = __importDefault(require("./generate"));
34
- const app = (0, express_1.default)();
35
- const nbt = require(path.join(process.cwd(), "nbt.json"));
36
- const outputPath = (0, generate_1.default)(nbt.runners, nbt.additionalScripts);
37
- app.use("/test-browser", express_1.default.static(outputPath));
38
- app.use("/test", express_1.default.static(path.resolve(nbt.testFolder)));
39
- if (nbt.proxies) {
40
- for (const proxy of nbt.proxies) {
41
- app.use(proxy.local, (0, express_http_proxy_1.default)(proxy.remote));
42
- }
43
- }
44
- const urls = nbt.runners
28
+ const util_1 = require("./util");
29
+ const port = 7777;
30
+ const config = require(path.join(process.cwd(), "nbt.json"));
31
+ const server = util_1.Server.create(config, port).start();
32
+ const urls = config.runners
45
33
  .map((_runner, index) => `- http://localhost:7777/test-browser/index${index + 1}.html`)
46
34
  .join("\n");
47
35
  console.log(`Server Started. Open under the following URL's
48
36
  ${urls}
49
37
  and type "mocha.run()" in the debug console to run the tests.`);
50
- app.listen(7777, () => { });
38
+ const signals = [
39
+ "SIGHUP",
40
+ "SIGINT",
41
+ "SIGQUIT",
42
+ "SIGILL",
43
+ "SIGTRAP",
44
+ "SIGABRT",
45
+ "SIGBUS",
46
+ "SIGFPE",
47
+ "SIGUSR1",
48
+ "SIGSEGV",
49
+ "SIGUSR2",
50
+ "SIGTERM"
51
+ ];
52
+ for (const signal of signals) {
53
+ process.on(signal, () => {
54
+ server.stop();
55
+ process.exit(0);
56
+ });
57
+ }
File without changes
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.Server = void 0;
30
+ const express_1 = __importDefault(require("express"));
31
+ const path = __importStar(require("path"));
32
+ const generateHtml_1 = require("./generateHtml");
33
+ class Server {
34
+ constructor(config, port) {
35
+ this.config = config;
36
+ this.port = port;
37
+ this.testFolder = path.resolve(config.testFolder);
38
+ }
39
+ static create(config, port = 7777) {
40
+ return new Server(config, port);
41
+ }
42
+ start() {
43
+ const app = (0, express_1.default)();
44
+ this.config.runners.forEach((runner, i) => {
45
+ app.get(`/test-browser/index${i + 1}.html`, (_req, res) => {
46
+ const html = (0, generateHtml_1.generateHtml)(runner.dependencies, this.config.additionalScripts);
47
+ res.status(200).send(html);
48
+ });
49
+ });
50
+ app.use("/test", express_1.default.static(this.testFolder));
51
+ if (this.config.proxies) {
52
+ const httpproxy = require("express-http-proxy");
53
+ for (const proxy of this.config.proxies) {
54
+ app.use(proxy.local, httpproxy(proxy.remote));
55
+ }
56
+ }
57
+ this.server = app.listen(this.port, () => { });
58
+ return this;
59
+ }
60
+ stop() {
61
+ this.server?.close();
62
+ }
63
+ }
64
+ exports.Server = Server;
@@ -1,4 +1,8 @@
1
- <!DOCTYPE html>
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateHtml = void 0;
4
+ function generateHtml(dependencies, additionalScripts) {
5
+ return `<!DOCTYPE html>
2
6
  <html>
3
7
  <head>
4
8
  <title>Mocha Tests</title>
@@ -14,12 +18,13 @@
14
18
  mocha.reporter("spec")
15
19
  </script>
16
20
  <script>
17
- window.TEST = {}
18
- window.TEST2 = {}
21
+ ${additionalScripts ? additionalScripts.join("\n") : ""}
19
22
  </script>
20
23
 
21
- <script src="/test/test.js"></script>
24
+ ${dependencies.map((dependency) => ` <script src="/test/${dependency}"></script>`).join("\n")}
22
25
 
23
26
  <div id="main">Test</div>
24
27
  </body>
25
- </html>
28
+ </html>`;
29
+ }
30
+ exports.generateHtml = generateHtml;
@@ -3,8 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getPort = void 0;
6
7
  const net_1 = __importDefault(require("net"));
7
- async function default_1(options) {
8
+ async function getPort(options) {
8
9
  return await new Promise((resolve, reject) => {
9
10
  const server = net_1.default.createServer();
10
11
  server.unref();
@@ -17,4 +18,4 @@ async function default_1(options) {
17
18
  });
18
19
  });
19
20
  }
20
- exports.default = default_1;
21
+ exports.getPort = getPort;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Config"), exports);
18
+ __exportStar(require("./generateHtml"), exports);
19
+ __exportStar(require("./getPort"), exports);
20
+ __exportStar(require("./runTests"), exports);
21
+ __exportStar(require("./Server"), exports);
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.runTests = void 0;
7
+ const puppeteer_1 = __importDefault(require("puppeteer"));
8
+ async function runTests(serverPort, testRunners) {
9
+ const browser = await puppeteer_1.default.launch({
10
+ headless: true,
11
+ args: ["--disable-gpu", "--disable-dev-shm-usage", "--disable-setuid-sandbox", "--no-sandbox"]
12
+ });
13
+ const page = await browser.newPage();
14
+ page.on("console", (message) => {
15
+ console.log.apply(console, message.args().map((arg) => arg.remoteObject().value));
16
+ });
17
+ for (let i = 0; i < testRunners.length; i++) {
18
+ const runner = testRunners[i];
19
+ const runnerNumber = i + 1;
20
+ console.log(`Running test runner ${runnerNumber}`);
21
+ await page.goto(`http://localhost:${serverPort}/test-browser/index${runnerNumber}.html`);
22
+ const globals = runner.globals ?? [];
23
+ globals.push("mocha");
24
+ const result = await page.evaluate(async (globals) => {
25
+ for (const glob of globals) {
26
+ if (typeof window[glob] === "undefined") {
27
+ console.log(`Required library '${glob}' not loaded. Aborting...`);
28
+ return { failures: 1 };
29
+ }
30
+ }
31
+ return new Promise((resolve) => window.mocha.run(function (failures) {
32
+ resolve({ failures: failures });
33
+ }));
34
+ }, runner.globals ?? []);
35
+ if (result.failures != 0) {
36
+ await browser.close();
37
+ return false;
38
+ }
39
+ console.log();
40
+ console.log();
41
+ }
42
+ await browser.close();
43
+ return true;
44
+ }
45
+ exports.runTests = runTests;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bt-runner",
3
- "version": "3.0.1",
3
+ "version": "3.1.0",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,8 +14,7 @@
14
14
  "browsertest-runner-debug": "dist/index_debug.js"
15
15
  },
16
16
  "files": [
17
- "dist",
18
- "tmp"
17
+ "dist"
19
18
  ],
20
19
  "scripts": {
21
20
  "prepublishOnly": "tsc"
@@ -24,14 +23,12 @@
24
23
  "express": "^4.18.1",
25
24
  "express-http-proxy": "^1.6.3",
26
25
  "puppeteer": "^16.2.0",
27
- "rimraf": "^3.0.2",
28
26
  "yargs": "^17.5.1"
29
27
  },
30
28
  "devDependencies": {
31
29
  "@types/express": "^4.17.13",
32
30
  "@types/express-http-proxy": "^1.6.3",
33
31
  "@types/node": "^18.7.11",
34
- "@types/rimraf": "^3.0.2",
35
32
  "@types/yargs": "^17.0.11"
36
33
  },
37
34
  "publishConfig": {
package/dist/generate.js DELETED
@@ -1,62 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- const fs = __importStar(require("fs"));
27
- const path = __importStar(require("path"));
28
- function generate(runners, additionalScripts) {
29
- const outputPath = fs.mkdtempSync(path.join(__dirname, "..", "tmp", "browsertests-"));
30
- runners.forEach((runner, index) => {
31
- writeHtml(outputPath, index + 1, runner.dependencies, additionalScripts);
32
- });
33
- return outputPath;
34
- }
35
- exports.default = generate;
36
- function writeHtml(outputPath, runnerNumber, dependencies, additionalScripts) {
37
- const html = `<!DOCTYPE html>
38
- <html>
39
- <head>
40
- <title>Mocha Tests</title>
41
- </head>
42
-
43
- <body>
44
- <div id="mocha"></div>
45
-
46
- <script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/10.0.0/mocha.min.js"></script>
47
- <script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.3.6/chai.min.js"></script>
48
- <script>
49
- mocha.setup("bdd")
50
- mocha.reporter("spec")
51
- </script>
52
- <script>
53
- ${additionalScripts ? additionalScripts.join("\n") : ""}
54
- </script>
55
-
56
- ${dependencies.map((dependency) => ` <script src="/test/${dependency}"></script>`).join("\n")}
57
-
58
- <div id="main">Test</div>
59
- </body>
60
- </html>`;
61
- fs.writeFileSync(path.join(outputPath, `index${runnerNumber}.html`), html);
62
- }
package/dist/server.js DELETED
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const express_1 = __importDefault(require("express"));
7
- const path = require("path");
8
- const app = (0, express_1.default)();
9
- app.use("/test-browser", express_1.default.static(process.argv[2]));
10
- app.use("/test", express_1.default.static(process.argv[3]));
11
- const config = require(path.join(process.cwd(), "nbt.json"));
12
- if (config && config.proxies) {
13
- const httpproxy = require("express-http-proxy");
14
- for (const proxy of config.proxies) {
15
- app.use(proxy.local, httpproxy(proxy.remote));
16
- }
17
- }
18
- app.listen(process.env["PORT"] ?? 7777, () => { });
package/tmp/.gitkeep DELETED
File without changes
@@ -1,25 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Mocha Tests</title>
5
- </head>
6
-
7
- <body>
8
- <div id="mocha"></div>
9
-
10
- <script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/10.0.0/mocha.min.js"></script>
11
- <script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.3.6/chai.min.js"></script>
12
- <script>
13
- mocha.setup("bdd")
14
- mocha.reporter("spec")
15
- </script>
16
- <script>
17
- window.TEST = {}
18
- window.TEST2 = {}
19
- </script>
20
-
21
- <script src="/test/test.js"></script>
22
-
23
- <div id="main">Test</div>
24
- </body>
25
- </html>
@@ -1,25 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Mocha Tests</title>
5
- </head>
6
-
7
- <body>
8
- <div id="mocha"></div>
9
-
10
- <script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/10.0.0/mocha.min.js"></script>
11
- <script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.3.6/chai.min.js"></script>
12
- <script>
13
- mocha.setup("bdd")
14
- mocha.reporter("spec")
15
- </script>
16
- <script>
17
- window.TEST = {}
18
- window.TEST2 = {}
19
- </script>
20
-
21
- <script src="/test/test.js"></script>
22
-
23
- <div id="main">Test</div>
24
- </body>
25
- </html>
@@ -1,25 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Mocha Tests</title>
5
- </head>
6
-
7
- <body>
8
- <div id="mocha"></div>
9
-
10
- <script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/10.0.0/mocha.min.js"></script>
11
- <script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.3.6/chai.min.js"></script>
12
- <script>
13
- mocha.setup("bdd")
14
- mocha.reporter("spec")
15
- </script>
16
- <script>
17
- window.TEST = {}
18
- window.TEST2 = {}
19
- </script>
20
-
21
- <script src="/test/test.js"></script>
22
-
23
- <div id="main">Test</div>
24
- </body>
25
- </html>
@@ -1,100 +0,0 @@
1
- const expect = require("chai").expect
2
-
3
- describe("Browser Mocha Tests", function () {
4
- before((client, done) => {
5
- client.captureBrowserConsoleLogs((event) => {
6
- const args = event.args.map((arg) => arg.value)
7
- console.log.apply(console, args)
8
- })
9
-
10
- done()
11
- })
12
-
13
- after((client, done) => {
14
- client.end(() => done())
15
- })
16
-
17
-
18
- it("Should run the Mocha tests without error (runner 1)", async (client) => {
19
- client.url("http://localhost:7777/test-browser/index1.html")
20
-
21
- client.waitForElementVisible("#main")
22
-
23
- const executeFunction = (done) => {
24
- const mocha = window.mocha
25
-
26
- //add required test librarys in this if statement
27
- if (!mocha) {
28
- console.log("Required library 'mocha' not loaded. Aborting...")
29
- done({ failures: 1 })
30
- return
31
- }
32
-
33
- if (!window.TEST) {
34
- console.log("Required library 'TEST' not loaded. Aborting...")
35
- done({ failures: 1 })
36
- return
37
- }
38
- if (!window.TEST2) {
39
- console.log("Required library 'TEST2' not loaded. Aborting...")
40
- done({ failures: 1 })
41
- return
42
- }
43
-
44
- mocha.run(function (failures) {
45
- done({ failures: failures })
46
- })
47
- }
48
-
49
- const result = await new Promise(resolve => client.timeoutsAsyncScript(1500000).executeAsyncScript(
50
- executeFunction,
51
- (result) => resolve(result)
52
- ))
53
-
54
- expect(result.value).to.not.be.undefined
55
- expect(result.value.failures).to.equal(0)
56
- })
57
-
58
-
59
-
60
- it("Should run the Mocha tests without error (runner 2)", async (client) => {
61
- client.url("http://localhost:7777/test-browser/index2.html")
62
-
63
- client.waitForElementVisible("#main")
64
-
65
- const executeFunction = (done) => {
66
- const mocha = window.mocha
67
-
68
- //add required test librarys in this if statement
69
- if (!mocha) {
70
- console.log("Required library 'mocha' not loaded. Aborting...")
71
- done({ failures: 1 })
72
- return
73
- }
74
-
75
- if (!window.TEST) {
76
- console.log("Required library 'TEST' not loaded. Aborting...")
77
- done({ failures: 1 })
78
- return
79
- }
80
- if (!window.TEST2) {
81
- console.log("Required library 'TEST2' not loaded. Aborting...")
82
- done({ failures: 1 })
83
- return
84
- }
85
-
86
- mocha.run(function (failures) {
87
- done({ failures: failures })
88
- })
89
- }
90
-
91
- const result = await new Promise(resolve => client.timeoutsAsyncScript(1500000).executeAsyncScript(
92
- executeFunction,
93
- (result) => resolve(result)
94
- ))
95
-
96
- expect(result.value).to.not.be.undefined
97
- expect(result.value.failures).to.equal(0)
98
- })
99
-
100
- })
@@ -1 +0,0 @@
1
- {"src_folders":["/home/julian/git/jss/docker-node-browsertests/test-runner/tmp/browsertests-CRhBRJ"],"filter":"*.test.js","webdriver":{"start_process":true,"server_path":"/home/julian/.local/lib/node_modules/chromedriver/lib/chromedriver/chromedriver","port":9515,"timeout_options":{"timeout":1500000}},"test_runner":{"type":"mocha","options":{"ui":"bdd","reporter":"spec"}},"test_settings":{"default":{"request_timeout_options":{"timeout":1500000},"desiredCapabilities":{"javascriptEnabled":true,"acceptSslCerts":true,"acceptInsecureCerts":true,"browserName":"chrome","goog:chromeOptions":{"w3c":true,"args":["--headless","--disable-gpu","--ignore-certificate-errors","--no-sandbox","--disable-features=NetworkService"],"binary":"/usr/bin/google-chrome"}}}},"globals":{"waitForConditionTimeout":100000,"asyncHookTimeout":1500000,"unitTestsTimeout":100000,"customReporterCallbackTimeout":100000,"retryAssertionTimeout":50000}}
@@ -1,25 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Mocha Tests</title>
5
- </head>
6
-
7
- <body>
8
- <div id="mocha"></div>
9
-
10
- <script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/10.0.0/mocha.min.js"></script>
11
- <script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.3.6/chai.min.js"></script>
12
- <script>
13
- mocha.setup("bdd")
14
- mocha.reporter("spec")
15
- </script>
16
- <script>
17
- window.TEST = {}
18
- window.TEST2 = {}
19
- </script>
20
-
21
- <script src="/test/test.js"></script>
22
-
23
- <div id="main">Test</div>
24
- </body>
25
- </html>