bt-runner 4.0.0 → 4.0.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 j&s-soft GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,10 @@
1
+ # bt-runner
2
+
3
+ [![GitHub Actions CI](https://github.com/js-soft/bt-runner/workflows/Publish/badge.svg)](https://github.com/js-soft/bt-runner/actions?query=workflow%3APublish)
4
+ [![npm version](https://badge.fury.io/js/bt-runner.svg)](https://www.npmjs.com/package/bt-runner)
5
+
6
+ A browser-based test runner for NodeJS.
7
+
8
+ ## License
9
+
10
+ [MIT](LICENSE)
package/dist/index.js CHANGED
@@ -63,4 +63,7 @@ async function run() {
63
63
  }
64
64
  process.exit(exitCode);
65
65
  }
66
- run();
66
+ run().catch((e) => {
67
+ console.error(e);
68
+ process.exit(1);
69
+ });
@@ -55,7 +55,7 @@ class Server {
55
55
  app.use(proxy.local, httpproxy(proxy.remote));
56
56
  }
57
57
  }
58
- this.server = app.listen(this.port, () => { });
58
+ this.server = app.listen(this.port);
59
59
  return this;
60
60
  }
61
61
  transformProxy(proxy) {
@@ -66,7 +66,6 @@ class Server {
66
66
  if (match) {
67
67
  const envVar = match[1];
68
68
  const envValue = process.env[envVar];
69
- console.log(envValue);
70
69
  if (!envValue)
71
70
  throw new Error(`Environment variable ${envVar} is not defined`);
72
71
  remote = remote.replace(match[0], envValue);
@@ -11,8 +11,8 @@ function generateHtml(dependencies, additionalScripts) {
11
11
  <body>
12
12
  <div id="mocha"></div>
13
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>
14
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/mocha/10.2.0/mocha.min.js"></script>
15
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/chai/4.3.7/chai.min.js"></script>
16
16
  <script>
17
17
  mocha.setup("bdd")
18
18
  mocha.reporter("spec")
@@ -21,9 +21,8 @@ async function runTests(serverPort, testRunners, debug) {
21
21
  await page.goto(`http://localhost:${serverPort}/test-browser/index${runnerNumber}.html`);
22
22
  // patch all process.env variables into the browsers "process.env"
23
23
  await page.evaluate((params) => {
24
- // @ts-expect-error
25
- globalThis.process = globalThis.process ?? {};
26
- globalThis.process.env = globalThis.process.env ?? {};
24
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
25
+ globalThis.process = globalThis.process ?? { env: {} };
27
26
  globalThis.process.env = { ...globalThis.process.env, ...params };
28
27
  }, process.env);
29
28
  for (const dependency of runner.dependencies) {
@@ -38,15 +37,16 @@ async function runTests(serverPort, testRunners, debug) {
38
37
  return { failures: 1 };
39
38
  }
40
39
  }
41
- return new Promise((resolve) => window.mocha.run(function (failures) {
40
+ return await new Promise((resolve) => window.mocha.run(function (failures) {
42
41
  resolve({ failures: failures });
43
42
  }));
44
43
  }, runner.globals ?? []);
45
44
  if (debug) {
46
45
  console.log("Press any key to continue...");
46
+ // eslint-disable-next-line no-loop-func
47
47
  await new Promise((resolve) => process.stdin.once("data", resolve));
48
48
  }
49
- if (result.failures != 0) {
49
+ if (result.failures !== 0) {
50
50
  await browser.close();
51
51
  return false;
52
52
  }
package/package.json CHANGED
@@ -1,13 +1,10 @@
1
1
  {
2
2
  "name": "bt-runner",
3
- "version": "4.0.0",
3
+ "version": "4.0.2",
4
4
  "description": "",
5
- "repository": {
6
- "type": "git",
7
- "url": "https://github.com/js-soft/docker-node-browsertests"
8
- },
9
- "license": "ISC",
10
- "author": "js-soft <julian.koenig@js-soft.com> (https://www.js-soft.com/)",
5
+ "repository": "github:js-soft/bt-runner",
6
+ "license": "MIT",
7
+ "author": "js-soft GmbH (https://www.js-soft.com/)",
11
8
  "main": "index.js",
12
9
  "bin": {
13
10
  "browsertest-runner": "dist/index.js"
@@ -15,8 +12,17 @@
15
12
  "files": [
16
13
  "dist"
17
14
  ],
15
+ "workspaces": [
16
+ ".",
17
+ "example"
18
+ ],
18
19
  "scripts": {
19
- "prepublishOnly": "tsc"
20
+ "build": "tsc",
21
+ "lint": "npm run lint:prettier && npm run lint:eslint && npm run lint:tsc",
22
+ "lint:eslint": "eslint --ext ts ./src",
23
+ "lint:prettier": "prettier --check .",
24
+ "lint:tsc": "tsc --noEmit",
25
+ "test": "npm run test --workspace example"
20
26
  },
21
27
  "dependencies": {
22
28
  "express": "^4.18.2",
@@ -25,10 +31,14 @@
25
31
  "yargs": "^17.7.1"
26
32
  },
27
33
  "devDependencies": {
34
+ "@js-soft/eslint-config-ts": "^1.6.2",
35
+ "@js-soft/license-check": "^1.0.6",
28
36
  "@types/express": "^4.17.17",
29
37
  "@types/express-http-proxy": "^1.6.3",
30
38
  "@types/node": "^18.14.6",
31
- "@types/yargs": "^17.0.22"
39
+ "@types/yargs": "^17.0.22",
40
+ "eslint": "^8.36.0",
41
+ "prettier": "^2.8.4"
32
42
  },
33
43
  "publishConfig": {
34
44
  "access": "public"