browser-ava 2.2.36 → 2.3.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-ava",
3
- "version": "2.2.36",
3
+ "version": "2.3.1",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -46,7 +46,7 @@
46
46
  "ws": "^8.18.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@types/node": "^22.8.4",
49
+ "@types/node": "^22.8.7",
50
50
  "ava": "^6.2.0",
51
51
  "c8": "^10.1.2",
52
52
  "documentation": "^14.0.3",
@@ -5,29 +5,39 @@ import {
5
5
  pluralize,
6
6
  moduleName
7
7
  } from "./util.mjs";
8
- import { isEqual } from "./eql.mjs";
8
+ import { isEqual } from "./assertions.mjs";
9
9
 
10
10
  let ws = new WebSocket(`ws://${location.host}`);
11
11
  ws.onerror = console.error;
12
12
 
13
- BigInt.prototype.toJSON = function () {
13
+ function primitiveRoString() {
14
14
  return this.toString();
15
- };
16
- Error.prototype.toJSON = function () {
17
- return this.toString();
18
- };
15
+ }
16
+ BigInt.prototype.toJSON = primitiveRoString;
17
+ Error.prototype.toJSON = primitiveRoString;
18
+
19
+ function allErrorProperties(key, value) {
20
+ if (value instanceof Error) {
21
+ const error = {};
22
+ Object.
23
+ getOwnPropertyNames(value).
24
+ forEach((key) => error[key] = value[key]);
25
+ return error;
26
+ }
27
+ return value;
28
+ }
19
29
 
20
30
  /*
21
31
  forward console info,log,error to the server
22
32
  */
23
- for (const slot of ["log", "info", "error"]) {
24
- const former = console[slot];
33
+ for (const action of ["log", "info", "error"]) {
34
+ const former = console[action];
25
35
 
26
- console[slot] = (...args) => {
36
+ console[action] = (...data) => {
27
37
  if (ws) {
28
- ws.send(JSON.stringify({ action: slot, data: args }));
38
+ ws.send(JSON.stringify({ action, data }, allErrorProperties));
29
39
  }
30
- former(...args);
40
+ former(...data);
31
41
  };
32
42
  }
33
43
 
@@ -86,7 +96,7 @@ async function displayTests() {
86
96
  .map(a => (a.title || "") + " " + (a.message || ""))
87
97
  .join(" ")
88
98
  : ""
89
- }</span>${t.message ? t.message : ""}</li>`;
99
+ }</span>${t.message ? t.message : ""}${t.stack ? "<br>" + t.stack : ""}</li>`;
90
100
  }
91
101
 
92
102
  function renderModule(tm) {
@@ -188,8 +198,9 @@ async function runTest(parent, tm, testInstance) {
188
198
  } catch (e) {
189
199
  testInstance.passed = false;
190
200
  testInstance.message = e;
201
+ testInstance.stack = e.stack;
191
202
  } finally {
192
- ws.send(JSON.stringify({ action: "update", data: testInstance }));
203
+ ws.send(JSON.stringify({ action: "update", data: testInstance }, allErrorProperties));
193
204
  }
194
205
  }
195
206
  }
@@ -231,7 +242,7 @@ async function runTestModule(tm) {
231
242
  async function runTestModules() {
232
243
  await Promise.all(testModules.map(tm => runTestModule(tm)));
233
244
 
234
- ws.send(JSON.stringify({ action: "result", data: testModules }));
245
+ ws.send(JSON.stringify({ action: "result", data: testModules }, allErrorProperties));
235
246
 
236
247
  displayTests();
237
248
  }
@@ -134,6 +134,12 @@ program
134
134
  console.log(" ", chalk.green("✔"), data.title);
135
135
  } else {
136
136
  console.log(" ", chalk.red("✘ [fail]: "), data.title);
137
+ if(data.message) {
138
+ console.log(" ", data.message);
139
+ if(data.stack) {
140
+ console.log(" ", data.stack);
141
+ }
142
+ }
137
143
  }
138
144
  }
139
145
  }
File without changes