bt-runner 2.1.0 → 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.
- package/dist/index.js +16 -31
- package/dist/index_debug.js +29 -17
- package/dist/util/Config.js +2 -0
- package/dist/util/Server.js +64 -0
- package/dist/util/generateHtml.js +30 -0
- package/dist/util/getPort.js +21 -0
- package/dist/util/index.js +21 -0
- package/dist/util/runTests.js +45 -0
- package/package.json +4 -10
- package/dist/generator.js +0 -203
- package/dist/server.js +0 -18
- package/tmp/.gitkeep +0 -0
- package/tmp/browsertests-3rqPiu/index1.html +0 -27
- package/tmp/browsertests-71yT6w/index1.html +0 -25
- package/tmp/browsertests-71yT6w/mocha1.test.js +0 -56
- package/tmp/browsertests-71yT6w/nightwatch.json +0 -1
- package/tmp/browsertests-nIABth/index1.html +0 -25
- package/tmp/browsertests-nIABth/mocha1.test.js +0 -55
- package/tmp/browsertests-nIABth/nightwatch.json +0 -1
- package/tmp/browsertests-sBNC3W/index1.html +0 -36
- package/tmp/browsertests-sBNC3W/mocha1.test.js +0 -69
- package/tmp/browsertests-sBNC3W/nightwatch.json +0 -1
package/dist/index.js
CHANGED
@@ -27,48 +27,33 @@ 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
|
-
const Nightwatch = __importStar(require("nightwatch"));
|
32
30
|
const path = __importStar(require("path"));
|
33
31
|
const helpers_1 = require("yargs/helpers");
|
34
32
|
const yargs_1 = __importDefault(require("yargs/yargs"));
|
35
|
-
const
|
36
|
-
|
37
|
-
|
38
|
-
const args = await (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv))
|
39
|
-
.option("config", {
|
33
|
+
const util_1 = require("./util");
|
34
|
+
async function run() {
|
35
|
+
const port = await (0, util_1.getPort)();
|
36
|
+
const args = await (0, yargs_1.default)((0, helpers_1.hideBin)(process.argv)).option("config", {
|
40
37
|
alias: "c",
|
41
38
|
type: "string",
|
42
39
|
description: "select a config file",
|
43
40
|
default: "nbt.json"
|
44
|
-
})
|
45
|
-
.option("port", {
|
46
|
-
alias: "p",
|
47
|
-
type: "number",
|
48
|
-
description: "select a port",
|
49
|
-
default: 9515
|
50
41
|
}).argv;
|
51
|
-
const
|
52
|
-
const
|
53
|
-
|
54
|
-
var httpServerProc = child_process.spawn("node", [`${__dirname}/server.js`, tempFolder, testFolder], {
|
55
|
-
stdio: "inherit"
|
56
|
-
});
|
57
|
-
argv.config = path.join(tempFolder, "nightwatch.json");
|
58
|
-
const runner = Nightwatch.CliRunner(argv);
|
42
|
+
const config = require(path.join(process.cwd(), args.config));
|
43
|
+
const server = util_1.Server.create(config, port).start();
|
44
|
+
let exitCode = 0;
|
59
45
|
try {
|
60
|
-
await
|
61
|
-
|
46
|
+
const success = await (0, util_1.runTests)(port, config.runners);
|
47
|
+
if (!success)
|
48
|
+
exitCode = 1;
|
62
49
|
}
|
63
|
-
catch (
|
64
|
-
console.error(
|
50
|
+
catch (e) {
|
51
|
+
console.error(e);
|
52
|
+
exitCode = 1;
|
65
53
|
}
|
66
54
|
finally {
|
67
|
-
|
55
|
+
server.stop();
|
68
56
|
}
|
69
|
-
|
70
|
-
function cleanup(httpServerProc, tempFolder) {
|
71
|
-
httpServerProc.kill("SIGINT");
|
72
|
-
rimraf.sync(tempFolder);
|
73
|
-
process.exit(0);
|
57
|
+
process.exit(exitCode);
|
74
58
|
}
|
59
|
+
run();
|
package/dist/index_debug.js
CHANGED
@@ -23,23 +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
|
34
|
-
const
|
35
|
-
const
|
36
|
-
const
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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
|
33
|
+
.map((_runner, index) => `- http://localhost:7777/test-browser/index${index + 1}.html`)
|
34
|
+
.join("\n");
|
35
|
+
console.log(`Server Started. Open under the following URL's
|
36
|
+
${urls}
|
37
|
+
and type "mocha.run()" in the debug console to run the tests.`);
|
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
|
+
});
|
43
57
|
}
|
44
|
-
console.log("Server Started. Open at http://localhost:7777/test-browser/index1.html.");
|
45
|
-
app.listen(7777, () => { });
|
@@ -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;
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.generateHtml = void 0;
|
4
|
+
function generateHtml(dependencies, additionalScripts) {
|
5
|
+
return `<!DOCTYPE html>
|
6
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<title>Mocha Tests</title>
|
9
|
+
</head>
|
10
|
+
|
11
|
+
<body>
|
12
|
+
<div id="mocha"></div>
|
13
|
+
|
14
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/10.0.0/mocha.min.js"></script>
|
15
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.3.6/chai.min.js"></script>
|
16
|
+
<script>
|
17
|
+
mocha.setup("bdd")
|
18
|
+
mocha.reporter("spec")
|
19
|
+
</script>
|
20
|
+
<script>
|
21
|
+
${additionalScripts ? additionalScripts.join("\n") : ""}
|
22
|
+
</script>
|
23
|
+
|
24
|
+
${dependencies.map((dependency) => ` <script src="/test/${dependency}"></script>`).join("\n")}
|
25
|
+
|
26
|
+
<div id="main">Test</div>
|
27
|
+
</body>
|
28
|
+
</html>`;
|
29
|
+
}
|
30
|
+
exports.generateHtml = generateHtml;
|
@@ -0,0 +1,21 @@
|
|
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.getPort = void 0;
|
7
|
+
const net_1 = __importDefault(require("net"));
|
8
|
+
async function getPort(options) {
|
9
|
+
return await new Promise((resolve, reject) => {
|
10
|
+
const server = net_1.default.createServer();
|
11
|
+
server.unref();
|
12
|
+
server.on("error", reject);
|
13
|
+
server.listen({ ...options, port: 0 }, () => {
|
14
|
+
const { port } = server.address();
|
15
|
+
server.close(() => {
|
16
|
+
resolve(port);
|
17
|
+
});
|
18
|
+
});
|
19
|
+
});
|
20
|
+
}
|
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
|
+
"version": "3.1.0",
|
4
4
|
"description": "",
|
5
5
|
"repository": {
|
6
6
|
"type": "git",
|
@@ -14,30 +14,24 @@
|
|
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"
|
22
21
|
},
|
23
22
|
"dependencies": {
|
24
|
-
"chai": "^4.3.6",
|
25
23
|
"express": "^4.18.1",
|
26
24
|
"express-http-proxy": "^1.6.3",
|
27
|
-
"
|
28
|
-
"nightwatch": "^2.3.3",
|
29
|
-
"rimraf": "^3.0.2",
|
25
|
+
"puppeteer": "^16.2.0",
|
30
26
|
"yargs": "^17.5.1"
|
31
27
|
},
|
32
28
|
"devDependencies": {
|
33
29
|
"@types/express": "^4.17.13",
|
34
30
|
"@types/express-http-proxy": "^1.6.3",
|
35
|
-
"@types/express-serve-static-core": "^4.17.30",
|
36
31
|
"@types/node": "^18.7.11",
|
37
|
-
"@types/rimraf": "^3.0.2",
|
38
32
|
"@types/yargs": "^17.0.11"
|
39
33
|
},
|
40
34
|
"publishConfig": {
|
41
|
-
"
|
35
|
+
"access": "public"
|
42
36
|
}
|
43
37
|
}
|
package/dist/generator.js
DELETED
@@ -1,203 +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
|
-
exports.generate = void 0;
|
27
|
-
const fs = __importStar(require("fs"));
|
28
|
-
const path = __importStar(require("path"));
|
29
|
-
function generate(runners, additionalScripts, debug = false, port) {
|
30
|
-
const outputPath = fs.mkdtempSync(path.join(__dirname, "..", "tmp", "browsertests-"));
|
31
|
-
let it = 1;
|
32
|
-
for (const runner of runners) {
|
33
|
-
writeHtml(outputPath, it, runner.dependencies, additionalScripts);
|
34
|
-
if (!debug) {
|
35
|
-
if (!runner.globals) {
|
36
|
-
runner.globals = [];
|
37
|
-
}
|
38
|
-
writeTestFile(outputPath, it, runner.globals);
|
39
|
-
}
|
40
|
-
it++;
|
41
|
-
}
|
42
|
-
if (!debug) {
|
43
|
-
writeConfig(outputPath, port);
|
44
|
-
}
|
45
|
-
return outputPath;
|
46
|
-
}
|
47
|
-
exports.generate = generate;
|
48
|
-
function writeHtml(outputPath, iteration, dependencies, additionalScripts) {
|
49
|
-
const html = `<!DOCTYPE html>
|
50
|
-
<html>
|
51
|
-
<head>
|
52
|
-
<title>Mocha Tests</title>
|
53
|
-
</head>
|
54
|
-
|
55
|
-
<body>
|
56
|
-
<div id="mocha"></div>
|
57
|
-
|
58
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/7.2.0/mocha.min.js"></script>
|
59
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.2.0/chai.min.js"></script>
|
60
|
-
<script>
|
61
|
-
mocha.setup("bdd")
|
62
|
-
mocha.reporter("spec")
|
63
|
-
</script>
|
64
|
-
<script>
|
65
|
-
${additionalScripts ? additionalScripts.join("\n") : ""}
|
66
|
-
</script>
|
67
|
-
|
68
|
-
${dependencies.map((dependency) => ` <script src="/test/${dependency}"></script>`).join("\n")}
|
69
|
-
|
70
|
-
<div id="main">Test</div>
|
71
|
-
</body>
|
72
|
-
</html>`;
|
73
|
-
fs.writeFileSync(path.join(outputPath, `index${iteration}.html`), html);
|
74
|
-
}
|
75
|
-
function writeTestFile(outputPath, iteration, globals) {
|
76
|
-
const globalsString = globals
|
77
|
-
.map((glob) => `if (!window.${glob}) {
|
78
|
-
console.log("Required library '${glob}' not loaded. Aborting...")
|
79
|
-
done({ failures: 1 })
|
80
|
-
return
|
81
|
-
}`)
|
82
|
-
.join("\n");
|
83
|
-
const testContent = `const expect = require("chai").expect
|
84
|
-
|
85
|
-
describe("Browser Mocha Tests", function () {
|
86
|
-
beforeEach((client, done) => {
|
87
|
-
client.url("http://localhost:7777/test-browser/index${iteration}.html")
|
88
|
-
done()
|
89
|
-
})
|
90
|
-
|
91
|
-
after((client, done) => {
|
92
|
-
client.end(() => done())
|
93
|
-
})
|
94
|
-
|
95
|
-
it("Should run the Mocha tests without error", async (client) => {
|
96
|
-
client.captureBrowserConsoleLogs((event) => {
|
97
|
-
const args = event.args.map((arg) => arg.value)
|
98
|
-
console.log.apply(console, args)
|
99
|
-
})
|
100
|
-
|
101
|
-
client.waitForElementVisible("#main")
|
102
|
-
|
103
|
-
const executeFunction = (done) => {
|
104
|
-
const mocha = window.mocha
|
105
|
-
|
106
|
-
//add required test librarys in this if statement
|
107
|
-
if (!mocha) {
|
108
|
-
console.log("Required library 'mocha' not loaded. Aborting...")
|
109
|
-
done({ failures: 1 })
|
110
|
-
return
|
111
|
-
}
|
112
|
-
|
113
|
-
${globalsString}
|
114
|
-
|
115
|
-
mocha.run(function (failures) {
|
116
|
-
done({ failures: failures })
|
117
|
-
})
|
118
|
-
}
|
119
|
-
|
120
|
-
const result = await new Promise(resolve => client.timeoutsAsyncScript(1500000).executeAsyncScript(
|
121
|
-
executeFunction,
|
122
|
-
(result) => resolve(result)
|
123
|
-
))
|
124
|
-
|
125
|
-
expect(result.value).to.not.be.undefined
|
126
|
-
expect(result.value.failures).to.equal(0)
|
127
|
-
})
|
128
|
-
})`;
|
129
|
-
fs.writeFileSync(path.join(outputPath, `mocha${iteration}.test.js`), testContent);
|
130
|
-
}
|
131
|
-
function requireGlobal(packageName) {
|
132
|
-
var childProcess = require("child_process");
|
133
|
-
var path = require("path");
|
134
|
-
var fs = require("fs");
|
135
|
-
var globalNodeModules = childProcess.execSync("npm root -g").toString().trim();
|
136
|
-
var packageDir = path.join(globalNodeModules, packageName);
|
137
|
-
if (!fs.existsSync(packageDir))
|
138
|
-
packageDir = path.join(globalNodeModules, "npm/node_modules", packageName); //find package required by old npm
|
139
|
-
if (!fs.existsSync(packageDir))
|
140
|
-
throw new Error("Cannot find global module '" + packageName + "'");
|
141
|
-
var packageMeta = JSON.parse(fs.readFileSync(path.join(packageDir, "package.json")).toString());
|
142
|
-
var main = path.join(packageDir, packageMeta.main);
|
143
|
-
return require(main);
|
144
|
-
}
|
145
|
-
function writeConfig(outputPath, port) {
|
146
|
-
const settings = {
|
147
|
-
src_folders: [outputPath],
|
148
|
-
filter: "*.test.js",
|
149
|
-
webdriver: {
|
150
|
-
start_process: true,
|
151
|
-
server_path: "",
|
152
|
-
port: port,
|
153
|
-
timeout_options: {
|
154
|
-
timeout: 1500000
|
155
|
-
}
|
156
|
-
},
|
157
|
-
test_runner: {
|
158
|
-
type: "mocha",
|
159
|
-
options: {
|
160
|
-
ui: "bdd",
|
161
|
-
reporter: "spec"
|
162
|
-
}
|
163
|
-
},
|
164
|
-
test_settings: {
|
165
|
-
default: {
|
166
|
-
request_timeout_options: {
|
167
|
-
timeout: 1500000
|
168
|
-
},
|
169
|
-
desiredCapabilities: {
|
170
|
-
javascriptEnabled: true,
|
171
|
-
acceptSslCerts: true,
|
172
|
-
acceptInsecureCerts: true,
|
173
|
-
browserName: "chrome",
|
174
|
-
"goog:chromeOptions": {
|
175
|
-
w3c: true,
|
176
|
-
args: [
|
177
|
-
"--headless",
|
178
|
-
"--disable-gpu",
|
179
|
-
"--ignore-certificate-errors",
|
180
|
-
"--no-sandbox",
|
181
|
-
"--disable-features=NetworkService"
|
182
|
-
],
|
183
|
-
binary: "/usr/bin/google-chrome"
|
184
|
-
}
|
185
|
-
}
|
186
|
-
}
|
187
|
-
},
|
188
|
-
globals: {
|
189
|
-
waitForConditionTimeout: 100000,
|
190
|
-
asyncHookTimeout: 1500000,
|
191
|
-
unitTestsTimeout: 100000,
|
192
|
-
customReporterCallbackTimeout: 100000,
|
193
|
-
retryAssertionTimeout: 50000
|
194
|
-
}
|
195
|
-
};
|
196
|
-
//@ts-ignore
|
197
|
-
if (process.platform === "win32" || process.platform === "win64") {
|
198
|
-
settings.test_settings.default.desiredCapabilities["goog:chromeOptions"].binary =
|
199
|
-
"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe";
|
200
|
-
}
|
201
|
-
settings.webdriver.server_path = requireGlobal("chromedriver").path;
|
202
|
-
fs.writeFileSync(path.join(outputPath, "nightwatch.json"), JSON.stringify(settings));
|
203
|
-
}
|
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(7777, () => { });
|
package/tmp/.gitkeep
DELETED
File without changes
|
@@ -1,27 +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
|
-
|
11
|
-
|
12
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/7.2.0/mocha.min.js"></script>
|
13
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.2.0/chai.min.js"></script>
|
14
|
-
<script>
|
15
|
-
mocha.setup("bdd")
|
16
|
-
mocha.reporter("spec")
|
17
|
-
</script>
|
18
|
-
<script>
|
19
|
-
window.TEST = {}
|
20
|
-
window.TEST2 = {}
|
21
|
-
</script>
|
22
|
-
|
23
|
-
<script src="/test/test.js"></script>
|
24
|
-
|
25
|
-
<div id="main">Test</div>
|
26
|
-
</body>
|
27
|
-
</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/7.2.0/mocha.min.js"></script>
|
11
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.2.0/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,56 +0,0 @@
|
|
1
|
-
const expect = require("chai").expect
|
2
|
-
|
3
|
-
describe("Browser Mocha Tests", function () {
|
4
|
-
beforeEach((client, done) => {
|
5
|
-
client.url("http://localhost:7777/test-browser/index1.html")
|
6
|
-
done()
|
7
|
-
})
|
8
|
-
|
9
|
-
after((client, done) => {
|
10
|
-
client.end(() => done())
|
11
|
-
})
|
12
|
-
|
13
|
-
it("Should run the Mocha tests without error", async (client) => {
|
14
|
-
client.captureBrowserConsoleLogs((event) => {
|
15
|
-
const args = event.args.map((arg) => arg.value)
|
16
|
-
args[0] = "BROWSER LOG - " + args[0]
|
17
|
-
console.log.apply(console, args)
|
18
|
-
})
|
19
|
-
|
20
|
-
client.waitForElementVisible("#main")
|
21
|
-
|
22
|
-
const executeFunction = (done) => {
|
23
|
-
const mocha = window.mocha
|
24
|
-
|
25
|
-
//add required test librarys in this if statement
|
26
|
-
if (!mocha) {
|
27
|
-
console.log("Required library 'mocha' not loaded. Aborting...")
|
28
|
-
done({ failures: 1 })
|
29
|
-
return
|
30
|
-
}
|
31
|
-
|
32
|
-
if (!window.TEST) {
|
33
|
-
console.log("Required library 'TEST' not loaded. Aborting...")
|
34
|
-
localDone({ failures: 1 })
|
35
|
-
return
|
36
|
-
}
|
37
|
-
if (!window.TEST2) {
|
38
|
-
console.log("Required library 'TEST2' not loaded. Aborting...")
|
39
|
-
localDone({ failures: 1 })
|
40
|
-
return
|
41
|
-
}
|
42
|
-
|
43
|
-
mocha.run(function (failures) {
|
44
|
-
done({ failures: failures })
|
45
|
-
})
|
46
|
-
}
|
47
|
-
|
48
|
-
const result = await new Promise(resolve => client.timeoutsAsyncScript(1500000).executeAsyncScript(
|
49
|
-
executeFunction,
|
50
|
-
(result) => resolve(result)
|
51
|
-
))
|
52
|
-
|
53
|
-
expect(result.value).to.not.be.undefined
|
54
|
-
expect(result.value.failures).to.equal(0)
|
55
|
-
})
|
56
|
-
})
|
@@ -1 +0,0 @@
|
|
1
|
-
{"src_folders":["/home/julian/git/jss/docker-node-browsertests/test-runner/tmp/browsertests-71yT6w"],"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/7.2.0/mocha.min.js"></script>
|
11
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.2.0/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,55 +0,0 @@
|
|
1
|
-
const expect = require("chai").expect
|
2
|
-
|
3
|
-
describe("Browser Mocha Tests", function () {
|
4
|
-
beforeEach((client, done) => {
|
5
|
-
client.url("http://localhost:7777/test-browser/index1.html")
|
6
|
-
done()
|
7
|
-
})
|
8
|
-
|
9
|
-
after((client, done) => {
|
10
|
-
client.end(() => done())
|
11
|
-
})
|
12
|
-
|
13
|
-
it("Should run the Mocha tests without error", async (client) => {
|
14
|
-
client.captureBrowserConsoleLogs((event) => {
|
15
|
-
const args = event.args.map((arg) => arg.value)
|
16
|
-
console.log.apply(console, args)
|
17
|
-
})
|
18
|
-
|
19
|
-
client.waitForElementVisible("#main")
|
20
|
-
|
21
|
-
const executeFunction = (done) => {
|
22
|
-
const mocha = window.mocha
|
23
|
-
|
24
|
-
//add required test librarys in this if statement
|
25
|
-
if (!mocha) {
|
26
|
-
console.log("Required library 'mocha' not loaded. Aborting...")
|
27
|
-
done({ failures: 1 })
|
28
|
-
return
|
29
|
-
}
|
30
|
-
|
31
|
-
if (!window.TEST) {
|
32
|
-
console.log("Required library 'TEST' not loaded. Aborting...")
|
33
|
-
localDone({ failures: 1 })
|
34
|
-
return
|
35
|
-
}
|
36
|
-
if (!window.TEST2) {
|
37
|
-
console.log("Required library 'TEST2' not loaded. Aborting...")
|
38
|
-
localDone({ failures: 1 })
|
39
|
-
return
|
40
|
-
}
|
41
|
-
|
42
|
-
mocha.run(function (failures) {
|
43
|
-
done({ failures: failures })
|
44
|
-
})
|
45
|
-
}
|
46
|
-
|
47
|
-
const result = await new Promise(resolve => client.timeoutsAsyncScript(1500000).executeAsyncScript(
|
48
|
-
executeFunction,
|
49
|
-
(result) => resolve(result)
|
50
|
-
))
|
51
|
-
|
52
|
-
expect(result.value).to.not.be.undefined
|
53
|
-
expect(result.value.failures).to.equal(0)
|
54
|
-
})
|
55
|
-
})
|
@@ -1 +0,0 @@
|
|
1
|
-
{"src_folders":["/home/julian/git/jss/docker-node-browsertests/test-runner/tmp/browsertests-nIABth"],"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":{"reporter":"List"}},"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,36 +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
|
-
|
11
|
-
<script>
|
12
|
-
window.logs = []
|
13
|
-
const oldLog = console.log
|
14
|
-
console.log = function () {
|
15
|
-
oldLog.apply(console, arguments)
|
16
|
-
window.logs.push(Array.from(arguments))
|
17
|
-
}
|
18
|
-
</script>
|
19
|
-
|
20
|
-
|
21
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/7.2.0/mocha.min.js"></script>
|
22
|
-
<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.2.0/chai.min.js"></script>
|
23
|
-
<script>
|
24
|
-
mocha.setup("bdd")
|
25
|
-
mocha.reporter("spec")
|
26
|
-
</script>
|
27
|
-
<script>
|
28
|
-
window.TEST = {}
|
29
|
-
window.TEST2 = {}
|
30
|
-
</script>
|
31
|
-
|
32
|
-
<script src="/test/test.js"></script>
|
33
|
-
|
34
|
-
<div id="main">Test</div>
|
35
|
-
</body>
|
36
|
-
</html>
|
@@ -1,69 +0,0 @@
|
|
1
|
-
const expect = require("chai").expect
|
2
|
-
|
3
|
-
describe("Browser Mocha Tests", function () {
|
4
|
-
beforeEach((client, done) => {
|
5
|
-
client.url("http://localhost:7777/test-browser/index1.html")
|
6
|
-
done()
|
7
|
-
})
|
8
|
-
|
9
|
-
after((client, done) => {
|
10
|
-
client.end(() => done())
|
11
|
-
})
|
12
|
-
|
13
|
-
it("Should run the Mocha tests without error", (client) => {
|
14
|
-
const outsideLog = console.log
|
15
|
-
|
16
|
-
client.waitForElementVisible("#main")
|
17
|
-
client.timeoutsAsyncScript(1500000).executeAsync(
|
18
|
-
(_data, done) => {
|
19
|
-
const oldLog = console.log
|
20
|
-
console.log = function () {
|
21
|
-
oldLog.apply(console, arguments)
|
22
|
-
outsideLog.apply(console, arguments)
|
23
|
-
window.logs.push(Array.from(arguments))
|
24
|
-
}
|
25
|
-
|
26
|
-
const localDone = typeof _data === "function" ? _data : done
|
27
|
-
|
28
|
-
const mocha = window.mocha
|
29
|
-
|
30
|
-
//add required test librarys in this if statement
|
31
|
-
if (!mocha) {
|
32
|
-
logs.push(["Required library 'mocha' not loaded. Aborting..."])
|
33
|
-
localDone({ failures: 1, logs: logs })
|
34
|
-
return
|
35
|
-
}
|
36
|
-
|
37
|
-
if (!window.TEST) {
|
38
|
-
logs.push(["Required library 'TEST' not loaded. Aborting..."])
|
39
|
-
localDone({ failures: 1, logs: logs })
|
40
|
-
return
|
41
|
-
}
|
42
|
-
if (!window.TEST2) {
|
43
|
-
logs.push(["Required library 'TEST2' not loaded. Aborting..."])
|
44
|
-
localDone({ failures: 1, logs: logs })
|
45
|
-
return
|
46
|
-
}
|
47
|
-
|
48
|
-
mocha.run(function (failures) {
|
49
|
-
localDone({ failures: failures, logs: logs })
|
50
|
-
})
|
51
|
-
},
|
52
|
-
[],
|
53
|
-
(result) => {
|
54
|
-
console.log("\n--- browser mocha output ---")
|
55
|
-
|
56
|
-
if (result && result.value && result.value.logs) {
|
57
|
-
for (const logs of result.value.logs) {
|
58
|
-
console.log.apply(null, logs)
|
59
|
-
}
|
60
|
-
}
|
61
|
-
|
62
|
-
console.log("--- finished browser mocha output ---")
|
63
|
-
|
64
|
-
expect(result.value).to.not.be.undefined
|
65
|
-
expect(result.value.failures).to.equal(0)
|
66
|
-
}
|
67
|
-
)
|
68
|
-
})
|
69
|
-
})
|
@@ -1 +0,0 @@
|
|
1
|
-
{"src_folders":["/home/julian/git/jss/docker-node-browsertests/test-runner/tmp/browsertests-sBNC3W"],"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}}
|