browser-ava 2.3.38 → 2.3.40
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/runtime.mjs +27 -14
- package/src/browser-ava-cli.mjs +3 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "browser-ava",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.40",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"commander": "^14.0.1",
|
|
42
42
|
"es-module-lexer": "^1.7.0",
|
|
43
43
|
"globby": "^15.0.0",
|
|
44
|
+
"json-cyclic": "^1.0.2",
|
|
44
45
|
"koa": "^3.0.1",
|
|
45
46
|
"koa-static": "^5.0.0",
|
|
46
47
|
"playwright": "^1.56.0",
|
package/src/browser/runtime.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { decycle } from "./node_modules/json-cyclic/dist/index.esm.js";
|
|
1
2
|
import { testModules, test } from "./ava.mjs";
|
|
2
3
|
import {
|
|
3
4
|
calculateSummary,
|
|
@@ -18,11 +19,9 @@ Error.prototype.toJSON = primitiveRoString;
|
|
|
18
19
|
|
|
19
20
|
function allErrorProperties(key, value) {
|
|
20
21
|
if (value instanceof Error) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
forEach((key) => error[key] = value[key]);
|
|
25
|
-
return error;
|
|
22
|
+
const error = {};
|
|
23
|
+
Object.getOwnPropertyNames(value).forEach(key => (error[key] = value[key]));
|
|
24
|
+
return error;
|
|
26
25
|
}
|
|
27
26
|
return value;
|
|
28
27
|
}
|
|
@@ -35,7 +34,7 @@ for (const action of ["log", "info", "error"]) {
|
|
|
35
34
|
|
|
36
35
|
console[action] = (...data) => {
|
|
37
36
|
if (ws) {
|
|
38
|
-
ws.send(JSON.stringify({ action, data }, allErrorProperties));
|
|
37
|
+
ws.send(JSON.stringify(decycle({ action, data }), allErrorProperties));
|
|
39
38
|
}
|
|
40
39
|
former(...data);
|
|
41
40
|
};
|
|
@@ -96,7 +95,9 @@ async function displayTests() {
|
|
|
96
95
|
.map(a => (a.title || "") + " " + (a.message || ""))
|
|
97
96
|
.join(" ")
|
|
98
97
|
: ""
|
|
99
|
-
}</span>${t.message ? t.message : ""}${
|
|
98
|
+
}</span>${t.message ? t.message : ""}${
|
|
99
|
+
t.stack ? "<br>" + t.stack : ""
|
|
100
|
+
}</li>`;
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
function renderModule(tm) {
|
|
@@ -200,7 +201,12 @@ async function runTest(parent, tm, testInstance) {
|
|
|
200
201
|
testInstance.message = e;
|
|
201
202
|
testInstance.stack = e.stack;
|
|
202
203
|
} finally {
|
|
203
|
-
ws.send(
|
|
204
|
+
ws.send(
|
|
205
|
+
JSON.stringify(
|
|
206
|
+
decycle({ action: "update", data: testInstance }),
|
|
207
|
+
allErrorProperties
|
|
208
|
+
)
|
|
209
|
+
);
|
|
204
210
|
}
|
|
205
211
|
}
|
|
206
212
|
}
|
|
@@ -240,14 +246,21 @@ async function runTestModule(tm) {
|
|
|
240
246
|
}
|
|
241
247
|
|
|
242
248
|
async function runTestModules() {
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
249
|
+
const results = await Promise.allSettled(
|
|
250
|
+
testModules.map(tm => runTestModule(tm))
|
|
251
|
+
);
|
|
252
|
+
|
|
253
|
+
let i = 0;
|
|
254
|
+
for (const result of results) {
|
|
255
|
+
if (result.status !== "fulfilled") {
|
|
256
|
+
console.error(testModules[i].url, result.reason);
|
|
257
|
+
i++;
|
|
258
|
+
}
|
|
248
259
|
}
|
|
249
260
|
|
|
250
|
-
ws.send(
|
|
261
|
+
ws.send(
|
|
262
|
+
JSON.stringify(decycle({ action: "result", data: testModules }), allErrorProperties)
|
|
263
|
+
);
|
|
251
264
|
|
|
252
265
|
displayTests();
|
|
253
266
|
}
|
package/src/browser-ava-cli.mjs
CHANGED
|
@@ -12,6 +12,7 @@ import { calculateSummary, summaryMessages } from "./browser/util.mjs";
|
|
|
12
12
|
import { resolveImport, utf8EncodingOptions } from "./resolver.mjs";
|
|
13
13
|
import { globby } from "globby";
|
|
14
14
|
import chalk from "chalk";
|
|
15
|
+
import { encycle } from "json-cyclic";
|
|
15
16
|
import pkg from "../package.json" with { type: "json" };
|
|
16
17
|
|
|
17
18
|
const knownBrowsers = {
|
|
@@ -106,7 +107,7 @@ program
|
|
|
106
107
|
|
|
107
108
|
wss.on("connection", ws => {
|
|
108
109
|
ws.on("message", async content => {
|
|
109
|
-
const { action, data } = JSON.parse(content);
|
|
110
|
+
const { action, data } = encycle(JSON.parse(content));
|
|
110
111
|
switch (action) {
|
|
111
112
|
case "info":
|
|
112
113
|
console.info(...data);
|
|
@@ -226,6 +227,7 @@ async function createServer(tests, options) {
|
|
|
226
227
|
app.use(Cors({ origin: "*" }));
|
|
227
228
|
|
|
228
229
|
app.use(Static(new URL("./browser", import.meta.url).pathname));
|
|
230
|
+
app.use(Static(new URL("..", import.meta.url).pathname));
|
|
229
231
|
|
|
230
232
|
app.on("error", console.error);
|
|
231
233
|
|