browser-ava 2.2.11 → 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 +1 -1
- package/src/browser/ava.mjs +5 -1
- package/src/browser/runtime.mjs +26 -17
package/package.json
CHANGED
package/src/browser/ava.mjs
CHANGED
|
@@ -6,7 +6,7 @@ export const testModules = [];
|
|
|
6
6
|
/**
|
|
7
7
|
* Collect all tests into testModules
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
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
|
};
|
package/src/browser/runtime.mjs
CHANGED
|
@@ -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() {
|
|
14
|
-
|
|
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,
|
|
140
|
-
|
|
141
|
-
|
|
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
|
|
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 (
|
|
167
|
-
|
|
168
|
-
|
|
172
|
+
if (testInstance.assertions.length === 0) {
|
|
173
|
+
testInstance.passed = false;
|
|
174
|
+
testInstance.message = "Test finished without running any assertions";
|
|
169
175
|
} else {
|
|
170
|
-
|
|
176
|
+
testInstance.passed = !testInstance.assertions.find(
|
|
171
177
|
a => a.passed !== true && !a.skipped
|
|
172
178
|
);
|
|
173
179
|
|
|
174
|
-
if (
|
|
175
|
-
|
|
176
|
-
|
|
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
|
-
|
|
181
|
-
|
|
189
|
+
testInstance.passed = false;
|
|
190
|
+
testInstance.message = e;
|
|
182
191
|
} finally {
|
|
183
|
-
ws.send(JSON.stringify({ action: "update", data:
|
|
192
|
+
ws.send(JSON.stringify({ action: "update", data: testInstance }));
|
|
184
193
|
}
|
|
185
194
|
}
|
|
186
195
|
}
|