bt-runner 2.0.4 → 2.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/generator.js CHANGED
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[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);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -26,7 +30,7 @@ function generate(runners, additionalScripts, debug = false, port) {
26
30
  const outputPath = fs.mkdtempSync(path.join(__dirname, "..", "tmp", "browsertests-"));
27
31
  let it = 1;
28
32
  for (const runner of runners) {
29
- writeHtml(outputPath, it, runner.dependencies, additionalScripts, debug);
33
+ writeHtml(outputPath, it, runner.dependencies, additionalScripts);
30
34
  if (!debug) {
31
35
  if (!runner.globals) {
32
36
  runner.globals = [];
@@ -41,7 +45,7 @@ function generate(runners, additionalScripts, debug = false, port) {
41
45
  return outputPath;
42
46
  }
43
47
  exports.generate = generate;
44
- function writeHtml(outputPath, iteration, dependencies, additionalScripts, debug) {
48
+ function writeHtml(outputPath, iteration, dependencies, additionalScripts) {
45
49
  const html = `<!DOCTYPE html>
46
50
  <html>
47
51
  <head>
@@ -50,19 +54,6 @@ function writeHtml(outputPath, iteration, dependencies, additionalScripts, debug
50
54
 
51
55
  <body>
52
56
  <div id="mocha"></div>
53
-
54
- ${debug
55
- ? ""
56
- : `
57
- <script>
58
- window.logs = []
59
- const oldLog = console.log
60
- console.log = function () {
61
- oldLog.apply(console, arguments)
62
- window.logs.push(Array.from(arguments))
63
- }
64
- </script>
65
- `}
66
57
 
67
58
  <script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/7.2.0/mocha.min.js"></script>
68
59
  <script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.2.0/chai.min.js"></script>
@@ -84,8 +75,8 @@ function writeHtml(outputPath, iteration, dependencies, additionalScripts, debug
84
75
  function writeTestFile(outputPath, iteration, globals) {
85
76
  const globalsString = globals
86
77
  .map((glob) => `if (!window.${glob}) {
87
- logs.push(["Required library '${glob}' not loaded. Aborting..."])
88
- localDone({ failures: 1, logs: logs })
78
+ console.log("Required library '${glob}' not loaded. Aborting...")
79
+ done({ failures: 1 })
89
80
  return
90
81
  }`)
91
82
  .join("\n");
@@ -101,43 +92,38 @@ function writeTestFile(outputPath, iteration, globals) {
101
92
  client.end(() => done())
102
93
  })
103
94
 
104
- it("Should run the Mocha tests without error", (client) => {
105
- client.waitForElementVisible("#main")
106
- client.timeoutsAsyncScript(1500000).executeAsync(
107
- (_data, done) => {
108
- const localDone = typeof _data === "function" ? _data : done
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
+ })
109
100
 
110
- const mocha = window.mocha
111
-
112
- //add required test librarys in this if statement
113
- if (!mocha) {
114
- logs.push(["Required library 'mocha' not loaded. Aborting..."])
115
- localDone({ failures: 1, logs: logs })
116
- return
117
- }
101
+ client.waitForElementVisible("#main")
118
102
 
119
- ${globalsString}
120
-
121
- mocha.run(function (failures) {
122
- localDone({ failures: failures, logs: logs })
123
- })
124
- },
125
- [],
126
- (result) => {
127
- console.log("\\n--- browser mocha output ---")
103
+ const executeFunction = (done) => {
104
+ const mocha = window.mocha
128
105
 
129
- if (result && result.value && result.value.logs) {
130
- for (const logs of result.value.logs) {
131
- console.log.apply(null, logs)
132
- }
133
- }
134
-
135
- console.log("--- finished browser mocha output ---")
136
-
137
- expect(result.value).to.not.be.undefined
138
- expect(result.value.failures).to.equal(0)
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
139
111
  }
140
- )
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)
141
127
  })
142
128
  })`;
143
129
  fs.writeFileSync(path.join(outputPath, `mocha${iteration}.test.js`), testContent);
@@ -163,7 +149,10 @@ function writeConfig(outputPath, port) {
163
149
  webdriver: {
164
150
  start_process: true,
165
151
  server_path: "",
166
- port: port
152
+ port: port,
153
+ timeout_options: {
154
+ timeout: 1500000
155
+ }
167
156
  },
168
157
  test_runner: {
169
158
  type: "mocha",
@@ -210,5 +199,5 @@ function writeConfig(outputPath, port) {
210
199
  "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe";
211
200
  }
212
201
  settings.webdriver.server_path = requireGlobal("chromedriver").path;
213
- fs.writeFileSync(path.join(outputPath, `nightwatch.json`), JSON.stringify(settings));
202
+ fs.writeFileSync(path.join(outputPath, "nightwatch.json"), JSON.stringify(settings));
214
203
  }
package/dist/index.js CHANGED
@@ -2,7 +2,11 @@
2
2
  "use strict";
3
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
4
  if (k2 === undefined) k2 = k;
5
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
6
10
  }) : (function(o, m, k, k2) {
7
11
  if (k2 === undefined) k2 = k;
8
12
  o[k2] = m[k];
@@ -2,7 +2,11 @@
2
2
  "use strict";
3
3
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
4
  if (k2 === undefined) k2 = k;
5
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
6
10
  }) : (function(o, m, k, k2) {
7
11
  if (k2 === undefined) k2 = k;
8
12
  o[k2] = m[k];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bt-runner",
3
- "version": "2.0.4",
3
+ "version": "2.1.0",
4
4
  "description": "",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,20 +22,20 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "chai": "^4.3.6",
25
- "express": "^4.17.3",
25
+ "express": "^4.18.1",
26
26
  "express-http-proxy": "^1.6.3",
27
- "mocha": "^9.2.1",
28
- "nightwatch": "^2.0.7",
27
+ "mocha": "^10.0.0",
28
+ "nightwatch": "^2.3.3",
29
29
  "rimraf": "^3.0.2",
30
- "yargs": "^17.3.1"
30
+ "yargs": "^17.5.1"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/express": "^4.17.13",
34
34
  "@types/express-http-proxy": "^1.6.3",
35
- "@types/express-serve-static-core": "^4.17.28",
36
- "@types/node": "^17.0.18",
35
+ "@types/express-serve-static-core": "^4.17.30",
36
+ "@types/node": "^18.7.11",
37
37
  "@types/rimraf": "^3.0.2",
38
- "@types/yargs": "^17.0.8"
38
+ "@types/yargs": "^17.0.11"
39
39
  },
40
40
  "publishConfig": {
41
41
  "registry": "https://registry.npmjs.org"
@@ -0,0 +1,27 @@
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>
@@ -0,0 +1,25 @@
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>
@@ -0,0 +1,56 @@
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
+ })
@@ -0,0 +1 @@
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}}
@@ -0,0 +1,25 @@
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>
@@ -0,0 +1,55 @@
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
+ })
@@ -0,0 +1 @@
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}}
@@ -0,0 +1,36 @@
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>
@@ -0,0 +1,69 @@
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
+ })
@@ -0,0 +1 @@
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}}