browser-ava 2.2.10 → 2.2.12

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.10",
3
+ "version": "2.2.12",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
@@ -38,16 +38,16 @@
38
38
  "@koa/cors": "^5.0.0",
39
39
  "chalk": "^5.3.0",
40
40
  "commander": "^12.0.0",
41
- "es-module-lexer": "^1.5.0",
41
+ "es-module-lexer": "^1.5.2",
42
42
  "globby": "^14.0.1",
43
43
  "koa": "^2.15.3",
44
44
  "koa-static": "^5.0.0",
45
45
  "playwright": "^1.43.1",
46
- "ws": "^8.16.0"
46
+ "ws": "^8.17.0"
47
47
  },
48
48
  "devDependencies": {
49
- "@types/node": "^20.12.7",
50
- "ava": "^6.1.2",
49
+ "@types/node": "^20.12.8",
50
+ "ava": "^6.1.3",
51
51
  "c8": "^9.1.0",
52
52
  "documentation": "^14.0.3",
53
53
  "execa": "^8.0.1",
@@ -6,7 +6,7 @@ export const testModules = [];
6
6
  /**
7
7
  * Collect all tests into testModules
8
8
  */
9
- export default function test(body, ...args) {
9
+ export function test(body, ...args) {
10
10
  let title;
11
11
  if (typeof body === "string") {
12
12
  title = body;
@@ -22,6 +22,10 @@ export default function test(body, ...args) {
22
22
  return def;
23
23
  }
24
24
 
25
+ export default test;
26
+
27
+ test.meta = {};
28
+
25
29
  test.failing = (...args) => {
26
30
  test(...args).failing = true;
27
31
  };
@@ -1,4 +1,4 @@
1
- import { testModules } from "./ava.mjs";
1
+ import { testModules, test } from "./ava.mjs";
2
2
  import {
3
3
  calculateSummary,
4
4
  summaryMessages,
@@ -10,8 +10,12 @@ import { isEqual } from "./eql.mjs";
10
10
  let ws = new WebSocket(`ws://${location.host}`);
11
11
  ws.onerror = console.error;
12
12
 
13
- BigInt.prototype.toJSON = function() { return this.toString() };
14
- Error.prototype.toJSON = function() { return this.toString() };
13
+ BigInt.prototype.toJSON = function () {
14
+ return this.toString();
15
+ };
16
+ Error.prototype.toJSON = function () {
17
+ return this.toString();
18
+ };
15
19
 
16
20
  /*
17
21
  forward console info,log,error to the server
@@ -136,9 +140,11 @@ async function execHooks(hooks, t) {
136
140
  }
137
141
  }
138
142
 
139
- async function runTest(parent, tm, test) {
140
- if (!test.skip && !test.todo) {
141
- const t = testContext(test, parent);
143
+ async function runTest(parent, tm, testInstance) {
144
+ test.meta.file = tm.file;
145
+
146
+ if (!testInstance.skip && !testInstance.todo) {
147
+ const t = testContext(testInstance, parent);
142
148
 
143
149
  try {
144
150
  await execHooks(tm.beforeEach, t);
@@ -150,7 +156,7 @@ async function runTest(parent, tm, test) {
150
156
  }, t.ms);
151
157
  }
152
158
 
153
- await test.body(t, ...test.args);
159
+ await testInstance.body(t, ...testInstance.args);
154
160
 
155
161
  if (t.timer) {
156
162
  clearTimeout(t.timer);
@@ -163,24 +169,27 @@ async function runTest(parent, tm, test) {
163
169
 
164
170
  await execHooks(tm.afterEach, t);
165
171
 
166
- if (test.assertions.length === 0) {
167
- test.passed = false;
168
- test.message = "Test finished without running any assertions";
172
+ if (testInstance.assertions.length === 0) {
173
+ testInstance.passed = false;
174
+ testInstance.message = "Test finished without running any assertions";
169
175
  } else {
170
- test.passed = !test.assertions.find(
176
+ testInstance.passed = !testInstance.assertions.find(
171
177
  a => a.passed !== true && !a.skipped
172
178
  );
173
179
 
174
- if (t.planned !== undefined && t.planned !== test.assertions.length) {
175
- test.passed = false;
176
- test.message = `Planned for ${t.planned} assertions, but got ${test.assertions.length}`;
180
+ if (
181
+ t.planned !== undefined &&
182
+ t.planned !== testInstance.assertions.length
183
+ ) {
184
+ testInstance.passed = false;
185
+ testInstance.message = `Planned for ${t.planned} assertions, but got ${testInstance.assertions.length}`;
177
186
  }
178
187
  }
179
188
  } catch (e) {
180
- test.passed = false;
181
- test.message = e;
189
+ testInstance.passed = false;
190
+ testInstance.message = e;
182
191
  } finally {
183
- ws.send(JSON.stringify({ action: "update", data: test }));
192
+ ws.send(JSON.stringify({ action: "update", data: testInstance }));
184
193
  }
185
194
  }
186
195
  }
@@ -354,6 +363,13 @@ function testContext(def, parentContext) {
354
363
  title
355
364
  });
356
365
  },
366
+ like(a, b, title) {
367
+ def.assertions.push({
368
+ passed: isEqual(a, b), // todo
369
+ message: `${a} != ${b}`,
370
+ title
371
+ });
372
+ },
357
373
 
358
374
  regex(contents, regex, message) {
359
375
  def.assertions.push({