tape-six 1.7.2 → 1.7.4

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/bin/tape6-bun.js CHANGED
@@ -119,9 +119,10 @@ const main = async () => {
119
119
  await init();
120
120
  await selectTimer();
121
121
 
122
- process.on('uncaughtException', (error, origin) =>
123
- console.error('UNHANDLED ERROR:', origin, error)
124
- );
122
+ process.on('uncaughtException', (error, origin) => {
123
+ console.error('UNHANDLED ERROR:', origin, error);
124
+ process.exit(1);
125
+ });
125
126
 
126
127
  const reporter = getReporter(),
127
128
  worker = new TestWorker(reporter, parallel, options);
package/bin/tape6-node.js CHANGED
@@ -132,9 +132,10 @@ const main = async () => {
132
132
  await init();
133
133
  await selectTimer();
134
134
 
135
- process.on('uncaughtException', (error, origin) =>
136
- console.error('UNHANDLED ERROR:', origin, error)
137
- );
135
+ process.on('uncaughtException', (error, origin) => {
136
+ console.error('UNHANDLED ERROR:', origin, error);
137
+ process.exit(1);
138
+ });
138
139
 
139
140
  if (!files.length) {
140
141
  console.log('No files found.');
package/bin/tape6-seq.js CHANGED
@@ -104,9 +104,10 @@ const main = async () => {
104
104
 
105
105
  const console = globalThis.console;
106
106
 
107
- process.on('uncaughtException', (error, origin) =>
108
- console.error('UNHANDLED ERROR:', origin, error)
109
- );
107
+ process.on('uncaughtException', (error, origin) => {
108
+ console.error('UNHANDLED ERROR:', origin, error);
109
+ process.exit(1);
110
+ });
110
111
 
111
112
  const reporter = getReporter(),
112
113
  worker = new TestWorker(reporter, 1, {...options, testRunner});
package/index.d.ts CHANGED
@@ -66,15 +66,15 @@ export declare interface Tester {
66
66
  /**
67
67
  * A symbol that can be used to match any value.
68
68
  */
69
- any: Symbol;
69
+ any: symbol;
70
70
 
71
71
  /**
72
72
  * A symbol that can be used to match any value. An alias of `any`.
73
73
  */
74
- _: Symbol;
74
+ _: symbol;
75
75
 
76
76
  /**
77
- * A signal that can be used to abort asynchronous operations. It is triggered when the test is ended.
77
+ * A signal that can be used to abort asynchronous operations. It is triggered when the test ends.
78
78
  */
79
79
  signal: AbortSignal;
80
80
 
@@ -287,7 +287,7 @@ export declare interface Tester {
287
287
  ): Promise<void>;
288
288
 
289
289
  /**
290
- * Runs non-asynchronous callback-based test.
290
+ * Runs a callback-based test wrapped in a promise.
291
291
  * @param name - The name of the test
292
292
  * @param fn - The test function
293
293
  * @param options - The test options
@@ -299,7 +299,7 @@ export declare interface Tester {
299
299
  ): Promise<void>;
300
300
 
301
301
  /**
302
- * Runs non-asynchronous callback-based test.
302
+ * Runs a callback-based test wrapped in a promise.
303
303
  * @param name - The name of the test
304
304
  * @param options - The test options
305
305
  * @param fn - The test function
@@ -311,7 +311,7 @@ export declare interface Tester {
311
311
  ): Promise<void>;
312
312
 
313
313
  /**
314
- * Runs non-asynchronous callback-based test.
314
+ * Runs a callback-based test wrapped in a promise.
315
315
  * @param fn - The test function
316
316
  * @param options - The test options
317
317
  * @param name - The name of the test
@@ -323,7 +323,7 @@ export declare interface Tester {
323
323
  ): Promise<void>;
324
324
 
325
325
  /**
326
- * Runs non-asynchronous callback-based test.
326
+ * Runs a callback-based test wrapped in a promise.
327
327
  * @param fn - The test function
328
328
  * @param name - The name of the test
329
329
  * @param options - The test options
@@ -335,7 +335,7 @@ export declare interface Tester {
335
335
  ): Promise<void>;
336
336
 
337
337
  /**
338
- * Runs non-asynchronous callback-based test.
338
+ * Runs a callback-based test wrapped in a promise.
339
339
  * @param options - The test options
340
340
  * @param fn - The test function
341
341
  * @param name - The name of the test
@@ -347,7 +347,7 @@ export declare interface Tester {
347
347
  ): Promise<void>;
348
348
 
349
349
  /**
350
- * Runs non-asynchronous callback-based test.
350
+ * Runs a callback-based test wrapped in a promise.
351
351
  * @param options - The test options
352
352
  * @param name - The name of the test
353
353
  * @param fn - The test function
@@ -425,8 +425,8 @@ export declare interface Tester {
425
425
  notOk(value: unknown, message?: string): void;
426
426
 
427
427
  /**
428
- * Asserts that `error` is an error and fails the test.
429
- * @param error - The error to test
428
+ * Asserts that `error` is falsy. If the value is truthy (e.g. an Error object), the assertion fails.
429
+ * @param error - The value to test
430
430
  * @param message - Optional message to display if the assertion fails
431
431
  */
432
432
  error(error: Error | null | unknown, message?: string): void;
@@ -600,22 +600,22 @@ export declare interface Tester {
600
600
  notok(value: unknown, message?: string): void;
601
601
 
602
602
  /**
603
- * Asserts that `error` is an error and fails the test. Alias of `error`.
604
- * @param error - The error to test
603
+ * Asserts that `error` is falsy. If the value is truthy (e.g. an Error object), the assertion fails. Alias of `error`.
604
+ * @param error - The value to test
605
605
  * @param message - Optional message to display if the assertion fails
606
606
  */
607
607
  ifError(error: Error | null | unknown, message?: string): void;
608
608
 
609
609
  /**
610
- * Asserts that `error` is an error and fails the test. Alias of `error`.
611
- * @param error - The error to test
610
+ * Asserts that `error` is falsy. If the value is truthy (e.g. an Error object), the assertion fails. Alias of `error`.
611
+ * @param error - The value to test
612
612
  * @param message - Optional message to display if the assertion fails
613
613
  */
614
614
  ifErr(error: Error | null | unknown, message?: string): void;
615
615
 
616
616
  /**
617
- * Asserts that `error` is an error and fails the test. Alias of `error`.
618
- * @param error - The error to test
617
+ * Asserts that `error` is falsy. If the value is truthy (e.g. an Error object), the assertion fails. Alias of `error`.
618
+ * @param error - The value to test
619
619
  * @param message - Optional message to display if the assertion fails
620
620
  */
621
621
  iferror(error: Error | null | unknown, message?: string): void;
@@ -1122,57 +1122,64 @@ export declare interface Test {
1122
1122
  }
1123
1123
 
1124
1124
  /**
1125
- * The main function, which is used to define tests. Many other functions are defined as properties of this function.
1125
+ * The main function used to define tests. When called inside a test body, it delegates to the current tester.
1126
+ * Many other functions are defined as properties of this function.
1126
1127
  */
1127
1128
  export declare const test: Test;
1128
1129
 
1129
1130
  /**
1130
- * An alias for `test`. Used for compatibility with other testing frameworks to define test suites.
1131
+ * An alias for `test`. When called inside a test body, it delegates to the current tester.
1131
1132
  */
1132
1133
  export declare const suite = test;
1133
1134
 
1134
1135
  /**
1135
- * An alias for `test`. Used for compatibility with other testing frameworks to define test suites.
1136
+ * An alias for `test`. When called inside a test body, it delegates to the current tester.
1136
1137
  */
1137
1138
  export declare const describe = test;
1138
1139
 
1139
1140
  /**
1140
- * An alias for `test`. Used for compatibility with other testing frameworks to define tests.
1141
+ * An alias for `test`. When called inside a test body, it delegates to the current tester.
1141
1142
  */
1142
1143
  export declare const it = test;
1143
1144
 
1144
1145
  /**
1145
1146
  * Registers a function that will be called before all 1st-level embedded tests in the current scope.
1147
+ * When called inside a test body, delegates to the current tester.
1146
1148
  * @param fn a hook function
1147
1149
  */
1148
1150
  export declare const beforeAll: typeof test.beforeAll;
1149
1151
 
1150
1152
  /**
1151
1153
  * Registers a function that will be called after all 1st-level embedded tests in the current scope.
1154
+ * When called inside a test body, delegates to the current tester.
1152
1155
  * @param fn a hook function
1153
1156
  */
1154
1157
  export declare const afterAll: typeof test.afterAll;
1155
1158
 
1156
1159
  /**
1157
1160
  * Registers a function that will be called before each 1st-level embedded test in the current scope.
1161
+ * When called inside a test body, delegates to the current tester.
1158
1162
  * @param fn a hook function
1159
1163
  */
1160
1164
  export declare const beforeEach: typeof test.beforeEach;
1161
1165
 
1162
1166
  /**
1163
1167
  * Registers a function that will be called after each 1st-level embedded test in the current scope.
1168
+ * When called inside a test body, delegates to the current tester.
1164
1169
  * @param fn a hook function
1165
1170
  */
1166
1171
  export declare const afterEach: typeof test.afterEach;
1167
1172
 
1168
1173
  /**
1169
1174
  * Registers a function that will be called before all 1st-level embedded tests in the current scope. An alias for `beforeAll()`.
1175
+ * When called inside a test body, delegates to the current tester.
1170
1176
  * @param fn a hook function
1171
1177
  */
1172
1178
  export declare const before: typeof test.before;
1173
1179
 
1174
1180
  /**
1175
1181
  * Registers a function that will be called after all 1st-level embedded tests in the current scope. An alias for `afterAll()`.
1182
+ * When called inside a test body, delegates to the current tester.
1176
1183
  * @param fn a hook function
1177
1184
  */
1178
1185
  export declare const after: typeof test.after;
package/llms-full.txt CHANGED
@@ -9,6 +9,7 @@
9
9
  - Browser testing with built-in web UI and automation support (Puppeteer, Playwright)
10
10
  - Before/after hooks: `beforeAll`, `afterAll`, `beforeEach`, `afterEach`
11
11
  - `test()` is aliased as `suite()`, `describe()`, and `it()` for easy migration
12
+ - When called inside a test body, top-level functions auto-delegate to the current tester
12
13
  - Compatible with `AssertionError`-based libraries like `node:assert` and `chai`
13
14
 
14
15
  ## Quick start
@@ -128,6 +129,20 @@ test('top', async t => {
128
129
 
129
130
  Always `await` embedded tests to preserve execution order.
130
131
 
132
+ Top-level `test()`/`it()`/`describe()` auto-delegate when called inside a test body, so these are equivalent:
133
+
134
+ ```js
135
+ import {describe, it, before, beforeEach} from 'tape-six';
136
+
137
+ describe('module', () => {
138
+ before(() => { /* setup */ });
139
+ beforeEach(() => { /* per-test setup */ });
140
+
141
+ it('works', t => { t.ok(true); });
142
+ it('also works', t => { t.equal(1, 1); });
143
+ });
144
+ ```
145
+
131
146
  ## Tester API
132
147
 
133
148
  The `Tester` object is passed to test functions. All `msg` arguments are optional.
@@ -163,17 +178,17 @@ The `Tester` object is passed to test functions. All `msg` arguments are optiona
163
178
 
164
179
  ### Embedded test methods
165
180
 
166
- - `test(name, options, testFn)` — nested test suite (async, await it).
181
+ - `test(name, options, testFn)` — nested test suite (async, await it). Top-level `test()`/`it()` also works.
167
182
  - `skip(name, options, testFn)` — skip nested suite.
168
183
  - `todo(name, options, testFn)` — TODO nested suite.
169
184
  - `asPromise(name, options, testPromiseFn)` — callback-style nested suite.
170
185
 
171
186
  ### Hooks
172
187
 
173
- - `beforeAll(fn)` / `before(fn)` — run before first nested test.
174
- - `afterAll(fn)` / `after(fn)` — run after last nested test.
175
- - `beforeEach(fn)` — run before each nested test.
176
- - `afterEach(fn)` — run after each nested test.
188
+ - `beforeAll(fn)` / `before(fn)` — run before first nested test. Top-level `beforeAll()`/`before()` also works.
189
+ - `afterAll(fn)` / `after(fn)` — run after last nested test. Top-level `afterAll()`/`after()` also works.
190
+ - `beforeEach(fn)` — run before each nested test. Top-level `beforeEach()` also works.
191
+ - `afterEach(fn)` — run after each nested test. Top-level `afterEach()` also works.
177
192
 
178
193
  ### Miscellaneous
179
194
 
@@ -211,12 +226,16 @@ beforeEach(() => { /* runs before each top-level test */ });
211
226
  afterEach(() => { /* runs after each top-level test */ });
212
227
  ```
213
228
 
214
- Nested hooks (via tester object):
229
+ Nested hooks (top-level functions auto-delegate to current tester):
215
230
 
216
231
  ```js
232
+ import {test, beforeEach, afterEach} from 'tape-six';
233
+
217
234
  test('suite', async t => {
218
- t.beforeEach(() => { /* before each nested test */ });
219
- t.afterEach(() => { /* after each nested test */ });
235
+ beforeEach(() => { /* before each nested test */ });
236
+ afterEach(() => { /* after each nested test */ });
237
+
238
+ // equivalent: t.beforeEach(), t.afterEach()
220
239
 
221
240
  await t.test('test 1', t => t.pass());
222
241
  await t.test('test 2', t => t.pass());
@@ -323,6 +342,7 @@ Browser: `http://localhost:3000/?flags=FO`
323
342
  - `TAPE6_PAR` — number of parallel workers.
324
343
  - `TAPE6_TAP` — force TAP reporter (any non-empty value).
325
344
  - `TAPE6_JSONL` — force JSONL reporter (any non-empty value).
345
+ - `TAPE6_MIN` — force minimal reporter (any non-empty value).
326
346
  - `TAPE6_TEST_FILE_NAME` — set by runners to identify the current test file.
327
347
 
328
348
  ## Browser testing
package/llms.txt CHANGED
@@ -33,6 +33,7 @@ Registers a test. All three arguments are optional and can be in any order (reco
33
33
  Returns a promise that resolves when the test finishes. Usually no need to await.
34
34
 
35
35
  Aliases: `suite`, `describe`, `it` — all are the same function.
36
+ When called inside a test body, these (and all hook functions) automatically delegate to the current tester — no need to use `t.test()` or `t.before()` explicitly.
36
37
 
37
38
  ```js
38
39
  import {test, describe, it, suite} from 'tape-six';
@@ -97,7 +98,7 @@ The object passed to test functions. Provides assertions and test control.
97
98
 
98
99
  #### Embedded tests (all async, should be awaited)
99
100
 
100
- - `await t.test(name, options, testFn)` — nested test.
101
+ - `await t.test(name, options, testFn)` — nested test. Top-level `test()`/`it()` also works (auto-delegates).
101
102
  - `await t.skip(name, options, testFn)` — nested skipped test.
102
103
  - `await t.todo(name, options, testFn)` — nested TODO test.
103
104
  - `await t.asPromise(name, options, testPromiseFn)` — nested callback-style test.
@@ -122,12 +123,14 @@ afterAll(() => { /* runs once after all tests */ });
122
123
  beforeEach(() => { /* runs before each test */ });
123
124
  afterEach(() => { /* runs after each test */ });
124
125
 
125
- // Or inside a test:
126
+ // Inside a test — top-level functions auto-delegate to current tester:
126
127
  test('suite', async t => {
127
- t.beforeAll(() => { /* before embedded tests */ });
128
- t.afterAll(() => { /* after embedded tests */ });
129
- t.beforeEach(() => { /* before each embedded test */ });
130
- t.afterEach(() => { /* after each embedded test */ });
128
+ beforeAll(() => { /* before embedded tests */ });
129
+ afterAll(() => { /* after embedded tests */ });
130
+ beforeEach(() => { /* before each embedded test */ });
131
+ afterEach(() => { /* after each embedded test */ });
132
+
133
+ // equivalent: t.beforeAll(), t.afterAll(), t.beforeEach(), t.afterEach()
131
134
 
132
135
  await t.test('inner', t => { t.pass(); });
133
136
  });
@@ -198,9 +201,12 @@ test('partial match', t => {
198
201
  ### Using describe/it style
199
202
 
200
203
  ```js
201
- import {describe, it} from 'tape-six';
204
+ import {describe, it, before, beforeEach} from 'tape-six';
202
205
 
203
206
  describe('my module', () => {
207
+ before(() => { /* setup — auto-delegates to current tester */ });
208
+ beforeEach(() => { /* per-test setup */ });
209
+
204
210
  it('should work', t => {
205
211
  t.ok(true);
206
212
  });
@@ -223,6 +229,15 @@ npx tape6-seq # run sequentially (no worker threads)
223
229
  npx tape6-server --trace # start browser test server
224
230
  ```
225
231
 
232
+ ## Environment variables
233
+
234
+ - `TAPE6_FLAGS` — flags string.
235
+ - `TAPE6_PAR` — number of parallel workers.
236
+ - `TAPE6_TAP` — force TAP reporter (any non-empty value).
237
+ - `TAPE6_JSONL` — force JSONL reporter (any non-empty value).
238
+ - `TAPE6_MIN` — force minimal reporter (any non-empty value).
239
+ - `TAPE6_TEST_FILE_NAME` — set by runners to identify the current test file.
240
+
226
241
  ## Configuration (package.json)
227
242
 
228
243
  ```json
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tape-six",
3
- "version": "1.7.2",
3
+ "version": "1.7.4",
4
4
  "description": "TAP-based unit test library for Node, Deno, Bun, and browsers. ES modules, TypeScript, zero dependencies.",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -61,7 +61,8 @@
61
61
  "bun",
62
62
  "nodejs",
63
63
  "tap-protocol",
64
- "cross-runtime"
64
+ "cross-runtime",
65
+ "zero-dependency"
65
66
  ],
66
67
  "author": "Eugene Lazutkin <eugene.lazutkin@gmail.com> (https://www.lazutkin.com/)",
67
68
  "funding": "https://github.com/sponsors/uhop",
@@ -78,7 +79,9 @@
78
79
  "web-app",
79
80
  "src",
80
81
  "llms.txt",
81
- "llms-full.txt"
82
+ "llms-full.txt",
83
+ "TESTING.md",
84
+ "workflows"
82
85
  ],
83
86
  "tape6": {
84
87
  "tests": [
@@ -101,7 +104,7 @@
101
104
  },
102
105
  "devDependencies": {
103
106
  "@types/chai": "^5.2.3",
104
- "@types/node": "^25.3.0",
107
+ "@types/node": "^25.3.1",
105
108
  "chai": "^6.2.2",
106
109
  "playwright": "^1.58.2",
107
110
  "puppeteer": "^24.37.5",
package/src/State.js CHANGED
@@ -246,10 +246,10 @@ export class State {
246
246
  return event;
247
247
  }
248
248
 
249
- postprocess(event) {
249
+ postprocess(event, suppressStopTest = false) {
250
250
  switch (event.type) {
251
251
  case 'assert':
252
- if (event.stopTest && event.operator !== 'exception') {
252
+ if (!suppressStopTest && event.stopTest && event.operator !== 'exception') {
253
253
  const stopTest = new StopTest('failOnce is activated');
254
254
  stopTest[signature] = signature;
255
255
  throw stopTest;
@@ -257,6 +257,7 @@ export class State {
257
257
  this.time = this.timer.now();
258
258
  break;
259
259
  case 'bail-out':
260
+ if (suppressStopTest) return;
260
261
  const stopTest = new StopTest('bailOut is activated');
261
262
  stopTest[signature] = signature;
262
263
  throw stopTest;
package/src/Tester.js CHANGED
@@ -236,7 +236,7 @@ export class Tester {
236
236
 
237
237
  deepLooseEqual(a, b, msg) {
238
238
  this.reporter.report({
239
- name: msg || 'should be loosely equal',
239
+ name: msg || 'should be deeply loosely equal',
240
240
  test: this.testNumber,
241
241
  marker: new Error(),
242
242
  time: this.timer.now(),
@@ -251,7 +251,7 @@ export class Tester {
251
251
 
252
252
  notDeepLooseEqual(a, b, msg) {
253
253
  this.reporter.report({
254
- name: msg || 'should not be loosely equal',
254
+ name: msg || 'should not be deeply loosely equal',
255
255
  test: this.testNumber,
256
256
  marker: new Error(),
257
257
  time: this.timer.now(),
@@ -21,7 +21,7 @@ export class JSONLReporter extends Reporter {
21
21
  prefix ||= getEnvVar('TAPE6_JSONL_PREFIX') || '';
22
22
  this.prefix = prefix ? '\n' + prefix : '';
23
23
  }
24
- report(event) {
24
+ report(event, suppressStopTest = false) {
25
25
  event = this.state?.preprocess(event) || event;
26
26
  if (event.type === 'assert' && this.renumberAsserts) {
27
27
  event = {...event, id: ++this.assertCounter};
@@ -39,7 +39,7 @@ export class JSONLReporter extends Reporter {
39
39
  }
40
40
  const jsonEvent = JSON.stringify(event);
41
41
  this.console.log(this.prefix ? this.prefix + jsonEvent : jsonEvent);
42
- this.state?.postprocess(event);
42
+ this.state?.postprocess(event, suppressStopTest);
43
43
  }
44
44
  }
45
45
 
@@ -1,22 +1,11 @@
1
1
  import Reporter from './Reporter.js';
2
2
 
3
- const getEnvVar = name => {
4
- if (typeof Deno == 'object' && Deno?.version) {
5
- return Deno.env.get(name);
6
- } else if (typeof Bun == 'object' && Bun?.version) {
7
- return Bun.env[name];
8
- } else if (typeof process == 'object' && process?.versions?.node) {
9
- return process.env[name];
10
- }
11
- return undefined;
12
- };
13
-
14
3
  export class MinReporter extends Reporter {
15
4
  constructor({failOnce = false, originalConsole} = {}) {
16
5
  super({failOnce});
17
6
  this.console = originalConsole || console;
18
7
  }
19
- report(event) {
8
+ report(event, suppressStopTest = false) {
20
9
  event = this.state?.preprocess(event) || event;
21
10
  const handler = Reporter.EVENT_MAP[event.type];
22
11
  typeof handler == 'string' && this[handler]?.(event);
@@ -30,7 +19,7 @@ export class MinReporter extends Reporter {
30
19
  'Fail:',
31
20
  event.fail
32
21
  );
33
- this.state?.postprocess(event);
22
+ this.state?.postprocess(event, suppressStopTest);
34
23
  }
35
24
  }
36
25
 
@@ -5,7 +5,7 @@ export class ProxyReporter extends Reporter {
5
5
  super({failOnce});
6
6
  this.reportTo = reportTo;
7
7
  }
8
- report(event) {
8
+ report(event, suppressStopTest = false) {
9
9
  event = this.state?.preprocess(event) || event;
10
10
  switch (event.type) {
11
11
  case 'test':
@@ -19,7 +19,7 @@ export class ProxyReporter extends Reporter {
19
19
  break;
20
20
  }
21
21
  this.reportTo(event);
22
- this.state?.postprocess(event);
22
+ this.state?.postprocess(event, suppressStopTest);
23
23
  }
24
24
  }
25
25
 
@@ -57,13 +57,13 @@ export class Reporter {
57
57
  }
58
58
  }
59
59
 
60
- report(event) {
60
+ report(event, suppressStopTest = false) {
61
61
  event = this.state?.preprocess(event) || event;
62
62
 
63
63
  const handler = this.constructor.EVENT_MAP[event.type];
64
64
  typeof handler == 'string' && this[handler]?.(event);
65
65
 
66
- this.state?.postprocess(event);
66
+ this.state?.postprocess(event, suppressStopTest);
67
67
  }
68
68
 
69
69
  static EVENT_MAP = {
@@ -76,7 +76,7 @@ export class Reporter {
76
76
  console: 'onConsole',
77
77
  stdout: 'onStdout',
78
78
  stderr: 'onStderr',
79
- bailOut: 'onBailOut'
79
+ 'bail-out': 'onBailOut'
80
80
  };
81
81
  }
82
82
 
@@ -148,15 +148,15 @@ export class TTYReporter extends Reporter {
148
148
  ++this.lines;
149
149
  return this;
150
150
  }
151
- report(event) {
151
+ report(event, suppressStopTest = false) {
152
152
  this.consoleSkipChecks = true;
153
153
  try {
154
- this.reportInternal(event);
154
+ this.reportInternal(event, suppressStopTest);
155
155
  } finally {
156
156
  this.consoleSkipChecks = false;
157
157
  }
158
158
  }
159
- reportInternal(event) {
159
+ reportInternal(event, suppressStopTest = false) {
160
160
  if (this.output.isTTY) {
161
161
  if (!this.consoleWasUsed && this.overrideLastLine) {
162
162
  this.output.moveCursor(0, -1);
@@ -320,7 +320,7 @@ export class TTYReporter extends Reporter {
320
320
  this.showScore();
321
321
  this.overrideLastLine = true;
322
322
  }
323
- this.state?.postprocess(event);
323
+ this.state?.postprocess(event, suppressStopTest);
324
324
  }
325
325
  showScore() {
326
326
  this.out(
@@ -61,7 +61,7 @@ export class TapReporter extends Reporter {
61
61
  this.opened = true;
62
62
  }
63
63
  }
64
- report(event) {
64
+ report(event, suppressStopTest = false) {
65
65
  event = this.state?.preprocess(event) || event;
66
66
  let text;
67
67
  switch (event.type) {
@@ -192,6 +192,7 @@ export class TapReporter extends Reporter {
192
192
  }
193
193
  break;
194
194
  }
195
+ this.state?.postprocess(event, suppressStopTest);
195
196
  }
196
197
  showSummary(state, diffTime) {
197
198
  const success = state.asserts - state.failed - state.skipped;
@@ -1,6 +1,5 @@
1
1
  import {sep} from 'node:path';
2
2
 
3
- import {isStopTest} from '../../State.js';
4
3
  import EventServer from '../../utils/EventServer.js';
5
4
 
6
5
  const srcName = new URL('../../', import.meta.url),
@@ -21,11 +20,7 @@ export default class TestWorker extends EventServer {
21
20
  this.idToWorker[id] = worker;
22
21
  worker.addEventListener('message', event => {
23
22
  const msg = event.data;
24
- try {
25
- this.report(id, msg);
26
- } catch (error) {
27
- if (!isStopTest(error)) throw error;
28
- }
23
+ this.report(id, msg);
29
24
  if (msg.type === 'end' && msg.test === 0) {
30
25
  this.close(id);
31
26
  }
@@ -36,20 +31,16 @@ export default class TestWorker extends EventServer {
36
31
  name: 'fail to load: ' + (error.message || 'Worker error'),
37
32
  test: 0
38
33
  });
39
- try {
40
- this.report(id, {
41
- name: String(error),
42
- test: 0,
43
- marker: new Error(),
44
- operator: 'error',
45
- fail: true,
46
- data: {
47
- actual: error
48
- }
49
- });
50
- } catch (error) {
51
- if (!isStopTest(error)) throw error;
52
- }
34
+ this.report(id, {
35
+ name: String(error),
36
+ test: 0,
37
+ marker: new Error(),
38
+ operator: 'error',
39
+ fail: true,
40
+ data: {
41
+ actual: error
42
+ }
43
+ });
53
44
  this.close(id);
54
45
  });
55
46
  worker.addEventListener('messageerror', error => {
@@ -58,20 +49,16 @@ export default class TestWorker extends EventServer {
58
49
  name: 'fail to load: ' + (error.message || 'Worker error'),
59
50
  test: 0
60
51
  });
61
- try {
62
- this.report(id, {
63
- name: String(error),
64
- test: 0,
65
- marker: new Error(),
66
- operator: 'error',
67
- fail: true,
68
- data: {
69
- actual: error
70
- }
71
- });
72
- } catch (error) {
73
- if (!isStopTest(error)) throw error;
74
- }
52
+ this.report(id, {
53
+ name: String(error),
54
+ test: 0,
55
+ marker: new Error(),
56
+ operator: 'error',
57
+ fail: true,
58
+ data: {
59
+ actual: error
60
+ }
61
+ });
75
62
  this.close(id);
76
63
  });
77
64
  worker.postMessage({