browser-ava 1.0.1 → 1.0.3
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/package.json +2 -1
- package/src/browser/util.mjs +7 -0
- package/src/browser-ava-cli.mjs +13 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browser-ava",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"commander": "^9.4.1",
|
|
31
31
|
"es-module-lexer": "^1.0.5",
|
|
32
|
+
"globby": "^13.1.2",
|
|
32
33
|
"koa": "^2.13.4",
|
|
33
34
|
"koa-static": "^5.0.0",
|
|
34
35
|
"playwright": "^1.27.1",
|
package/src/browser/util.mjs
CHANGED
|
@@ -32,9 +32,16 @@ export function calculateSummary(testModules) {
|
|
|
32
32
|
return { passed, failed, knownFailure, skip, todo };
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
/**
|
|
36
|
+
* Pluralize subjects
|
|
37
|
+
* @param {string} word subject to be pluralized
|
|
38
|
+
* @param {number} number if > 1 pluralize otherwize keep subject alone
|
|
39
|
+
* @returns {string} pluralized subject if number > 1
|
|
40
|
+
*/
|
|
35
41
|
export function pluralize(word, number) {
|
|
36
42
|
return number > 1 ? word + "s" : word;
|
|
37
43
|
}
|
|
44
|
+
|
|
38
45
|
export function summaryMessages(summary) {
|
|
39
46
|
const messages = [];
|
|
40
47
|
|
package/src/browser-ava-cli.mjs
CHANGED
|
@@ -10,6 +10,8 @@ import { WebSocketServer } from "ws";
|
|
|
10
10
|
import { program, Option } from "commander";
|
|
11
11
|
import { calculateSummary, summaryMessages } from "./browser/util.mjs";
|
|
12
12
|
import { resolveImport } from "./resolver.mjs";
|
|
13
|
+
import { globby } from "globby";
|
|
14
|
+
import chalk from "chalk";
|
|
13
15
|
|
|
14
16
|
const utf8EncodingOptions = { encoding: "utf8" };
|
|
15
17
|
|
|
@@ -68,13 +70,9 @@ program
|
|
|
68
70
|
|
|
69
71
|
await init;
|
|
70
72
|
|
|
71
|
-
tests = tests
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
.filter(file => !file.match(/[\*\?]/))
|
|
75
|
-
.map(file => {
|
|
76
|
-
return { url: resolve(process.cwd(), file), file };
|
|
77
|
-
});
|
|
73
|
+
tests = (await globby(tests)).map(file => {
|
|
74
|
+
return { url: resolve(process.cwd(), file), file };
|
|
75
|
+
});
|
|
78
76
|
|
|
79
77
|
const { server, wss } = await createServer(tests, options);
|
|
80
78
|
|
|
@@ -110,8 +108,15 @@ program
|
|
|
110
108
|
case "result":
|
|
111
109
|
const summary = calculateSummary(data.data);
|
|
112
110
|
|
|
111
|
+
const classToColor = {
|
|
112
|
+
failed: "red",
|
|
113
|
+
passed: "green",
|
|
114
|
+
todo: "blue",
|
|
115
|
+
skip: "yellow"
|
|
116
|
+
};
|
|
117
|
+
|
|
113
118
|
for (const m of summaryMessages(summary)) {
|
|
114
|
-
console.log(m.text);
|
|
119
|
+
console.log(" " + chalk[classToColor[m.colorClass] || "black"](m.text));
|
|
115
120
|
}
|
|
116
121
|
|
|
117
122
|
await shutdown(summary.failed);
|