browser-ava 1.3.5 → 1.3.7
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 -2
- package/src/browser/runtime.mjs +8 -5
- package/src/browser/util.mjs +0 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browser-ava",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.7",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"commander": "^9.4.1",
|
|
33
33
|
"es-module-lexer": "^1.0.5",
|
|
34
34
|
"globby": "^13.1.2",
|
|
35
|
-
"koa": "^2.
|
|
35
|
+
"koa": "^2.14.0",
|
|
36
36
|
"koa-static": "^5.0.0",
|
|
37
37
|
"playwright": "^1.27.1",
|
|
38
38
|
"ws": "^8.11.0"
|
package/src/browser/runtime.mjs
CHANGED
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
calculateSummary,
|
|
4
4
|
summaryMessages,
|
|
5
5
|
pluralize,
|
|
6
|
-
stringify,
|
|
7
6
|
moduleName
|
|
8
7
|
} from "./util.mjs";
|
|
9
8
|
import { isEqual } from "./eql.mjs";
|
|
@@ -19,7 +18,11 @@ for (const slot of ["log", "info", "error"]) {
|
|
|
19
18
|
|
|
20
19
|
console[slot] = (...args) => {
|
|
21
20
|
if (ws) {
|
|
22
|
-
|
|
21
|
+
// TODO how to serialize Error instances ?
|
|
22
|
+
if(args[0] instanceof Error) {
|
|
23
|
+
args[0] = "Error: " + args[0].message;
|
|
24
|
+
}
|
|
25
|
+
ws.send(JSON.stringify({ action: slot, data: args }));
|
|
23
26
|
}
|
|
24
27
|
former(...args);
|
|
25
28
|
};
|
|
@@ -51,7 +54,7 @@ ws.onmessage = async message => {
|
|
|
51
54
|
|
|
52
55
|
displayTests();
|
|
53
56
|
if (errors === 0) {
|
|
54
|
-
ws.send(stringify({ action: "ready" }));
|
|
57
|
+
ws.send(JSON.stringify({ action: "ready" }));
|
|
55
58
|
}
|
|
56
59
|
}
|
|
57
60
|
break;
|
|
@@ -178,7 +181,7 @@ async function runTest(parent, tm, test) {
|
|
|
178
181
|
test.passed = false;
|
|
179
182
|
test.message = e;
|
|
180
183
|
} finally {
|
|
181
|
-
ws.send(stringify({ action: "update", data: test }));
|
|
184
|
+
ws.send(JSON.stringify({ action: "update", data: test }));
|
|
182
185
|
}
|
|
183
186
|
}
|
|
184
187
|
}
|
|
@@ -220,7 +223,7 @@ async function runTestModule(tm) {
|
|
|
220
223
|
async function runTestModules() {
|
|
221
224
|
await Promise.all(testModules.map(tm => runTestModule(tm)));
|
|
222
225
|
|
|
223
|
-
ws.send(stringify({ action: "result", data: testModules }));
|
|
226
|
+
ws.send(JSON.stringify({ action: "result", data: testModules }));
|
|
224
227
|
|
|
225
228
|
displayTests();
|
|
226
229
|
}
|
package/src/browser/util.mjs
CHANGED
|
@@ -67,17 +67,6 @@ export function summaryMessages(summary) {
|
|
|
67
67
|
return messages;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
/**
|
|
71
|
-
* @TODO HACK to be able to sent BigInt
|
|
72
|
-
*/
|
|
73
|
-
export function stringify(...args) {
|
|
74
|
-
const former = BigInt.prototype.toJSON;
|
|
75
|
-
BigInt.prototype.toJSON = (v) => v.toString();
|
|
76
|
-
const string = JSON.stringify(...args);
|
|
77
|
-
BigInt.prototype.toJSON = former;
|
|
78
|
-
return string;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
70
|
export function moduleName(url) {
|
|
82
71
|
return url.replace(/\.m?js$/,'')
|
|
83
72
|
}
|