@logtape/testing-bun 2.3.0-dev.0 → 2.3.0-dev.840

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/README.md CHANGED
@@ -35,11 +35,11 @@ import { test } from "@logtape/testing-bun/autoload";
35
35
  import { getLogger } from "@logtape/logtape";
36
36
 
37
37
  test("case", () => {
38
- getLogger(["my-lib"]).debug("Fixture state: {state}.", {
38
+ getLogger(["my-lib"]).info("Fixture state: {state}.", {
39
39
  state: "ready",
40
40
  });
41
41
 
42
- // Logs emitted here are printed only if this callback fails.
42
+ // The info log is printed only if this callback fails.
43
43
  });
44
44
  ~~~~
45
45
 
@@ -49,6 +49,10 @@ when LogTape has not been configured yet. If your suite already configures
49
49
  LogTape, that configuration must include `contextLocalStorage`; otherwise, use
50
50
  `@logtape/testing-bun` and manage setup explicitly.
51
51
 
52
+ Set `LOGTAPE_TEST_MODE` to `on-failure`, `always`, or `never`, and
53
+ `LOGTAPE_TEST_LOWEST_LEVEL` to a LogTape level such as `debug` or `info` to
54
+ configure the default reporter used by the autoload `test` and `it` exports.
55
+
52
56
  Use `createTest()` when a suite needs custom reporter options:
53
57
 
54
58
  ~~~~ typescript
@@ -62,11 +66,12 @@ const test = createTest({
62
66
 
63
67
  The package preserves Bun test options and shorthand helpers such as
64
68
  `test.skip()`, `test.todo()`, `test.only()`, `test.if()`, `test.failing()`,
65
- `test.concurrent()`, `test.serial()`, and `test.each()`. It also exports a
66
- wrapped `it()` alias and `createIt()`. Other `bun:test` helpers, including
67
- `describe()`, `beforeAll()`, `afterAll()`, `beforeEach()`, `afterEach()`,
68
- `expect`, `expectTypeOf`, `mock()`, `spyOn()`, `jest`, `vi`, `xdescribe()`,
69
- `xit()`, and `xtest()`, are re-exported unchanged.
69
+ `test.concurrent()`, `test.serial()`, and `test.each()` when Bun exposes them
70
+ in the current environment. It also exports a wrapped `it()` alias and
71
+ `createIt()`. Other `bun:test` helpers, including `describe()`,
72
+ `beforeAll()`, `afterAll()`, `beforeEach()`, `afterEach()`, `expect`,
73
+ `expectTypeOf`, `mock()`, `spyOn()`, `jest`, `vi`, `xdescribe()`, `xit()`, and
74
+ `xtest()`, are re-exported unchanged.
70
75
 
71
76
 
72
77
  Docs
package/dist/autoload.cjs CHANGED
@@ -24,8 +24,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  //#endregion
25
25
  const node_async_hooks = __toESM(require("node:async_hooks"));
26
26
  const __logtape_logtape = __toESM(require("@logtape/logtape"));
27
- const bun_test = __toESM(require("bun:test"));
28
27
  const __logtape_testing_reporter = __toESM(require("@logtape/testing/reporter"));
28
+ const bun_test = __toESM(require("bun:test"));
29
29
 
30
30
  //#region src/mod.ts
31
31
  const helperNames = [
@@ -81,57 +81,56 @@ function createIt(options = {}) {
81
81
  *
82
82
  * @since 2.3.0
83
83
  */
84
- const test = createTest();
84
+ const test$1 = createTest();
85
85
  /**
86
86
  * A `bun:test` `it()` alias that reports LogTape records from failed test
87
87
  * callbacks using the default reporter options.
88
88
  *
89
89
  * @since 2.3.0
90
90
  */
91
- const it = createIt();
91
+ const it$1 = createIt();
92
92
  /**
93
93
  * Shorthand for skipping a test.
94
94
  *
95
95
  * @since 2.3.0
96
96
  */
97
- const skip = test.skip;
97
+ const skip$1 = test$1.skip;
98
98
  /**
99
99
  * Shorthand for marking a test as TODO.
100
100
  *
101
101
  * @since 2.3.0
102
102
  */
103
- const todo = test.todo;
103
+ const todo$1 = test$1.todo;
104
104
  /**
105
105
  * Shorthand for marking a test as `only`.
106
106
  *
107
107
  * @since 2.3.0
108
108
  */
109
- const only = test.only;
109
+ const only$1 = test$1.only;
110
110
  /**
111
111
  * Shorthand for marking a test as expected to fail.
112
112
  *
113
113
  * @since 2.3.0
114
114
  */
115
- const failing = test.failing;
115
+ const failing$1 = test$1.failing;
116
116
  /**
117
117
  * Shorthand for running a test concurrently.
118
118
  *
119
119
  * @since 2.3.0
120
120
  */
121
- const concurrent = test.concurrent;
121
+ const concurrent$1 = test$1.concurrent;
122
122
  /**
123
123
  * Shorthand for running a test serially.
124
124
  *
125
125
  * @since 2.3.0
126
126
  */
127
- const serial = test.serial;
127
+ const serial$1 = test$1.serial;
128
128
  /**
129
129
  * Shorthand for Bun's parameterized tests.
130
130
  *
131
131
  * @since 2.3.0
132
132
  */
133
- const each = test.each;
134
- var src_default = test;
133
+ const each$1 = test$1.each;
135
134
  function createBunTestFunction(baseTest, options) {
136
135
  const register = (...args) => Reflect.apply(baseTest, void 0, wrapBunTestArguments(args, options));
137
136
  for (const helperName of helperNames) {
@@ -157,19 +156,20 @@ function createBunTestFunction(baseTest, options) {
157
156
  writable: true
158
157
  });
159
158
  }
160
- const each$1 = getFunctionProperty(baseTest, "each");
161
- if (each$1 != null) Object.defineProperty(register, "each", {
159
+ const each$2 = getFunctionProperty(baseTest, "each");
160
+ if (each$2 != null) Object.defineProperty(register, "each", {
162
161
  configurable: true,
163
162
  enumerable: true,
164
- value: createWrappedEach(baseTest, each$1, options),
163
+ value: createWrappedEach(baseTest, each$2, options),
165
164
  writable: true
166
165
  });
167
166
  return register;
168
167
  }
169
168
  function createWrappedEach(baseTest, baseEach, options) {
170
169
  return (...cases) => {
170
+ const maxCaseArgumentCount = getMaxCaseArgumentCount(cases);
171
171
  const registerEach = Reflect.apply(baseEach, baseTest, cases);
172
- return (...args) => Reflect.apply(registerEach, void 0, wrapBunEachArguments(args, options));
172
+ return (...args) => Reflect.apply(registerEach, void 0, wrapBunEachArguments(args, options, maxCaseArgumentCount));
173
173
  };
174
174
  }
175
175
  function wrapBunTestArguments(args, options) {
@@ -181,43 +181,85 @@ function wrapBunTestArguments(args, options) {
181
181
  ...args.slice(callbackIndex + 1)
182
182
  ];
183
183
  }
184
- function wrapBunEachArguments(args, options) {
184
+ function wrapBunEachArguments(args, options, maxCaseArgumentCount) {
185
185
  const callbackIndex = args.findIndex((arg, index) => index > 0 && typeof arg === "function");
186
186
  if (callbackIndex < 0) return [...args];
187
187
  return [
188
188
  ...args.slice(0, callbackIndex),
189
- wrapBunEachCallback(args[callbackIndex], options),
189
+ wrapBunEachCallback(args[callbackIndex], options, maxCaseArgumentCount),
190
190
  ...args.slice(callbackIndex + 1)
191
191
  ];
192
192
  }
193
193
  function wrapBunTestCallback(callback, options) {
194
194
  const reporter = (0, __logtape_testing_reporter.createFailureLogReporter)(options);
195
195
  if (callback.length >= 1) return function(done) {
196
- const wrapped = reporter.wrap(() => new Promise((resolve, reject) => {
197
- let settled = false;
198
- const wrappedDone = (error) => {
199
- if (settled) return;
200
- settled = true;
201
- if (error == null) resolve();
202
- else reject(error);
203
- };
204
- try {
205
- Reflect.apply(callback, this, [wrappedDone]);
206
- } catch (error) {
207
- reject(error);
208
- }
209
- }));
196
+ const wrapped = reporter.wrap(() => runBunDoneCallback(callback, this, []));
210
197
  wrapped().then(() => done(), (error) => done(error));
211
198
  };
212
199
  return function() {
213
200
  return reporter.run(() => Reflect.apply(callback, this, []));
214
201
  };
215
202
  }
216
- function wrapBunEachCallback(callback, options) {
203
+ function wrapBunEachCallback(callback, options, maxCaseArgumentCount) {
217
204
  const reporter = (0, __logtape_testing_reporter.createFailureLogReporter)(options);
218
- return function(...args) {
219
- return reporter.run(() => Reflect.apply(callback, this, args));
220
- };
205
+ const invoke = (thisArg, args) => runBunEachCallback(reporter, callback, thisArg, args, maxCaseArgumentCount);
206
+ return createArityPreservingFunction(callback.length, invoke);
207
+ }
208
+ function createArityPreservingFunction(length, invoke) {
209
+ const parameters = Array.from({ length }, (_, index) => `arg${index}`).join(", ");
210
+ const createFunction = Function("invoke", `return function (${parameters}) { return invoke(this, Array.from(arguments)); };`);
211
+ return createFunction(invoke);
212
+ }
213
+ function runBunEachCallback(reporter, callback, thisArg, args, maxCaseArgumentCount) {
214
+ const lastArgument = args.at(-1);
215
+ if (callback.length > maxCaseArgumentCount && typeof lastArgument === "function") {
216
+ const done = lastArgument;
217
+ reporter.run(() => runBunDoneCallback(callback, thisArg, args.slice(0, -1))).then(() => done(), (error) => done(error));
218
+ return void 0;
219
+ }
220
+ return reporter.run(() => Reflect.apply(callback, thisArg, args));
221
+ }
222
+ function runBunDoneCallback(callback, thisArg, args) {
223
+ return new Promise((resolve, reject) => {
224
+ let callbackReturned = false;
225
+ let doneCalled = false;
226
+ let pendingDone = false;
227
+ let pendingDoneError;
228
+ let settled = false;
229
+ const settle = (error) => {
230
+ if (settled) return;
231
+ settled = true;
232
+ if (error == null) resolve();
233
+ else reject(error);
234
+ };
235
+ const wrappedDone = (error) => {
236
+ if (doneCalled) return;
237
+ doneCalled = true;
238
+ if (!callbackReturned) {
239
+ pendingDone = true;
240
+ pendingDoneError = error;
241
+ return;
242
+ }
243
+ settle(error);
244
+ };
245
+ try {
246
+ Reflect.apply(callback, thisArg, [...args, wrappedDone]);
247
+ callbackReturned = true;
248
+ if (pendingDone) settle(pendingDoneError);
249
+ } catch (error) {
250
+ callbackReturned = true;
251
+ reject(error);
252
+ }
253
+ });
254
+ }
255
+ function getMaxCaseArgumentCount(cases) {
256
+ const rows = cases.length === 1 && Array.isArray(cases[0]) ? cases[0] : cases;
257
+ let maxArgumentCount = 0;
258
+ for (const row of rows) {
259
+ const argumentCount = Array.isArray(row) ? row.length : 1;
260
+ maxArgumentCount = Math.max(maxArgumentCount, argumentCount);
261
+ }
262
+ return maxArgumentCount;
221
263
  }
222
264
  function getFunctionProperty(value, property) {
223
265
  try {
@@ -240,7 +282,17 @@ if (config == null) (0, __logtape_logtape.configureSync)({
240
282
  }]
241
283
  });
242
284
  else if (config.contextLocalStorage == null) throw new __logtape_logtape.ConfigError("@logtape/testing-bun/autoload requires the existing LogTape configuration to provide contextLocalStorage.");
243
- var autoload_default = src_default;
285
+ const reporterOptions = (0, __logtape_testing_reporter.getFailureLogReporterOptionsFromEnv)({ getEnv: (name) => process.env[name] });
286
+ const test = createTest(reporterOptions);
287
+ const it = createIt(reporterOptions);
288
+ const concurrent = test.concurrent;
289
+ const each = test.each;
290
+ const failing = test.failing;
291
+ const only = test.only;
292
+ const serial = test.serial;
293
+ const skip = test.skip;
294
+ const todo = test.todo;
295
+ var autoload_default = test;
244
296
 
245
297
  //#endregion
246
298
  exports.afterAll = bun_test.afterAll;
@@ -266,7 +318,7 @@ exports.setDefaultTimeout = bun_test.setDefaultTimeout;
266
318
  exports.setSystemTime = bun_test.setSystemTime;
267
319
  exports.skip = skip;
268
320
  exports.spyOn = bun_test.spyOn;
269
- exports.test = src_default;
321
+ exports.test = test;
270
322
  exports.todo = todo;
271
323
  exports.vi = vi;
272
324
  exports.xdescribe = xdescribe;
@@ -96,56 +96,17 @@ declare function createIt(options?: FailureLogReporterOptions$1): BunTestFunctio
96
96
  *
97
97
  * @since 2.3.0
98
98
  */
99
+ //#endregion
100
+ //#region src/autoload.d.ts
99
101
  declare const test: BunTestFunction;
100
- /**
101
- * A `bun:test` `it()` alias that reports LogTape records from failed test
102
- * callbacks using the default reporter options.
103
- *
104
- * @since 2.3.0
105
- */
106
102
  declare const it: BunTestFunction;
107
- /**
108
- * Shorthand for skipping a test.
109
- *
110
- * @since 2.3.0
111
- */
112
- declare const skip: BunTestFunction;
113
- /**
114
- * Shorthand for marking a test as TODO.
115
- *
116
- * @since 2.3.0
117
- */
118
- declare const todo: BunTestFunction;
119
- /**
120
- * Shorthand for marking a test as `only`.
121
- *
122
- * @since 2.3.0
123
- */
124
- declare const only: BunTestFunction;
125
- /**
126
- * Shorthand for marking a test as expected to fail.
127
- *
128
- * @since 2.3.0
129
- */
130
- declare const failing: BunTestFunction;
131
- /**
132
- * Shorthand for running a test concurrently.
133
- *
134
- * @since 2.3.0
135
- */
136
- declare const concurrent: BunTestFunction;
137
- /**
138
- * Shorthand for running a test serially.
139
- *
140
- * @since 2.3.0
141
- */
142
- declare const serial: BunTestFunction;
143
- /**
144
- * Shorthand for Bun's parameterized tests.
145
- *
146
- * @since 2.3.0
147
- */
148
- declare const each: BunEachFunction;
103
+ declare const concurrent: BunTestFunction["concurrent"];
104
+ declare const each: BunTestFunction["each"];
105
+ declare const failing: BunTestFunction["failing"];
106
+ declare const only: BunTestFunction["only"];
107
+ declare const serial: BunTestFunction["serial"];
108
+ declare const skip: BunTestFunction["skip"];
109
+ declare const todo: BunTestFunction["todo"];
149
110
  //#endregion
150
111
  export { BunTestCallback, BunTestFunction, BunTestOptions, FailureLogReportMode, FailureLogReporterOptions, afterAll, afterEach, beforeAll, beforeEach, concurrent, createIt, createTest, test as default, test, describe, each, expect, expectTypeOf, failing, it, jest, mock, onTestFinished, only, serial, setDefaultTimeout, setSystemTime, skip, spyOn, todo, vi, xdescribe, xit, xtest };
151
112
  //# sourceMappingURL=autoload.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"autoload.d.cts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;AAuDA;AAYA;AASA;;;;;;;AAGmC,UAxBlB,cAAA,CAwBkB;EAA2B,SAC7C,KAAA,CAAA,EAAA,MAAA;EAAe,SAAG,OAAA,CAAA,EAAA,MAAA;EAA2B,SAC7C,OAAA,CAAA,EAAA,MAAA;EAAe,UAAG,MAAA,EAAA,MAAA,CAAA,EAAA,OAAA;;;;;;;AAIlB,KAlBL,eAAA,GAkBK,CAAA,GAAA,GAAA,OAAA,CAAA,GAAA,CAAA,CAAA,IAAA,EAhBL,eAgBK,EAAA,GAAA,OAAA,CAAA;;;;AAG2B;AAC3C;AAMS,UAnBO,eAAA,CAmBkB;EAAA,CAAA,IAAA,EAAA,MAAA,EAAA,EAAA,CAAA,EAlBb,eAkBa,EAAA,OAAA,CAAA,EAAA,MAAA,GAlBuB,cAkBvB,CAAA,EAAA,IAAA;EAAA,CAAA,IACX,EAAA,MAAA,EAAA,OAAA,EAAA,MAAA,GAlBW,cAkBX,EAAA,EAAA,CAAA,EAlBgC,eAkBhC,CAAA,EAAA,IAAA;EAAe,SAAG,IAAA,EAjBzB,eAiByB,GAjBP,2BAiBO;EAA2B,SAAA,IAAA,EAhBpD,eAgBoD,GAhBlC,2BAgBkC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AAA,GAAA,OAAA;KAlFN,oBAAA,GAmFF,CAAA,GAAA,IAAA,EAAA,OAAA,EAAA,EAAA,GAAA,OAAA;AAAe,KAlFb,sBAAA,GAkFa,CAAA,QAAA,EAAA,GAAA,GAAA,OAAA,EAAA,GAAA,IAAA;cArDZ,cAAc;cAGd,gBAAgB;cAKhB,WAAW;ACzHC,cD2HZ,SClGM,EDkGK,WClGwC;AAAA,cDqGnD,GCpG+C,EDoG1C,WCpGD;AAA2C,cDsG/C,KCrG2D,EDqGpD,WCrGK;AAAe;AACN;AACG;AACH;AACE;AACF;;;;;;;;;iBDmHX,UAAA,WACL,8BACR;;;;;;;;;iBAea,QAAA,WACL,8BACR;;;;;;;;;cC7IG,MAAM;cACN,IAAI;ADXV,cCYM,UDZyB,ECYb,eDZa,CAAA,YAAA,CAAA;AAY/B,cCCM,IDDM,ECCA,eDCA,CAAA,MAAA,CAAA;AAOZ,cCPM,ODOW,ECPF,eDOiB,CAAA,SAAA,CAAA;cCN1B,IDM0B,ECNpB,eDMoB,CAAA,MAAA,CAAA;cCL1B,MDMgB,ECNR,eDMQ,CAAA,QAAA,CAAA;cCLhB,IDKoD,ECL9C,eDK8C,CAAA,MAAA,CAAA;cCJpD,IDK6B,ECLvB,eDKuB,CAAA,MAAA,CAAA"}
@@ -1,5 +1,5 @@
1
- import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, jest, mock, setDefaultTimeout, setSystemTime, spyOn } from "bun:test";
2
1
  import { FailureLogReportMode, FailureLogReporterOptions, FailureLogReporterOptions as FailureLogReporterOptions$1 } from "@logtape/testing/reporter";
2
+ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, jest, mock, setDefaultTimeout, setSystemTime, spyOn } from "bun:test";
3
3
 
4
4
  //#region src/mod.d.ts
5
5
 
@@ -96,56 +96,17 @@ declare function createIt(options?: FailureLogReporterOptions$1): BunTestFunctio
96
96
  *
97
97
  * @since 2.3.0
98
98
  */
99
+ //#endregion
100
+ //#region src/autoload.d.ts
99
101
  declare const test: BunTestFunction;
100
- /**
101
- * A `bun:test` `it()` alias that reports LogTape records from failed test
102
- * callbacks using the default reporter options.
103
- *
104
- * @since 2.3.0
105
- */
106
102
  declare const it: BunTestFunction;
107
- /**
108
- * Shorthand for skipping a test.
109
- *
110
- * @since 2.3.0
111
- */
112
- declare const skip: BunTestFunction;
113
- /**
114
- * Shorthand for marking a test as TODO.
115
- *
116
- * @since 2.3.0
117
- */
118
- declare const todo: BunTestFunction;
119
- /**
120
- * Shorthand for marking a test as `only`.
121
- *
122
- * @since 2.3.0
123
- */
124
- declare const only: BunTestFunction;
125
- /**
126
- * Shorthand for marking a test as expected to fail.
127
- *
128
- * @since 2.3.0
129
- */
130
- declare const failing: BunTestFunction;
131
- /**
132
- * Shorthand for running a test concurrently.
133
- *
134
- * @since 2.3.0
135
- */
136
- declare const concurrent: BunTestFunction;
137
- /**
138
- * Shorthand for running a test serially.
139
- *
140
- * @since 2.3.0
141
- */
142
- declare const serial: BunTestFunction;
143
- /**
144
- * Shorthand for Bun's parameterized tests.
145
- *
146
- * @since 2.3.0
147
- */
148
- declare const each: BunEachFunction;
103
+ declare const concurrent: BunTestFunction["concurrent"];
104
+ declare const each: BunTestFunction["each"];
105
+ declare const failing: BunTestFunction["failing"];
106
+ declare const only: BunTestFunction["only"];
107
+ declare const serial: BunTestFunction["serial"];
108
+ declare const skip: BunTestFunction["skip"];
109
+ declare const todo: BunTestFunction["todo"];
149
110
  //#endregion
150
111
  export { BunTestCallback, BunTestFunction, BunTestOptions, FailureLogReportMode, FailureLogReporterOptions, afterAll, afterEach, beforeAll, beforeEach, concurrent, createIt, createTest, test as default, test, describe, each, expect, expectTypeOf, failing, it, jest, mock, onTestFinished, only, serial, setDefaultTimeout, setSystemTime, skip, spyOn, todo, vi, xdescribe, xit, xtest };
151
112
  //# sourceMappingURL=autoload.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"autoload.d.ts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"m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Yb,eDZa,CAAA,YAAA,CAAA;AAY/B,cCCM,IDDM,ECCA,eDCA,CAAA,MAAA,CAAA;AAOZ,cCPM,ODOW,ECPF,eDOiB,CAAA,SAAA,CAAA;cCN1B,IDM0B,ECNpB,eDMoB,CAAA,MAAA,CAAA;cCL1B,MDMgB,ECNR,eDMQ,CAAA,QAAA,CAAA;cCLhB,IDKoD,ECL9C,eDK8C,CAAA,MAAA,CAAA;cCJpD,IDK6B,ECLvB,eDKuB,CAAA,MAAA,CAAA"}
package/dist/autoload.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
2
  import { ConfigError, configureSync, getConfig } from "@logtape/logtape";
3
+ import { createFailureLogReporter, getFailureLogReporterOptionsFromEnv } from "@logtape/testing/reporter";
3
4
  import * as bunTestModule from "bun:test";
4
- import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it as it$1, jest, mock, setDefaultTimeout, setSystemTime, spyOn, test } from "bun:test";
5
- import { createFailureLogReporter } from "@logtape/testing/reporter";
5
+ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it as it$1, jest, mock, setDefaultTimeout, setSystemTime, spyOn, test as test$1 } from "bun:test";
6
6
 
7
7
  //#region src/mod.ts
8
8
  const helperNames = [
@@ -39,7 +39,7 @@ const xtest = bunTestModule.xtest;
39
39
  * @since 2.3.0
40
40
  */
41
41
  function createTest(options = {}) {
42
- return createBunTestFunction(test, options);
42
+ return createBunTestFunction(test$1, options);
43
43
  }
44
44
  /**
45
45
  * Creates an `it()` alias that reports LogTape records from failed test
@@ -58,57 +58,56 @@ function createIt(options = {}) {
58
58
  *
59
59
  * @since 2.3.0
60
60
  */
61
- const test$1 = createTest();
61
+ const test$2 = createTest();
62
62
  /**
63
63
  * A `bun:test` `it()` alias that reports LogTape records from failed test
64
64
  * callbacks using the default reporter options.
65
65
  *
66
66
  * @since 2.3.0
67
67
  */
68
- const it = createIt();
68
+ const it$2 = createIt();
69
69
  /**
70
70
  * Shorthand for skipping a test.
71
71
  *
72
72
  * @since 2.3.0
73
73
  */
74
- const skip = test$1.skip;
74
+ const skip$1 = test$2.skip;
75
75
  /**
76
76
  * Shorthand for marking a test as TODO.
77
77
  *
78
78
  * @since 2.3.0
79
79
  */
80
- const todo = test$1.todo;
80
+ const todo$1 = test$2.todo;
81
81
  /**
82
82
  * Shorthand for marking a test as `only`.
83
83
  *
84
84
  * @since 2.3.0
85
85
  */
86
- const only = test$1.only;
86
+ const only$1 = test$2.only;
87
87
  /**
88
88
  * Shorthand for marking a test as expected to fail.
89
89
  *
90
90
  * @since 2.3.0
91
91
  */
92
- const failing = test$1.failing;
92
+ const failing$1 = test$2.failing;
93
93
  /**
94
94
  * Shorthand for running a test concurrently.
95
95
  *
96
96
  * @since 2.3.0
97
97
  */
98
- const concurrent = test$1.concurrent;
98
+ const concurrent$1 = test$2.concurrent;
99
99
  /**
100
100
  * Shorthand for running a test serially.
101
101
  *
102
102
  * @since 2.3.0
103
103
  */
104
- const serial = test$1.serial;
104
+ const serial$1 = test$2.serial;
105
105
  /**
106
106
  * Shorthand for Bun's parameterized tests.
107
107
  *
108
108
  * @since 2.3.0
109
109
  */
110
- const each = test$1.each;
111
- var src_default = test$1;
110
+ const each$1 = test$2.each;
112
111
  function createBunTestFunction(baseTest, options) {
113
112
  const register = (...args) => Reflect.apply(baseTest, void 0, wrapBunTestArguments(args, options));
114
113
  for (const helperName of helperNames) {
@@ -134,19 +133,20 @@ function createBunTestFunction(baseTest, options) {
134
133
  writable: true
135
134
  });
136
135
  }
137
- const each$1 = getFunctionProperty(baseTest, "each");
138
- if (each$1 != null) Object.defineProperty(register, "each", {
136
+ const each$2 = getFunctionProperty(baseTest, "each");
137
+ if (each$2 != null) Object.defineProperty(register, "each", {
139
138
  configurable: true,
140
139
  enumerable: true,
141
- value: createWrappedEach(baseTest, each$1, options),
140
+ value: createWrappedEach(baseTest, each$2, options),
142
141
  writable: true
143
142
  });
144
143
  return register;
145
144
  }
146
145
  function createWrappedEach(baseTest, baseEach, options) {
147
146
  return (...cases) => {
147
+ const maxCaseArgumentCount = getMaxCaseArgumentCount(cases);
148
148
  const registerEach = Reflect.apply(baseEach, baseTest, cases);
149
- return (...args) => Reflect.apply(registerEach, void 0, wrapBunEachArguments(args, options));
149
+ return (...args) => Reflect.apply(registerEach, void 0, wrapBunEachArguments(args, options, maxCaseArgumentCount));
150
150
  };
151
151
  }
152
152
  function wrapBunTestArguments(args, options) {
@@ -158,43 +158,85 @@ function wrapBunTestArguments(args, options) {
158
158
  ...args.slice(callbackIndex + 1)
159
159
  ];
160
160
  }
161
- function wrapBunEachArguments(args, options) {
161
+ function wrapBunEachArguments(args, options, maxCaseArgumentCount) {
162
162
  const callbackIndex = args.findIndex((arg, index) => index > 0 && typeof arg === "function");
163
163
  if (callbackIndex < 0) return [...args];
164
164
  return [
165
165
  ...args.slice(0, callbackIndex),
166
- wrapBunEachCallback(args[callbackIndex], options),
166
+ wrapBunEachCallback(args[callbackIndex], options, maxCaseArgumentCount),
167
167
  ...args.slice(callbackIndex + 1)
168
168
  ];
169
169
  }
170
170
  function wrapBunTestCallback(callback, options) {
171
171
  const reporter = createFailureLogReporter(options);
172
172
  if (callback.length >= 1) return function(done) {
173
- const wrapped = reporter.wrap(() => new Promise((resolve, reject) => {
174
- let settled = false;
175
- const wrappedDone = (error) => {
176
- if (settled) return;
177
- settled = true;
178
- if (error == null) resolve();
179
- else reject(error);
180
- };
181
- try {
182
- Reflect.apply(callback, this, [wrappedDone]);
183
- } catch (error) {
184
- reject(error);
185
- }
186
- }));
173
+ const wrapped = reporter.wrap(() => runBunDoneCallback(callback, this, []));
187
174
  wrapped().then(() => done(), (error) => done(error));
188
175
  };
189
176
  return function() {
190
177
  return reporter.run(() => Reflect.apply(callback, this, []));
191
178
  };
192
179
  }
193
- function wrapBunEachCallback(callback, options) {
180
+ function wrapBunEachCallback(callback, options, maxCaseArgumentCount) {
194
181
  const reporter = createFailureLogReporter(options);
195
- return function(...args) {
196
- return reporter.run(() => Reflect.apply(callback, this, args));
197
- };
182
+ const invoke = (thisArg, args) => runBunEachCallback(reporter, callback, thisArg, args, maxCaseArgumentCount);
183
+ return createArityPreservingFunction(callback.length, invoke);
184
+ }
185
+ function createArityPreservingFunction(length, invoke) {
186
+ const parameters = Array.from({ length }, (_, index) => `arg${index}`).join(", ");
187
+ const createFunction = Function("invoke", `return function (${parameters}) { return invoke(this, Array.from(arguments)); };`);
188
+ return createFunction(invoke);
189
+ }
190
+ function runBunEachCallback(reporter, callback, thisArg, args, maxCaseArgumentCount) {
191
+ const lastArgument = args.at(-1);
192
+ if (callback.length > maxCaseArgumentCount && typeof lastArgument === "function") {
193
+ const done = lastArgument;
194
+ reporter.run(() => runBunDoneCallback(callback, thisArg, args.slice(0, -1))).then(() => done(), (error) => done(error));
195
+ return void 0;
196
+ }
197
+ return reporter.run(() => Reflect.apply(callback, thisArg, args));
198
+ }
199
+ function runBunDoneCallback(callback, thisArg, args) {
200
+ return new Promise((resolve, reject) => {
201
+ let callbackReturned = false;
202
+ let doneCalled = false;
203
+ let pendingDone = false;
204
+ let pendingDoneError;
205
+ let settled = false;
206
+ const settle = (error) => {
207
+ if (settled) return;
208
+ settled = true;
209
+ if (error == null) resolve();
210
+ else reject(error);
211
+ };
212
+ const wrappedDone = (error) => {
213
+ if (doneCalled) return;
214
+ doneCalled = true;
215
+ if (!callbackReturned) {
216
+ pendingDone = true;
217
+ pendingDoneError = error;
218
+ return;
219
+ }
220
+ settle(error);
221
+ };
222
+ try {
223
+ Reflect.apply(callback, thisArg, [...args, wrappedDone]);
224
+ callbackReturned = true;
225
+ if (pendingDone) settle(pendingDoneError);
226
+ } catch (error) {
227
+ callbackReturned = true;
228
+ reject(error);
229
+ }
230
+ });
231
+ }
232
+ function getMaxCaseArgumentCount(cases) {
233
+ const rows = cases.length === 1 && Array.isArray(cases[0]) ? cases[0] : cases;
234
+ let maxArgumentCount = 0;
235
+ for (const row of rows) {
236
+ const argumentCount = Array.isArray(row) ? row.length : 1;
237
+ maxArgumentCount = Math.max(maxArgumentCount, argumentCount);
238
+ }
239
+ return maxArgumentCount;
198
240
  }
199
241
  function getFunctionProperty(value, property) {
200
242
  try {
@@ -217,8 +259,18 @@ if (config == null) configureSync({
217
259
  }]
218
260
  });
219
261
  else if (config.contextLocalStorage == null) throw new ConfigError("@logtape/testing-bun/autoload requires the existing LogTape configuration to provide contextLocalStorage.");
220
- var autoload_default = src_default;
262
+ const reporterOptions = getFailureLogReporterOptionsFromEnv({ getEnv: (name) => process.env[name] });
263
+ const test = createTest(reporterOptions);
264
+ const it = createIt(reporterOptions);
265
+ const concurrent = test.concurrent;
266
+ const each = test.each;
267
+ const failing = test.failing;
268
+ const only = test.only;
269
+ const serial = test.serial;
270
+ const skip = test.skip;
271
+ const todo = test.todo;
272
+ var autoload_default = test;
221
273
 
222
274
  //#endregion
223
- export { afterAll, afterEach, beforeAll, beforeEach, concurrent, createIt, createTest, autoload_default as default, describe, each, expect, expectTypeOf, failing, it, jest, mock, onTestFinished, only, serial, setDefaultTimeout, setSystemTime, skip, spyOn, src_default as test, todo, vi, xdescribe, xit, xtest };
275
+ export { afterAll, afterEach, beforeAll, beforeEach, concurrent, createIt, createTest, autoload_default as default, describe, each, expect, expectTypeOf, failing, it, jest, mock, onTestFinished, only, serial, setDefaultTimeout, setSystemTime, skip, spyOn, test, todo, vi, xdescribe, xit, xtest };
224
276
  //# sourceMappingURL=autoload.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"autoload.js","names":["expectTypeOf: ExpectTypeOfFunction","onTestFinished: OnTestFinishedFunction","vi: typeof jest","xdescribe: BunFunction","xit: BunFunction","xtest: BunFunction","options: FailureLogReporterOptions","bunTest","bunIt","test: BunTestFunction","it: BunTestFunction","skip: BunTestFunction","test","todo: BunTestFunction","only: BunTestFunction","failing: BunTestFunction","concurrent: BunTestFunction","serial: BunTestFunction","each: BunEachFunction","baseTest: BaseBunTestFunction","condition: unknown","each","baseEach: AnyFunction","args: readonly unknown[]","callback: AnyFunction","done: BunDoneCallback","wrappedDone: BunDoneCallback","error?: unknown","error: unknown","value: BaseBunTestFunction","property: string","test"],"sources":["../src/mod.ts","../src/autoload.ts"],"sourcesContent":["import {\n afterAll,\n afterEach,\n beforeAll,\n beforeEach,\n describe,\n expect,\n it as bunIt,\n jest,\n mock,\n setDefaultTimeout,\n setSystemTime,\n spyOn,\n test as bunTest,\n} from \"bun:test\";\nimport * as bunTestModule from \"bun:test\";\n\nimport {\n createFailureLogReporter,\n type FailureLogReporterOptions,\n} from \"@logtape/testing/reporter\";\n\nexport type {\n FailureLogReporterOptions,\n FailureLogReportMode,\n} from \"@logtape/testing/reporter\";\nexport {\n afterAll,\n afterEach,\n beforeAll,\n beforeEach,\n describe,\n expect,\n expectTypeOf,\n jest,\n mock,\n onTestFinished,\n setDefaultTimeout,\n setSystemTime,\n spyOn,\n vi,\n xdescribe,\n xit,\n xtest,\n};\n\n/**\n * Options accepted by Bun's `test()` and `it()` functions.\n *\n * The shape mirrors Bun's documented option bag while allowing newer Bun\n * options to pass through even when bundled TypeScript declarations lag behind\n * the current runtime.\n *\n * @since 2.3.0\n */\nexport interface BunTestOptions {\n readonly retry?: number;\n readonly repeats?: number;\n readonly timeout?: number;\n readonly [option: string]: unknown;\n}\n\n/**\n * A callback passed to Bun's `test()` or `it()`.\n *\n * @since 2.3.0\n */\nexport type BunTestCallback =\n | (() => unknown)\n | ((done: BunDoneCallback) => unknown);\n\n/**\n * A Bun `test()`-compatible function.\n *\n * @since 2.3.0\n */\nexport interface BunTestFunction {\n (name: string, fn?: BunTestCallback, options?: number | BunTestOptions): void;\n (name: string, options: number | BunTestOptions, fn?: BunTestCallback): void;\n readonly skip: BunTestFunction & BunParameterizedTestFactory;\n readonly todo: BunTestFunction & BunParameterizedTestFactory;\n readonly only: BunTestFunction & BunParameterizedTestFactory;\n readonly failing: BunTestFunction & BunParameterizedTestFactory;\n readonly concurrent: BunTestFunction & BunParameterizedTestFactory;\n readonly serial: BunTestFunction & BunParameterizedTestFactory;\n readonly each: BunEachFunction;\n readonly if: BunConditionalTestFactory;\n readonly skipIf: BunConditionalTestFactory;\n readonly todoIf: BunConditionalTestFactory;\n}\n\ninterface BunParameterizedTestFactory {\n readonly each: BunEachFunction;\n}\n\ninterface BunConditionalTestFactory {\n (condition: unknown): BunTestFunction & BunParameterizedTestFactory;\n}\n\ninterface BunEachFunction {\n (...cases: readonly unknown[]): BunEachRegisterFunction;\n}\n\ninterface BunEachRegisterFunction {\n (\n name: string,\n fn: (...args: never[]) => unknown,\n options?: number | BunTestOptions,\n ): void;\n (\n name: string,\n options: number | BunTestOptions,\n fn: (...args: never[]) => unknown,\n ): void;\n}\n\ntype BunDoneCallback = (error?: unknown) => void;\ntype AnyFunction = (...args: never[]) => unknown;\ntype BunFunction = (...args: unknown[]) => unknown;\ntype ExpectTypeOfFunction = (...args: unknown[]) => unknown;\ntype OnTestFinishedFunction = (callback: () => unknown) => void;\ntype BaseBunTestFunction = AnyFunction & {\n readonly skip?: BaseBunTestFunction;\n readonly todo?: BaseBunTestFunction;\n readonly only?: BaseBunTestFunction;\n readonly failing?: BaseBunTestFunction;\n readonly concurrent?: BaseBunTestFunction;\n readonly serial?: BaseBunTestFunction;\n readonly each?: AnyFunction;\n readonly if?: AnyFunction;\n readonly skipIf?: AnyFunction;\n readonly todoIf?: AnyFunction;\n};\n\nconst helperNames = [\n \"skip\",\n \"todo\",\n \"only\",\n \"failing\",\n \"concurrent\",\n \"serial\",\n] as const;\n\nconst conditionalHelperNames = [\n \"if\",\n \"skipIf\",\n \"todoIf\",\n] as const;\n\nconst expectTypeOf: ExpectTypeOfFunction = (\n bunTestModule as unknown as { readonly expectTypeOf: ExpectTypeOfFunction }\n).expectTypeOf;\nconst onTestFinished: OnTestFinishedFunction = (\n bunTestModule as unknown as {\n readonly onTestFinished: OnTestFinishedFunction;\n }\n).onTestFinished;\nconst vi: typeof jest =\n (bunTestModule as unknown as { readonly vi: typeof jest }).vi;\nconst xdescribe: BunFunction =\n (bunTestModule as unknown as { readonly xdescribe: BunFunction })\n .xdescribe;\nconst xit: BunFunction =\n (bunTestModule as unknown as { readonly xit: BunFunction }).xit;\nconst xtest: BunFunction = (bunTestModule as unknown as {\n readonly xtest: BunFunction;\n})\n .xtest;\n\n/**\n * Creates a `bun:test` test function that reports LogTape records from failed\n * test callbacks.\n *\n * The returned function preserves Bun test options and shorthand helpers such\n * as `test.skip()`, `test.todo()`, `test.only()`, `test.if()`,\n * `test.failing()`, `test.concurrent()`, `test.serial()`, and `test.each()`.\n * Only callback arguments are adapted; options are passed through to\n * `bun:test`.\n *\n * @param options Failure log reporter options.\n * @returns A configured `bun:test`-compatible test function.\n * @since 2.3.0\n */\nexport function createTest(\n options: FailureLogReporterOptions = {},\n): BunTestFunction {\n return createBunTestFunction(\n bunTest as unknown as BaseBunTestFunction,\n options,\n );\n}\n\n/**\n * Creates an `it()` alias that reports LogTape records from failed test\n * callbacks.\n *\n * @param options Failure log reporter options.\n * @returns A configured `bun:test`-compatible `it()` function.\n * @since 2.3.0\n */\nexport function createIt(\n options: FailureLogReporterOptions = {},\n): BunTestFunction {\n return createBunTestFunction(\n bunIt as unknown as BaseBunTestFunction,\n options,\n );\n}\n\n/**\n * A `bun:test` test function that reports LogTape records from failed test\n * callbacks using the default reporter options.\n *\n * @since 2.3.0\n */\nexport const test: BunTestFunction = createTest();\n\n/**\n * A `bun:test` `it()` alias that reports LogTape records from failed test\n * callbacks using the default reporter options.\n *\n * @since 2.3.0\n */\nexport const it: BunTestFunction = createIt();\n\n/**\n * Shorthand for skipping a test.\n *\n * @since 2.3.0\n */\nexport const skip: BunTestFunction = test.skip;\n\n/**\n * Shorthand for marking a test as TODO.\n *\n * @since 2.3.0\n */\nexport const todo: BunTestFunction = test.todo;\n\n/**\n * Shorthand for marking a test as `only`.\n *\n * @since 2.3.0\n */\nexport const only: BunTestFunction = test.only;\n\n/**\n * Shorthand for marking a test as expected to fail.\n *\n * @since 2.3.0\n */\nexport const failing: BunTestFunction = test.failing;\n\n/**\n * Shorthand for running a test concurrently.\n *\n * @since 2.3.0\n */\nexport const concurrent: BunTestFunction = test.concurrent;\n\n/**\n * Shorthand for running a test serially.\n *\n * @since 2.3.0\n */\nexport const serial: BunTestFunction = test.serial;\n\n/**\n * Shorthand for Bun's parameterized tests.\n *\n * @since 2.3.0\n */\nexport const each: BunEachFunction = test.each;\n\nexport default test;\n\nfunction createBunTestFunction(\n baseTest: BaseBunTestFunction,\n options: FailureLogReporterOptions,\n): BunTestFunction {\n const register = ((...args: unknown[]) =>\n Reflect.apply(\n baseTest,\n undefined,\n wrapBunTestArguments(args, options),\n )) as BunTestFunction;\n\n for (const helperName of helperNames) {\n const helper = getFunctionProperty(baseTest, helperName);\n if (helper == null) continue;\n Object.defineProperty(register, helperName, {\n configurable: true,\n enumerable: true,\n value: createBunTestFunction(\n helper as BaseBunTestFunction,\n options,\n ),\n writable: true,\n });\n }\n\n for (const helperName of conditionalHelperNames) {\n const helper = getFunctionProperty(baseTest, helperName);\n if (helper == null) continue;\n Object.defineProperty(register, helperName, {\n configurable: true,\n enumerable: true,\n value: ((condition: unknown) => {\n const conditionalTest = Reflect.apply(helper, baseTest, [condition]);\n return createBunTestFunction(\n conditionalTest as BaseBunTestFunction,\n options,\n );\n }) as BunConditionalTestFactory,\n writable: true,\n });\n }\n\n const each = getFunctionProperty(baseTest, \"each\");\n if (each != null) {\n Object.defineProperty(register, \"each\", {\n configurable: true,\n enumerable: true,\n value: createWrappedEach(baseTest, each, options),\n writable: true,\n });\n }\n\n return register;\n}\n\nfunction createWrappedEach(\n baseTest: BaseBunTestFunction,\n baseEach: AnyFunction,\n options: FailureLogReporterOptions,\n): BunEachFunction {\n return ((...cases: readonly unknown[]) => {\n const registerEach = Reflect.apply(baseEach, baseTest, cases);\n return ((...args: unknown[]) =>\n Reflect.apply(\n registerEach as AnyFunction,\n undefined,\n wrapBunEachArguments(args, options),\n )) as BunEachRegisterFunction;\n }) as BunEachFunction;\n}\n\nfunction wrapBunTestArguments(\n args: readonly unknown[],\n options: FailureLogReporterOptions,\n): unknown[] {\n const callbackIndex = args.findIndex((arg) => typeof arg === \"function\");\n if (callbackIndex < 0) return [...args];\n\n return [\n ...args.slice(0, callbackIndex),\n wrapBunTestCallback(args[callbackIndex] as AnyFunction, options),\n ...args.slice(callbackIndex + 1),\n ];\n}\n\nfunction wrapBunEachArguments(\n args: readonly unknown[],\n options: FailureLogReporterOptions,\n): unknown[] {\n const callbackIndex = args.findIndex((arg, index) =>\n index > 0 && typeof arg === \"function\"\n );\n if (callbackIndex < 0) return [...args];\n\n return [\n ...args.slice(0, callbackIndex),\n wrapBunEachCallback(args[callbackIndex] as AnyFunction, options),\n ...args.slice(callbackIndex + 1),\n ];\n}\n\nfunction wrapBunTestCallback(\n callback: AnyFunction,\n options: FailureLogReporterOptions,\n): AnyFunction {\n const reporter = createFailureLogReporter(options);\n\n if (callback.length >= 1) {\n return function (this: unknown, done: BunDoneCallback): void {\n const wrapped = reporter.wrap(() =>\n new Promise<void>((resolve, reject) => {\n let settled = false;\n const wrappedDone: BunDoneCallback = (error?: unknown) => {\n if (settled) return;\n settled = true;\n if (error == null) resolve();\n else reject(error);\n };\n\n try {\n Reflect.apply(callback, this, [wrappedDone]);\n } catch (error) {\n reject(error);\n }\n })\n );\n\n void wrapped().then(\n () => done(),\n (error: unknown) => done(error),\n );\n };\n }\n\n return function (this: unknown): Promise<unknown> {\n return reporter.run(() => Reflect.apply(callback, this, []));\n };\n}\n\nfunction wrapBunEachCallback(\n callback: AnyFunction,\n options: FailureLogReporterOptions,\n): AnyFunction {\n const reporter = createFailureLogReporter(options);\n return function (this: unknown, ...args: never[]) {\n return reporter.run(() => Reflect.apply(callback, this, args));\n };\n}\n\nfunction getFunctionProperty(\n value: BaseBunTestFunction,\n property: string,\n): AnyFunction | undefined {\n try {\n const propertyValue = Reflect.get(value, property);\n return typeof propertyValue === \"function\" ? propertyValue : undefined;\n } catch {\n return undefined;\n }\n}\n","import { AsyncLocalStorage } from \"node:async_hooks\";\n\nimport {\n ConfigError,\n configureSync,\n type ContextLocalStorage,\n getConfig,\n} from \"@logtape/logtape\";\n\nimport {\n afterAll,\n afterEach,\n beforeAll,\n beforeEach,\n concurrent,\n createIt,\n createTest,\n default as test,\n describe,\n each,\n expect,\n expectTypeOf,\n failing,\n it,\n jest,\n mock,\n only,\n onTestFinished,\n serial,\n setDefaultTimeout,\n setSystemTime,\n skip,\n spyOn,\n todo,\n vi,\n xdescribe,\n xit,\n xtest,\n} from \"./mod.ts\";\n\nexport type {\n BunTestCallback,\n BunTestFunction,\n BunTestOptions,\n FailureLogReporterOptions,\n FailureLogReportMode,\n} from \"./mod.ts\";\n\nconst config = getConfig();\n\nif (config == null) {\n configureSync({\n contextLocalStorage: new AsyncLocalStorage() as ContextLocalStorage<\n Record<string, unknown>\n >,\n sinks: {},\n loggers: [\n { category: [\"logtape\", \"meta\"], sinks: [] },\n ],\n });\n} else if (config.contextLocalStorage == null) {\n throw new ConfigError(\n \"@logtape/testing-bun/autoload requires the existing LogTape \" +\n \"configuration to provide contextLocalStorage.\",\n );\n}\n\nexport {\n afterAll,\n afterEach,\n beforeAll,\n beforeEach,\n concurrent,\n createIt,\n createTest,\n describe,\n each,\n expect,\n expectTypeOf,\n failing,\n it,\n jest,\n mock,\n only,\n onTestFinished,\n serial,\n setDefaultTimeout,\n setSystemTime,\n skip,\n spyOn,\n test,\n todo,\n vi,\n xdescribe,\n xit,\n xtest,\n};\nexport default test;\n"],"mappings":";;;;;;;AAsIA,MAAM,cAAc;CAClB;CACA;CACA;CACA;CACA;CACA;AACD;AAED,MAAM,yBAAyB;CAC7B;CACA;CACA;AACD;AAED,MAAMA,eACJ,cACA;AACF,MAAMC,iBACJ,cAGA;AACF,MAAMC,KACH,cAA0D;AAC7D,MAAMC,YACH,cACE;AACL,MAAMC,MACH,cAA2D;AAC9D,MAAMC,QAAsB,cAGzB;;;;;;;;;;;;;;;AAgBH,SAAgB,WACdC,UAAqC,CAAE,GAC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ED,EAAK,SAAS,CAAC,KACb,MAAM,MAAM,EACZ,CAACC,UAAmB,KAAK,MAAM,CAChC;CACF;AAGH,QAAO,WAA2C;AAChD,SAAO,SAAS,IAAI,MAAM,QAAQ,MAAM,UAAU,MAAM,CAAE,EAAC,CAAC;CAC7D;AACF;AAED,SAAS,oBACPJ,UACAlB,SACa;CACb,MAAM,WAAW,yBAAyB,QAAQ;AAClD,QAAO,SAAyB,GAAG,MAAe;AAChD,SAAO,SAAS,IAAI,MAAM,QAAQ,MAAM,UAAU,MAAM,KAAK,CAAC;CAC/D;AACF;AAED,SAAS,oBACPuB,OACAC,UACyB;AACzB,KAAI;EACF,MAAM,gBAAgB,QAAQ,IAAI,OAAO,SAAS;AAClD,gBAAc,kBAAkB,aAAa;CAC9C,QAAO;AACN;CACD;AACF;;;;ACnYD,MAAM,SAAS,WAAW;AAE1B,IAAI,UAAU,KACZ,eAAc;CACZ,qBAAqB,IAAI;CAGzB,OAAO,CAAE;CACT,SAAS,CACP;EAAE,UAAU,CAAC,WAAW,MAAO;EAAE,OAAO,CAAE;CAAE,CAC7C;AACF,EAAC;SACO,OAAO,uBAAuB,KACvC,OAAM,IAAI,YACR;AAmCJ,uBAAeC"}
1
+ {"version":3,"file":"autoload.js","names":["expectTypeOf: ExpectTypeOfFunction","onTestFinished: OnTestFinishedFunction","vi: typeof jest","xdescribe: BunFunction","xit: BunFunction","xtest: BunFunction","options: FailureLogReporterOptions","bunTest","bunIt","test: BunTestFunction","it: BunTestFunction","skip: BunTestFunction","test","todo: BunTestFunction","only: BunTestFunction","failing: BunTestFunction","concurrent: BunTestFunction","serial: BunTestFunction","each: BunEachFunction","baseTest: BaseBunTestFunction","register: BunTestFunction","condition: unknown","each","baseEach: AnyFunction","args: readonly unknown[]","maxCaseArgumentCount: number","callback: AnyFunction","done: BunDoneCallback","error: unknown","thisArg: unknown","length: number","invoke: BunEachInvoker","reporter: ReturnType<typeof createFailureLogReporter>","pendingDoneError: unknown","error?: unknown","wrappedDone: BunDoneCallback","cases: readonly unknown[]","value: BaseBunTestFunction","property: string","reporterOptions: FailureLogReporterOptions","test: BunTestFunction","it: BunTestFunction","concurrent: BunTestFunction[\"concurrent\"]","each: BunTestFunction[\"each\"]","failing: BunTestFunction[\"failing\"]","only: BunTestFunction[\"only\"]","serial: BunTestFunction[\"serial\"]","skip: BunTestFunction[\"skip\"]","todo: BunTestFunction[\"todo\"]"],"sources":["../src/mod.ts","../src/autoload.ts"],"sourcesContent":["// @ts-types=\"npm:@types/bun@^1.2.15\"\nimport {\n afterAll,\n afterEach,\n beforeAll,\n beforeEach,\n describe,\n expect,\n it as bunIt,\n jest,\n mock,\n setDefaultTimeout,\n setSystemTime,\n spyOn,\n test as bunTest,\n} from \"bun:test\";\n// @ts-types=\"npm:@types/bun@^1.2.15\"\nimport * as bunTestModule from \"bun:test\";\n\nimport {\n createFailureLogReporter,\n type FailureLogReporterOptions,\n} from \"@logtape/testing/reporter\";\n\nexport type {\n FailureLogReporterOptions,\n FailureLogReportMode,\n} from \"@logtape/testing/reporter\";\nexport {\n afterAll,\n afterEach,\n beforeAll,\n beforeEach,\n describe,\n expect,\n expectTypeOf,\n jest,\n mock,\n onTestFinished,\n setDefaultTimeout,\n setSystemTime,\n spyOn,\n vi,\n xdescribe,\n xit,\n xtest,\n};\n\n/**\n * Options accepted by Bun's `test()` and `it()` functions.\n *\n * The shape mirrors Bun's documented option bag while allowing newer Bun\n * options to pass through even when bundled TypeScript declarations lag behind\n * the current runtime.\n *\n * @since 2.3.0\n */\nexport interface BunTestOptions {\n readonly retry?: number;\n readonly repeats?: number;\n readonly timeout?: number;\n readonly [option: string]: unknown;\n}\n\n/**\n * A callback passed to Bun's `test()` or `it()`.\n *\n * @since 2.3.0\n */\nexport type BunTestCallback =\n | (() => unknown)\n | ((done: BunDoneCallback) => unknown);\n\n/**\n * A Bun `test()`-compatible function.\n *\n * @since 2.3.0\n */\nexport interface BunTestFunction {\n (name: string, fn?: BunTestCallback, options?: number | BunTestOptions): void;\n (name: string, options: number | BunTestOptions, fn?: BunTestCallback): void;\n readonly skip: BunTestFunction & BunParameterizedTestFactory;\n readonly todo: BunTestFunction & BunParameterizedTestFactory;\n readonly only: BunTestFunction & BunParameterizedTestFactory;\n readonly failing: BunTestFunction & BunParameterizedTestFactory;\n readonly concurrent: BunTestFunction & BunParameterizedTestFactory;\n readonly serial: BunTestFunction & BunParameterizedTestFactory;\n readonly each: BunEachFunction;\n readonly if: BunConditionalTestFactory;\n readonly skipIf: BunConditionalTestFactory;\n readonly todoIf: BunConditionalTestFactory;\n}\n\ninterface BunParameterizedTestFactory {\n readonly each: BunEachFunction;\n}\n\ninterface BunConditionalTestFactory {\n (condition: unknown): BunTestFunction & BunParameterizedTestFactory;\n}\n\ninterface BunEachFunction {\n (...cases: readonly unknown[]): BunEachRegisterFunction;\n}\n\ninterface BunEachRegisterFunction {\n (\n name: string,\n fn: (...args: never[]) => unknown,\n options?: number | BunTestOptions,\n ): void;\n (\n name: string,\n options: number | BunTestOptions,\n fn: (...args: never[]) => unknown,\n ): void;\n}\n\ntype BunDoneCallback = (error?: unknown) => void;\ntype AnyFunction = (...args: never[]) => unknown;\ntype BunFunction = (...args: unknown[]) => unknown;\ntype BunEachInvoker = (\n thisArg: unknown,\n args: readonly unknown[],\n) => unknown;\ntype ExpectTypeOfFunction = (...args: unknown[]) => unknown;\ntype OnTestFinishedFunction = (callback: () => unknown) => void;\ntype BaseBunTestFunction = AnyFunction & {\n readonly skip?: BaseBunTestFunction;\n readonly todo?: BaseBunTestFunction;\n readonly only?: BaseBunTestFunction;\n readonly failing?: BaseBunTestFunction;\n readonly concurrent?: BaseBunTestFunction;\n readonly serial?: BaseBunTestFunction;\n readonly each?: AnyFunction;\n readonly if?: AnyFunction;\n readonly skipIf?: AnyFunction;\n readonly todoIf?: AnyFunction;\n};\n\nconst helperNames = [\n \"skip\",\n \"todo\",\n \"only\",\n \"failing\",\n \"concurrent\",\n \"serial\",\n] as const;\n\nconst conditionalHelperNames = [\n \"if\",\n \"skipIf\",\n \"todoIf\",\n] as const;\n\nconst expectTypeOf: ExpectTypeOfFunction = (\n bunTestModule as unknown as { readonly expectTypeOf: ExpectTypeOfFunction }\n).expectTypeOf;\nconst onTestFinished: OnTestFinishedFunction = (\n bunTestModule as unknown as {\n readonly onTestFinished: OnTestFinishedFunction;\n }\n).onTestFinished;\nconst vi: typeof jest =\n (bunTestModule as unknown as { readonly vi: typeof jest }).vi;\nconst xdescribe: BunFunction =\n (bunTestModule as unknown as { readonly xdescribe: BunFunction })\n .xdescribe;\nconst xit: BunFunction =\n (bunTestModule as unknown as { readonly xit: BunFunction }).xit;\nconst xtest: BunFunction = (bunTestModule as unknown as {\n readonly xtest: BunFunction;\n})\n .xtest;\n\n/**\n * Creates a `bun:test` test function that reports LogTape records from failed\n * test callbacks.\n *\n * The returned function preserves Bun test options and shorthand helpers such\n * as `test.skip()`, `test.todo()`, `test.only()`, `test.if()`,\n * `test.failing()`, `test.concurrent()`, `test.serial()`, and `test.each()`.\n * Only callback arguments are adapted; options are passed through to\n * `bun:test`.\n *\n * @param options Failure log reporter options.\n * @returns A configured `bun:test`-compatible test function.\n * @since 2.3.0\n */\nexport function createTest(\n options: FailureLogReporterOptions = {},\n): BunTestFunction {\n return createBunTestFunction(\n bunTest as unknown as BaseBunTestFunction,\n options,\n );\n}\n\n/**\n * Creates an `it()` alias that reports LogTape records from failed test\n * callbacks.\n *\n * @param options Failure log reporter options.\n * @returns A configured `bun:test`-compatible `it()` function.\n * @since 2.3.0\n */\nexport function createIt(\n options: FailureLogReporterOptions = {},\n): BunTestFunction {\n return createBunTestFunction(\n bunIt as unknown as BaseBunTestFunction,\n options,\n );\n}\n\n/**\n * A `bun:test` test function that reports LogTape records from failed test\n * callbacks using the default reporter options.\n *\n * @since 2.3.0\n */\nexport const test: BunTestFunction = createTest();\n\n/**\n * A `bun:test` `it()` alias that reports LogTape records from failed test\n * callbacks using the default reporter options.\n *\n * @since 2.3.0\n */\nexport const it: BunTestFunction = createIt();\n\n/**\n * Shorthand for skipping a test.\n *\n * @since 2.3.0\n */\nexport const skip: BunTestFunction = test.skip;\n\n/**\n * Shorthand for marking a test as TODO.\n *\n * @since 2.3.0\n */\nexport const todo: BunTestFunction = test.todo;\n\n/**\n * Shorthand for marking a test as `only`.\n *\n * @since 2.3.0\n */\nexport const only: BunTestFunction = test.only;\n\n/**\n * Shorthand for marking a test as expected to fail.\n *\n * @since 2.3.0\n */\nexport const failing: BunTestFunction = test.failing;\n\n/**\n * Shorthand for running a test concurrently.\n *\n * @since 2.3.0\n */\nexport const concurrent: BunTestFunction = test.concurrent;\n\n/**\n * Shorthand for running a test serially.\n *\n * @since 2.3.0\n */\nexport const serial: BunTestFunction = test.serial;\n\n/**\n * Shorthand for Bun's parameterized tests.\n *\n * @since 2.3.0\n */\nexport const each: BunEachFunction = test.each;\n\nexport default test;\n\nfunction createBunTestFunction(\n baseTest: BaseBunTestFunction,\n options: FailureLogReporterOptions,\n): BunTestFunction {\n const register: BunTestFunction = ((...args: unknown[]) =>\n Reflect.apply(\n baseTest,\n undefined,\n wrapBunTestArguments(args, options),\n )) as BunTestFunction;\n\n for (const helperName of helperNames) {\n const helper = getFunctionProperty(baseTest, helperName);\n if (helper == null) continue;\n Object.defineProperty(register, helperName, {\n configurable: true,\n enumerable: true,\n value: createBunTestFunction(\n helper as BaseBunTestFunction,\n options,\n ),\n writable: true,\n });\n }\n\n for (const helperName of conditionalHelperNames) {\n const helper = getFunctionProperty(baseTest, helperName);\n if (helper == null) continue;\n Object.defineProperty(register, helperName, {\n configurable: true,\n enumerable: true,\n value: ((condition: unknown) => {\n const conditionalTest = Reflect.apply(helper, baseTest, [condition]);\n return createBunTestFunction(\n conditionalTest as BaseBunTestFunction,\n options,\n );\n }) as BunConditionalTestFactory,\n writable: true,\n });\n }\n\n const each = getFunctionProperty(baseTest, \"each\");\n if (each != null) {\n Object.defineProperty(register, \"each\", {\n configurable: true,\n enumerable: true,\n value: createWrappedEach(baseTest, each, options),\n writable: true,\n });\n }\n\n return register;\n}\n\nfunction createWrappedEach(\n baseTest: BaseBunTestFunction,\n baseEach: AnyFunction,\n options: FailureLogReporterOptions,\n): BunEachFunction {\n return ((...cases: readonly unknown[]) => {\n const maxCaseArgumentCount = getMaxCaseArgumentCount(cases);\n const registerEach = Reflect.apply(baseEach, baseTest, cases);\n return ((...args: unknown[]) =>\n Reflect.apply(\n registerEach as AnyFunction,\n undefined,\n wrapBunEachArguments(args, options, maxCaseArgumentCount),\n )) as BunEachRegisterFunction;\n }) as BunEachFunction;\n}\n\nfunction wrapBunTestArguments(\n args: readonly unknown[],\n options: FailureLogReporterOptions,\n): unknown[] {\n const callbackIndex = args.findIndex((arg) => typeof arg === \"function\");\n if (callbackIndex < 0) return [...args];\n\n return [\n ...args.slice(0, callbackIndex),\n wrapBunTestCallback(args[callbackIndex] as AnyFunction, options),\n ...args.slice(callbackIndex + 1),\n ];\n}\n\nfunction wrapBunEachArguments(\n args: readonly unknown[],\n options: FailureLogReporterOptions,\n maxCaseArgumentCount: number,\n): unknown[] {\n const callbackIndex = args.findIndex((arg, index) =>\n index > 0 && typeof arg === \"function\"\n );\n if (callbackIndex < 0) return [...args];\n\n return [\n ...args.slice(0, callbackIndex),\n wrapBunEachCallback(\n args[callbackIndex] as AnyFunction,\n options,\n maxCaseArgumentCount,\n ),\n ...args.slice(callbackIndex + 1),\n ];\n}\n\nfunction wrapBunTestCallback(\n callback: AnyFunction,\n options: FailureLogReporterOptions,\n): AnyFunction {\n const reporter = createFailureLogReporter(options);\n\n if (callback.length >= 1) {\n return function (this: unknown, done: BunDoneCallback): void {\n const wrapped = reporter.wrap(() =>\n runBunDoneCallback(callback, this, [])\n );\n\n void wrapped().then(\n () => done(),\n (error: unknown) => done(error),\n );\n };\n }\n\n return function (this: unknown): unknown {\n return reporter.run(() => Reflect.apply(callback, this, []));\n };\n}\n\nfunction wrapBunEachCallback(\n callback: AnyFunction,\n options: FailureLogReporterOptions,\n maxCaseArgumentCount: number,\n): AnyFunction {\n const reporter = createFailureLogReporter(options);\n const invoke = (thisArg: unknown, args: readonly unknown[]): unknown =>\n runBunEachCallback(\n reporter,\n callback,\n thisArg,\n args,\n maxCaseArgumentCount,\n );\n\n return createArityPreservingFunction(callback.length, invoke);\n}\n\nfunction createArityPreservingFunction(\n length: number,\n invoke: BunEachInvoker,\n): AnyFunction {\n const parameters = Array.from(\n { length },\n (_, index) => `arg${index}`,\n ).join(\", \");\n const createFunction = Function(\n \"invoke\",\n `return function (${parameters}) {` +\n \" return invoke(this, Array.from(arguments));\" +\n \" };\",\n ) as (invoke: BunEachInvoker) => AnyFunction;\n return createFunction(invoke);\n}\n\nfunction runBunEachCallback(\n reporter: ReturnType<typeof createFailureLogReporter>,\n callback: AnyFunction,\n thisArg: unknown,\n args: readonly unknown[],\n maxCaseArgumentCount: number,\n): unknown {\n const lastArgument = args.at(-1);\n if (\n callback.length > maxCaseArgumentCount &&\n typeof lastArgument === \"function\"\n ) {\n const done = lastArgument as BunDoneCallback;\n void reporter.run(() =>\n runBunDoneCallback(callback, thisArg, args.slice(0, -1))\n ).then(\n () => done(),\n (error: unknown) => done(error),\n );\n return undefined;\n }\n\n return reporter.run(() => Reflect.apply(callback, thisArg, args));\n}\n\nfunction runBunDoneCallback(\n callback: AnyFunction,\n thisArg: unknown,\n args: readonly unknown[],\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n let callbackReturned = false;\n let doneCalled = false;\n let pendingDone = false;\n let pendingDoneError: unknown;\n let settled = false;\n const settle = (error?: unknown): void => {\n if (settled) return;\n settled = true;\n if (error == null) resolve();\n else reject(error);\n };\n const wrappedDone: BunDoneCallback = (error?: unknown) => {\n if (doneCalled) return;\n doneCalled = true;\n if (!callbackReturned) {\n pendingDone = true;\n pendingDoneError = error;\n return;\n }\n settle(error);\n };\n\n try {\n Reflect.apply(callback, thisArg, [...args, wrappedDone]);\n callbackReturned = true;\n if (pendingDone) settle(pendingDoneError);\n } catch (error) {\n callbackReturned = true;\n reject(error);\n }\n });\n}\n\nfunction getMaxCaseArgumentCount(cases: readonly unknown[]): number {\n const rows = cases.length === 1 && Array.isArray(cases[0])\n ? cases[0] as readonly unknown[]\n : cases;\n let maxArgumentCount = 0;\n for (const row of rows) {\n const argumentCount = Array.isArray(row) ? row.length : 1;\n maxArgumentCount = Math.max(maxArgumentCount, argumentCount);\n }\n return maxArgumentCount;\n}\n\nfunction getFunctionProperty(\n value: BaseBunTestFunction,\n property: string,\n): AnyFunction | undefined {\n try {\n const propertyValue = Reflect.get(value, property);\n return typeof propertyValue === \"function\" ? propertyValue : undefined;\n } catch {\n return undefined;\n }\n}\n","import { AsyncLocalStorage } from \"node:async_hooks\";\n\nimport {\n ConfigError,\n configureSync,\n type ContextLocalStorage,\n getConfig,\n} from \"@logtape/logtape\";\nimport {\n type FailureLogReporterOptions,\n getFailureLogReporterOptionsFromEnv,\n} from \"@logtape/testing/reporter\";\n\nimport {\n afterAll,\n afterEach,\n beforeAll,\n beforeEach,\n type BunTestFunction,\n createIt,\n createTest,\n describe,\n expect,\n expectTypeOf,\n jest,\n mock,\n onTestFinished,\n setDefaultTimeout,\n setSystemTime,\n spyOn,\n vi,\n xdescribe,\n xit,\n xtest,\n} from \"./mod.ts\";\n\nexport type {\n BunTestCallback,\n BunTestFunction,\n BunTestOptions,\n FailureLogReporterOptions,\n FailureLogReportMode,\n} from \"./mod.ts\";\n\nconst config = getConfig();\n\nif (config == null) {\n configureSync({\n contextLocalStorage: new AsyncLocalStorage() as ContextLocalStorage<\n Record<string, unknown>\n >,\n sinks: {},\n loggers: [\n { category: [\"logtape\", \"meta\"], sinks: [] },\n ],\n });\n} else if (config.contextLocalStorage == null) {\n throw new ConfigError(\n \"@logtape/testing-bun/autoload requires the existing LogTape \" +\n \"configuration to provide contextLocalStorage.\",\n );\n}\n\nconst reporterOptions: FailureLogReporterOptions =\n getFailureLogReporterOptionsFromEnv({\n getEnv: (name) => process.env[name],\n });\nconst test: BunTestFunction = createTest(reporterOptions);\nconst it: BunTestFunction = createIt(reporterOptions);\nconst concurrent: BunTestFunction[\"concurrent\"] = test.concurrent;\nconst each: BunTestFunction[\"each\"] = test.each;\nconst failing: BunTestFunction[\"failing\"] = test.failing;\nconst only: BunTestFunction[\"only\"] = test.only;\nconst serial: BunTestFunction[\"serial\"] = test.serial;\nconst skip: BunTestFunction[\"skip\"] = test.skip;\nconst todo: BunTestFunction[\"todo\"] = test.todo;\n\nexport {\n afterAll,\n afterEach,\n beforeAll,\n beforeEach,\n concurrent,\n createIt,\n createTest,\n describe,\n each,\n expect,\n expectTypeOf,\n failing,\n it,\n jest,\n mock,\n only,\n onTestFinished,\n serial,\n setDefaultTimeout,\n setSystemTime,\n skip,\n spyOn,\n test,\n todo,\n vi,\n xdescribe,\n xit,\n xtest,\n};\nexport default test;\n"],"mappings":";;;;;;;AA4IA,MAAM,cAAc;CAClB;CACA;CACA;CACA;CACA;CACA;AACD;AAED,MAAM,yBAAyB;CAC7B;CACA;CACA;AACD;AAED,MAAMA,eACJ,cACA;AACF,MAAMC,iBACJ,cAGA;AACF,MAAMC,KACH,cAA0D;AAC7D,MAAMC,YACH,cACE;AACL,MAAMC,MACH,cAA2D;AAC9D,MAAMC,QAAsB,cAGzB;;;;;;;;;;;;;;;AAgBH,SAAgB,WACdC,UAAqC,CAAE,GACtB;AACjB,QAAO,sBACLC,QACA,QACD;AACF;;;;;;;;;AAUD,SAAgB,SACdD,UAAqC,CAAE,GACtB;AACjB,QAAO,sBACLE,MACA,QACD;AACF;;;;;;;AAQD,MAAaC,SAAwB,YAAY;;;;;;;AAQjD,MAAaC,OAAsB,UAAU;;;;;;AAO7C,MAAaC,SAAwBC,OAAK;;;;;;AAO1C,MAAaC,SAAwBD,OAAK;;;;;;AAO1C,MAAaE,SAAwBF,OAAK;;;;;;AAO1C,MAAaG,YAA2BH,OAAK;;;;;;AAO7C,MAAaI,eAA8BJ,OAAK;;;;;;AAOhD,MAAaK,WAA0BL,OAAK;;;;;;AAO5C,MAAaM,SA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PC,OACAC,UACyB;AACzB,KAAI;EACF,MAAM,gBAAgB,QAAQ,IAAI,OAAO,SAAS;AAClD,gBAAc,kBAAkB,aAAa;CAC9C,QAAO;AACN;CACD;AACF;;;;AC1eD,MAAM,SAAS,WAAW;AAE1B,IAAI,UAAU,KACZ,eAAc;CACZ,qBAAqB,IAAI;CAGzB,OAAO,CAAE;CACT,SAAS,CACP;EAAE,UAAU,CAAC,WAAW,MAAO;EAAE,OAAO,CAAE;CAAE,CAC7C;AACF,EAAC;SACO,OAAO,uBAAuB,KACvC,OAAM,IAAI,YACR;AAKJ,MAAMC,kBACJ,oCAAoC,EAClC,QAAQ,CAAC,SAAS,QAAQ,IAAI,MAC/B,EAAC;AACJ,MAAMC,OAAwB,WAAW,gBAAgB;AACzD,MAAMC,KAAsB,SAAS,gBAAgB;AACrD,MAAMC,aAA4C,KAAK;AACvD,MAAMC,OAAgC,KAAK;AAC3C,MAAMC,UAAsC,KAAK;AACjD,MAAMC,OAAgC,KAAK;AAC3C,MAAMC,SAAoC,KAAK;AAC/C,MAAMC,OAAgC,KAAK;AAC3C,MAAMC,OAAgC,KAAK;AAgC3C,uBAAe"}
package/dist/mod.cjs CHANGED
@@ -144,8 +144,9 @@ function createBunTestFunction(baseTest, options) {
144
144
  }
145
145
  function createWrappedEach(baseTest, baseEach, options) {
146
146
  return (...cases) => {
147
+ const maxCaseArgumentCount = getMaxCaseArgumentCount(cases);
147
148
  const registerEach = Reflect.apply(baseEach, baseTest, cases);
148
- return (...args) => Reflect.apply(registerEach, void 0, wrapBunEachArguments(args, options));
149
+ return (...args) => Reflect.apply(registerEach, void 0, wrapBunEachArguments(args, options, maxCaseArgumentCount));
149
150
  };
150
151
  }
151
152
  function wrapBunTestArguments(args, options) {
@@ -157,43 +158,85 @@ function wrapBunTestArguments(args, options) {
157
158
  ...args.slice(callbackIndex + 1)
158
159
  ];
159
160
  }
160
- function wrapBunEachArguments(args, options) {
161
+ function wrapBunEachArguments(args, options, maxCaseArgumentCount) {
161
162
  const callbackIndex = args.findIndex((arg, index) => index > 0 && typeof arg === "function");
162
163
  if (callbackIndex < 0) return [...args];
163
164
  return [
164
165
  ...args.slice(0, callbackIndex),
165
- wrapBunEachCallback(args[callbackIndex], options),
166
+ wrapBunEachCallback(args[callbackIndex], options, maxCaseArgumentCount),
166
167
  ...args.slice(callbackIndex + 1)
167
168
  ];
168
169
  }
169
170
  function wrapBunTestCallback(callback, options) {
170
171
  const reporter = (0, __logtape_testing_reporter.createFailureLogReporter)(options);
171
172
  if (callback.length >= 1) return function(done) {
172
- const wrapped = reporter.wrap(() => new Promise((resolve, reject) => {
173
- let settled = false;
174
- const wrappedDone = (error) => {
175
- if (settled) return;
176
- settled = true;
177
- if (error == null) resolve();
178
- else reject(error);
179
- };
180
- try {
181
- Reflect.apply(callback, this, [wrappedDone]);
182
- } catch (error) {
183
- reject(error);
184
- }
185
- }));
173
+ const wrapped = reporter.wrap(() => runBunDoneCallback(callback, this, []));
186
174
  wrapped().then(() => done(), (error) => done(error));
187
175
  };
188
176
  return function() {
189
177
  return reporter.run(() => Reflect.apply(callback, this, []));
190
178
  };
191
179
  }
192
- function wrapBunEachCallback(callback, options) {
180
+ function wrapBunEachCallback(callback, options, maxCaseArgumentCount) {
193
181
  const reporter = (0, __logtape_testing_reporter.createFailureLogReporter)(options);
194
- return function(...args) {
195
- return reporter.run(() => Reflect.apply(callback, this, args));
196
- };
182
+ const invoke = (thisArg, args) => runBunEachCallback(reporter, callback, thisArg, args, maxCaseArgumentCount);
183
+ return createArityPreservingFunction(callback.length, invoke);
184
+ }
185
+ function createArityPreservingFunction(length, invoke) {
186
+ const parameters = Array.from({ length }, (_, index) => `arg${index}`).join(", ");
187
+ const createFunction = Function("invoke", `return function (${parameters}) { return invoke(this, Array.from(arguments)); };`);
188
+ return createFunction(invoke);
189
+ }
190
+ function runBunEachCallback(reporter, callback, thisArg, args, maxCaseArgumentCount) {
191
+ const lastArgument = args.at(-1);
192
+ if (callback.length > maxCaseArgumentCount && typeof lastArgument === "function") {
193
+ const done = lastArgument;
194
+ reporter.run(() => runBunDoneCallback(callback, thisArg, args.slice(0, -1))).then(() => done(), (error) => done(error));
195
+ return void 0;
196
+ }
197
+ return reporter.run(() => Reflect.apply(callback, thisArg, args));
198
+ }
199
+ function runBunDoneCallback(callback, thisArg, args) {
200
+ return new Promise((resolve, reject) => {
201
+ let callbackReturned = false;
202
+ let doneCalled = false;
203
+ let pendingDone = false;
204
+ let pendingDoneError;
205
+ let settled = false;
206
+ const settle = (error) => {
207
+ if (settled) return;
208
+ settled = true;
209
+ if (error == null) resolve();
210
+ else reject(error);
211
+ };
212
+ const wrappedDone = (error) => {
213
+ if (doneCalled) return;
214
+ doneCalled = true;
215
+ if (!callbackReturned) {
216
+ pendingDone = true;
217
+ pendingDoneError = error;
218
+ return;
219
+ }
220
+ settle(error);
221
+ };
222
+ try {
223
+ Reflect.apply(callback, thisArg, [...args, wrappedDone]);
224
+ callbackReturned = true;
225
+ if (pendingDone) settle(pendingDoneError);
226
+ } catch (error) {
227
+ callbackReturned = true;
228
+ reject(error);
229
+ }
230
+ });
231
+ }
232
+ function getMaxCaseArgumentCount(cases) {
233
+ const rows = cases.length === 1 && Array.isArray(cases[0]) ? cases[0] : cases;
234
+ let maxArgumentCount = 0;
235
+ for (const row of rows) {
236
+ const argumentCount = Array.isArray(row) ? row.length : 1;
237
+ maxArgumentCount = Math.max(maxArgumentCount, argumentCount);
238
+ }
239
+ return maxArgumentCount;
197
240
  }
198
241
  function getFunctionProperty(value, property) {
199
242
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.cts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;AAuDA;AAYA;AASA;;;;;;;AAGmC,UAxBlB,cAAA,CAwBkB;EAA2B,SAC7C,KAAA,CAAA,EAAA,MAAA;EAAe,SAAG,OAAA,CAAA,EAAA,MAAA;EAA2B,SAC7C,OAAA,CAAA,EAAA,MAAA;EAAe,UAAG,MAAA,EAA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A;AAOA;;;;;;;;;;;;iBAzFgB,UAAA,WACL,8BACR;;;;;;;;;iBAea,QAAA,WACL,8BACR;;;;;;;cAaU,MAAM;;;;;;;cAQN,IAAI;;;;;;cAOJ,MAAM;;;;;;cAON,MAAM;;;;;;cAON,MAAM;;;;;;cAON,SAAS;;;;;;cAOT,YAAY;;;;;;cAOZ,QAAQ;;;;;;cAOR,MAAM"}
package/dist/mod.js CHANGED
@@ -143,8 +143,9 @@ function createBunTestFunction(baseTest, options) {
143
143
  }
144
144
  function createWrappedEach(baseTest, baseEach, options) {
145
145
  return (...cases) => {
146
+ const maxCaseArgumentCount = getMaxCaseArgumentCount(cases);
146
147
  const registerEach = Reflect.apply(baseEach, baseTest, cases);
147
- return (...args) => Reflect.apply(registerEach, void 0, wrapBunEachArguments(args, options));
148
+ return (...args) => Reflect.apply(registerEach, void 0, wrapBunEachArguments(args, options, maxCaseArgumentCount));
148
149
  };
149
150
  }
150
151
  function wrapBunTestArguments(args, options) {
@@ -156,43 +157,85 @@ function wrapBunTestArguments(args, options) {
156
157
  ...args.slice(callbackIndex + 1)
157
158
  ];
158
159
  }
159
- function wrapBunEachArguments(args, options) {
160
+ function wrapBunEachArguments(args, options, maxCaseArgumentCount) {
160
161
  const callbackIndex = args.findIndex((arg, index) => index > 0 && typeof arg === "function");
161
162
  if (callbackIndex < 0) return [...args];
162
163
  return [
163
164
  ...args.slice(0, callbackIndex),
164
- wrapBunEachCallback(args[callbackIndex], options),
165
+ wrapBunEachCallback(args[callbackIndex], options, maxCaseArgumentCount),
165
166
  ...args.slice(callbackIndex + 1)
166
167
  ];
167
168
  }
168
169
  function wrapBunTestCallback(callback, options) {
169
170
  const reporter = createFailureLogReporter(options);
170
171
  if (callback.length >= 1) return function(done) {
171
- const wrapped = reporter.wrap(() => new Promise((resolve, reject) => {
172
- let settled = false;
173
- const wrappedDone = (error) => {
174
- if (settled) return;
175
- settled = true;
176
- if (error == null) resolve();
177
- else reject(error);
178
- };
179
- try {
180
- Reflect.apply(callback, this, [wrappedDone]);
181
- } catch (error) {
182
- reject(error);
183
- }
184
- }));
172
+ const wrapped = reporter.wrap(() => runBunDoneCallback(callback, this, []));
185
173
  wrapped().then(() => done(), (error) => done(error));
186
174
  };
187
175
  return function() {
188
176
  return reporter.run(() => Reflect.apply(callback, this, []));
189
177
  };
190
178
  }
191
- function wrapBunEachCallback(callback, options) {
179
+ function wrapBunEachCallback(callback, options, maxCaseArgumentCount) {
192
180
  const reporter = createFailureLogReporter(options);
193
- return function(...args) {
194
- return reporter.run(() => Reflect.apply(callback, this, args));
195
- };
181
+ const invoke = (thisArg, args) => runBunEachCallback(reporter, callback, thisArg, args, maxCaseArgumentCount);
182
+ return createArityPreservingFunction(callback.length, invoke);
183
+ }
184
+ function createArityPreservingFunction(length, invoke) {
185
+ const parameters = Array.from({ length }, (_, index) => `arg${index}`).join(", ");
186
+ const createFunction = Function("invoke", `return function (${parameters}) { return invoke(this, Array.from(arguments)); };`);
187
+ return createFunction(invoke);
188
+ }
189
+ function runBunEachCallback(reporter, callback, thisArg, args, maxCaseArgumentCount) {
190
+ const lastArgument = args.at(-1);
191
+ if (callback.length > maxCaseArgumentCount && typeof lastArgument === "function") {
192
+ const done = lastArgument;
193
+ reporter.run(() => runBunDoneCallback(callback, thisArg, args.slice(0, -1))).then(() => done(), (error) => done(error));
194
+ return void 0;
195
+ }
196
+ return reporter.run(() => Reflect.apply(callback, thisArg, args));
197
+ }
198
+ function runBunDoneCallback(callback, thisArg, args) {
199
+ return new Promise((resolve, reject) => {
200
+ let callbackReturned = false;
201
+ let doneCalled = false;
202
+ let pendingDone = false;
203
+ let pendingDoneError;
204
+ let settled = false;
205
+ const settle = (error) => {
206
+ if (settled) return;
207
+ settled = true;
208
+ if (error == null) resolve();
209
+ else reject(error);
210
+ };
211
+ const wrappedDone = (error) => {
212
+ if (doneCalled) return;
213
+ doneCalled = true;
214
+ if (!callbackReturned) {
215
+ pendingDone = true;
216
+ pendingDoneError = error;
217
+ return;
218
+ }
219
+ settle(error);
220
+ };
221
+ try {
222
+ Reflect.apply(callback, thisArg, [...args, wrappedDone]);
223
+ callbackReturned = true;
224
+ if (pendingDone) settle(pendingDoneError);
225
+ } catch (error) {
226
+ callbackReturned = true;
227
+ reject(error);
228
+ }
229
+ });
230
+ }
231
+ function getMaxCaseArgumentCount(cases) {
232
+ const rows = cases.length === 1 && Array.isArray(cases[0]) ? cases[0] : cases;
233
+ let maxArgumentCount = 0;
234
+ for (const row of rows) {
235
+ const argumentCount = Array.isArray(row) ? row.length : 1;
236
+ maxArgumentCount = Math.max(maxArgumentCount, argumentCount);
237
+ }
238
+ return maxArgumentCount;
196
239
  }
197
240
  function getFunctionProperty(value, property) {
198
241
  try {
package/dist/mod.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.js","names":["expectTypeOf: ExpectTypeOfFunction","onTestFinished: OnTestFinishedFunction","vi: typeof jest","xdescribe: BunFunction","xit: BunFunction","xtest: BunFunction","options: FailureLogReporterOptions","bunTest","bunIt","test: BunTestFunction","it: BunTestFunction","skip: BunTestFunction","todo: BunTestFunction","only: BunTestFunction","failing: BunTestFunction","concurrent: BunTestFunction","serial: BunTestFunction","each: BunEachFunction","baseTest: BaseBunTestFunction","condition: unknown","each","baseEach: AnyFunction","args: readonly unknown[]","callback: AnyFunction","done: BunDoneCallback","wrappedDone: BunDoneCallback","error?: unknown","error: unknown","value: BaseBunTestFunction","property: string"],"sources":["../src/mod.ts"],"sourcesContent":["import {\n afterAll,\n afterEach,\n beforeAll,\n beforeEach,\n describe,\n expect,\n it as bunIt,\n jest,\n mock,\n setDefaultTimeout,\n setSystemTime,\n spyOn,\n test as bunTest,\n} from \"bun:test\";\nimport * as bunTestModule from \"bun:test\";\n\nimport {\n createFailureLogReporter,\n type FailureLogReporterOptions,\n} from \"@logtape/testing/reporter\";\n\nexport type {\n FailureLogReporterOptions,\n FailureLogReportMode,\n} from \"@logtape/testing/reporter\";\nexport {\n afterAll,\n afterEach,\n beforeAll,\n beforeEach,\n describe,\n expect,\n expectTypeOf,\n jest,\n mock,\n onTestFinished,\n setDefaultTimeout,\n setSystemTime,\n spyOn,\n vi,\n xdescribe,\n xit,\n xtest,\n};\n\n/**\n * Options accepted by Bun's `test()` and `it()` functions.\n *\n * The shape mirrors Bun's documented option bag while allowing newer Bun\n * options to pass through even when bundled TypeScript declarations lag behind\n * the current runtime.\n *\n * @since 2.3.0\n */\nexport interface BunTestOptions {\n readonly retry?: number;\n readonly repeats?: number;\n readonly timeout?: number;\n readonly [option: string]: unknown;\n}\n\n/**\n * A callback passed to Bun's `test()` or `it()`.\n *\n * @since 2.3.0\n */\nexport type BunTestCallback =\n | (() => unknown)\n | ((done: BunDoneCallback) => unknown);\n\n/**\n * A Bun `test()`-compatible function.\n *\n * @since 2.3.0\n */\nexport interface BunTestFunction {\n (name: string, fn?: BunTestCallback, options?: number | BunTestOptions): void;\n (name: string, options: number | BunTestOptions, fn?: BunTestCallback): void;\n readonly skip: BunTestFunction & BunParameterizedTestFactory;\n readonly todo: BunTestFunction & BunParameterizedTestFactory;\n readonly only: BunTestFunction & BunParameterizedTestFactory;\n readonly failing: BunTestFunction & BunParameterizedTestFactory;\n readonly concurrent: BunTestFunction & BunParameterizedTestFactory;\n readonly serial: BunTestFunction & BunParameterizedTestFactory;\n readonly each: BunEachFunction;\n readonly if: BunConditionalTestFactory;\n readonly skipIf: BunConditionalTestFactory;\n readonly todoIf: BunConditionalTestFactory;\n}\n\ninterface BunParameterizedTestFactory {\n readonly each: BunEachFunction;\n}\n\ninterface BunConditionalTestFactory {\n (condition: unknown): BunTestFunction & BunParameterizedTestFactory;\n}\n\ninterface BunEachFunction {\n (...cases: readonly unknown[]): BunEachRegisterFunction;\n}\n\ninterface BunEachRegisterFunction {\n (\n name: string,\n fn: (...args: never[]) => unknown,\n options?: number | BunTestOptions,\n ): void;\n (\n name: string,\n options: number | BunTestOptions,\n fn: (...args: never[]) => unknown,\n ): void;\n}\n\ntype BunDoneCallback = (error?: unknown) => void;\ntype AnyFunction = (...args: never[]) => unknown;\ntype BunFunction = (...args: unknown[]) => unknown;\ntype ExpectTypeOfFunction = (...args: unknown[]) => unknown;\ntype OnTestFinishedFunction = (callback: () => unknown) => void;\ntype BaseBunTestFunction = AnyFunction & {\n readonly skip?: BaseBunTestFunction;\n readonly todo?: BaseBunTestFunction;\n readonly only?: BaseBunTestFunction;\n readonly failing?: BaseBunTestFunction;\n readonly concurrent?: BaseBunTestFunction;\n readonly serial?: BaseBunTestFunction;\n readonly each?: AnyFunction;\n readonly if?: AnyFunction;\n readonly skipIf?: AnyFunction;\n readonly todoIf?: AnyFunction;\n};\n\nconst helperNames = [\n \"skip\",\n \"todo\",\n \"only\",\n \"failing\",\n \"concurrent\",\n \"serial\",\n] as const;\n\nconst conditionalHelperNames = [\n \"if\",\n \"skipIf\",\n \"todoIf\",\n] as const;\n\nconst expectTypeOf: ExpectTypeOfFunction = (\n bunTestModule as unknown as { readonly expectTypeOf: ExpectTypeOfFunction }\n).expectTypeOf;\nconst onTestFinished: OnTestFinishedFunction = (\n bunTestModule as unknown as {\n readonly onTestFinished: OnTestFinishedFunction;\n }\n).onTestFinished;\nconst vi: typeof jest =\n (bunTestModule as unknown as { readonly vi: typeof jest }).vi;\nconst xdescribe: BunFunction =\n (bunTestModule as unknown as { readonly xdescribe: BunFunction })\n .xdescribe;\nconst xit: BunFunction =\n (bunTestModule as unknown as { readonly xit: BunFunction }).xit;\nconst xtest: BunFunction = (bunTestModule as unknown as {\n readonly xtest: BunFunction;\n})\n .xtest;\n\n/**\n * Creates a `bun:test` test function that reports LogTape records from failed\n * test callbacks.\n *\n * The returned function preserves Bun test options and shorthand helpers such\n * as `test.skip()`, `test.todo()`, `test.only()`, `test.if()`,\n * `test.failing()`, `test.concurrent()`, `test.serial()`, and `test.each()`.\n * Only callback arguments are adapted; options are passed through to\n * `bun:test`.\n *\n * @param options Failure log reporter options.\n * @returns A configured `bun:test`-compatible test function.\n * @since 2.3.0\n */\nexport function createTest(\n options: FailureLogReporterOptions = {},\n): BunTestFunction {\n return createBunTestFunction(\n bunTest as unknown as BaseBunTestFunction,\n options,\n );\n}\n\n/**\n * Creates an `it()` alias that reports LogTape records from failed test\n * callbacks.\n *\n * @param options Failure log reporter options.\n * @returns A configured `bun:test`-compatible `it()` function.\n * @since 2.3.0\n */\nexport function createIt(\n options: FailureLogReporterOptions = {},\n): BunTestFunction {\n return createBunTestFunction(\n bunIt as unknown as BaseBunTestFunction,\n options,\n );\n}\n\n/**\n * A `bun:test` test function that reports LogTape records from failed test\n * callbacks using the default reporter options.\n *\n * @since 2.3.0\n */\nexport const test: BunTestFunction = createTest();\n\n/**\n * A `bun:test` `it()` alias that reports LogTape records from failed test\n * callbacks using the default reporter options.\n *\n * @since 2.3.0\n */\nexport const it: BunTestFunction = createIt();\n\n/**\n * Shorthand for skipping a test.\n *\n * @since 2.3.0\n */\nexport const skip: BunTestFunction = test.skip;\n\n/**\n * Shorthand for marking a test as TODO.\n *\n * @since 2.3.0\n */\nexport const todo: BunTestFunction = test.todo;\n\n/**\n * Shorthand for marking a test as `only`.\n *\n * @since 2.3.0\n */\nexport const only: BunTestFunction = test.only;\n\n/**\n * Shorthand for marking a test as expected to fail.\n *\n * @since 2.3.0\n */\nexport const failing: BunTestFunction = test.failing;\n\n/**\n * Shorthand for running a test concurrently.\n *\n * @since 2.3.0\n */\nexport const concurrent: BunTestFunction = test.concurrent;\n\n/**\n * Shorthand for running a test serially.\n *\n * @since 2.3.0\n */\nexport const serial: BunTestFunction = test.serial;\n\n/**\n * Shorthand for Bun's parameterized tests.\n *\n * @since 2.3.0\n */\nexport const each: BunEachFunction = test.each;\n\nexport default test;\n\nfunction createBunTestFunction(\n baseTest: BaseBunTestFunction,\n options: FailureLogReporterOptions,\n): BunTestFunction {\n const register = ((...args: unknown[]) =>\n Reflect.apply(\n baseTest,\n undefined,\n wrapBunTestArguments(args, options),\n )) as BunTestFunction;\n\n for (const helperName of helperNames) {\n const helper = getFunctionProperty(baseTest, helperName);\n if (helper == null) continue;\n Object.defineProperty(register, helperName, {\n configurable: true,\n enumerable: true,\n value: createBunTestFunction(\n helper as BaseBunTestFunction,\n options,\n ),\n writable: true,\n });\n }\n\n for (const helperName of conditionalHelperNames) {\n const helper = getFunctionProperty(baseTest, helperName);\n if (helper == null) continue;\n Object.defineProperty(register, helperName, {\n configurable: true,\n enumerable: true,\n value: ((condition: unknown) => {\n const conditionalTest = Reflect.apply(helper, baseTest, [condition]);\n return createBunTestFunction(\n conditionalTest as BaseBunTestFunction,\n options,\n );\n }) as BunConditionalTestFactory,\n writable: true,\n });\n }\n\n const each = getFunctionProperty(baseTest, \"each\");\n if (each != null) {\n Object.defineProperty(register, \"each\", {\n configurable: true,\n enumerable: true,\n value: createWrappedEach(baseTest, each, options),\n writable: true,\n });\n }\n\n return register;\n}\n\nfunction createWrappedEach(\n baseTest: BaseBunTestFunction,\n baseEach: AnyFunction,\n options: FailureLogReporterOptions,\n): BunEachFunction {\n return ((...cases: readonly unknown[]) => {\n const registerEach = Reflect.apply(baseEach, baseTest, cases);\n return ((...args: unknown[]) =>\n Reflect.apply(\n registerEach as AnyFunction,\n undefined,\n wrapBunEachArguments(args, options),\n )) as BunEachRegisterFunction;\n }) as BunEachFunction;\n}\n\nfunction wrapBunTestArguments(\n args: readonly unknown[],\n options: FailureLogReporterOptions,\n): unknown[] {\n const callbackIndex = args.findIndex((arg) => typeof arg === \"function\");\n if (callbackIndex < 0) return [...args];\n\n return [\n ...args.slice(0, callbackIndex),\n wrapBunTestCallback(args[callbackIndex] as AnyFunction, options),\n ...args.slice(callbackIndex + 1),\n ];\n}\n\nfunction wrapBunEachArguments(\n args: readonly unknown[],\n options: FailureLogReporterOptions,\n): unknown[] {\n const callbackIndex = args.findIndex((arg, index) =>\n index > 0 && typeof arg === \"function\"\n );\n if (callbackIndex < 0) return [...args];\n\n return [\n ...args.slice(0, callbackIndex),\n wrapBunEachCallback(args[callbackIndex] as AnyFunction, options),\n ...args.slice(callbackIndex + 1),\n ];\n}\n\nfunction wrapBunTestCallback(\n callback: AnyFunction,\n options: FailureLogReporterOptions,\n): AnyFunction {\n const reporter = createFailureLogReporter(options);\n\n if (callback.length >= 1) {\n return function (this: unknown, done: BunDoneCallback): void {\n const wrapped = reporter.wrap(() =>\n new Promise<void>((resolve, reject) => {\n let settled = false;\n const wrappedDone: BunDoneCallback = (error?: unknown) => {\n if (settled) return;\n settled = true;\n if (error == null) resolve();\n else reject(error);\n };\n\n try {\n Reflect.apply(callback, this, [wrappedDone]);\n } catch (error) {\n reject(error);\n }\n })\n );\n\n void wrapped().then(\n () => done(),\n (error: unknown) => done(error),\n );\n };\n }\n\n return function (this: unknown): Promise<unknown> {\n return reporter.run(() => Reflect.apply(callback, this, []));\n };\n}\n\nfunction wrapBunEachCallback(\n callback: AnyFunction,\n options: FailureLogReporterOptions,\n): AnyFunction {\n const reporter = createFailureLogReporter(options);\n return function (this: unknown, ...args: never[]) {\n return reporter.run(() => Reflect.apply(callback, this, args));\n };\n}\n\nfunction getFunctionProperty(\n value: BaseBunTestFunction,\n property: string,\n): AnyFunction | undefined {\n try {\n const propertyValue = Reflect.get(value, property);\n return typeof propertyValue === \"function\" ? propertyValue : undefined;\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;;;AAsIA,MAAM,cAAc;CAClB;CACA;CACA;CACA;CACA;CACA;AACD;AAED,MAAM,yBAAyB;CAC7B;CACA;CACA;AACD;AAED,MAAMA,eACJ,cACA;AACF,MAAMC,iBACJ,cAGA;AACF,MAAMC,KACH,cAA0D;AAC7D,MAAMC,YACH,cACE;AACL,MAAMC,MACH,cAA2D;AAC9D,MAAMC,QAAsB,cAGzB;;;;;;;;;;;;;;;AAgBH,SAAgB,WACdC,UAAqC,CAAE,GACtB;AACjB,QAAO,sBACLC,QACA,QACD;AACF;;;;;;;;;AAUD,SAAgB,SACdD,UAAqC,CAAE,GACtB;AACjB,QAAO,sBACLE,MACA,QACD;AACF;;;;;;;AAQD,MAAaC,OAAw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AAE,EAAC,CAAC;CAC7D;AACF;AAED,SAAS,oBACPJ,UACAjB,SACa;CACb,MAAM,WAAW,yBAAyB,QAAQ;AAClD,QAAO,SAAyB,GAAG,MAAe;AAChD,SAAO,SAAS,IAAI,MAAM,QAAQ,MAAM,UAAU,MAAM,KAAK,CAAC;CAC/D;AACF;AAED,SAAS,oBACPsB,OACAC,UACyB;AACzB,KAAI;EACF,MAAM,gBAAgB,QAAQ,IAAI,OAAO,SAAS;AAClD,gBAAc,kBAAkB,aAAa;CAC9C,QAAO;AACN;CACD;AACF"}
1
+ {"version":3,"file":"mod.js","names":["expectTypeOf: ExpectTypeOfFunction","onTestFinished: OnTestFinishedFunction","vi: typeof jest","xdescribe: BunFunction","xit: BunFunction","xtest: BunFunction","options: FailureLogReporterOptions","bunTest","bunIt","test: BunTestFunction","it: BunTestFunction","skip: BunTestFunction","todo: BunTestFunction","only: BunTestFunction","failing: BunTestFunction","concurrent: BunTestFunction","serial: BunTestFunction","each: BunEachFunction","baseTest: BaseBunTestFunction","register: BunTestFunction","condition: unknown","each","baseEach: AnyFunction","args: readonly unknown[]","maxCaseArgumentCount: number","callback: AnyFunction","done: BunDoneCallback","error: unknown","thisArg: unknown","length: number","invoke: BunEachInvoker","reporter: ReturnType<typeof createFailureLogReporter>","pendingDoneError: unknown","error?: unknown","wrappedDone: BunDoneCallback","cases: readonly unknown[]","value: BaseBunTestFunction","property: string"],"sources":["../src/mod.ts"],"sourcesContent":["// @ts-types=\"npm:@types/bun@^1.2.15\"\nimport {\n afterAll,\n afterEach,\n beforeAll,\n beforeEach,\n describe,\n expect,\n it as bunIt,\n jest,\n mock,\n setDefaultTimeout,\n setSystemTime,\n spyOn,\n test as bunTest,\n} from \"bun:test\";\n// @ts-types=\"npm:@types/bun@^1.2.15\"\nimport * as bunTestModule from \"bun:test\";\n\nimport {\n createFailureLogReporter,\n type FailureLogReporterOptions,\n} from \"@logtape/testing/reporter\";\n\nexport type {\n FailureLogReporterOptions,\n FailureLogReportMode,\n} from \"@logtape/testing/reporter\";\nexport {\n afterAll,\n afterEach,\n beforeAll,\n beforeEach,\n describe,\n expect,\n expectTypeOf,\n jest,\n mock,\n onTestFinished,\n setDefaultTimeout,\n setSystemTime,\n spyOn,\n vi,\n xdescribe,\n xit,\n xtest,\n};\n\n/**\n * Options accepted by Bun's `test()` and `it()` functions.\n *\n * The shape mirrors Bun's documented option bag while allowing newer Bun\n * options to pass through even when bundled TypeScript declarations lag behind\n * the current runtime.\n *\n * @since 2.3.0\n */\nexport interface BunTestOptions {\n readonly retry?: number;\n readonly repeats?: number;\n readonly timeout?: number;\n readonly [option: string]: unknown;\n}\n\n/**\n * A callback passed to Bun's `test()` or `it()`.\n *\n * @since 2.3.0\n */\nexport type BunTestCallback =\n | (() => unknown)\n | ((done: BunDoneCallback) => unknown);\n\n/**\n * A Bun `test()`-compatible function.\n *\n * @since 2.3.0\n */\nexport interface BunTestFunction {\n (name: string, fn?: BunTestCallback, options?: number | BunTestOptions): void;\n (name: string, options: number | BunTestOptions, fn?: BunTestCallback): void;\n readonly skip: BunTestFunction & BunParameterizedTestFactory;\n readonly todo: BunTestFunction & BunParameterizedTestFactory;\n readonly only: BunTestFunction & BunParameterizedTestFactory;\n readonly failing: BunTestFunction & BunParameterizedTestFactory;\n readonly concurrent: BunTestFunction & BunParameterizedTestFactory;\n readonly serial: BunTestFunction & BunParameterizedTestFactory;\n readonly each: BunEachFunction;\n readonly if: BunConditionalTestFactory;\n readonly skipIf: BunConditionalTestFactory;\n readonly todoIf: BunConditionalTestFactory;\n}\n\ninterface BunParameterizedTestFactory {\n readonly each: BunEachFunction;\n}\n\ninterface BunConditionalTestFactory {\n (condition: unknown): BunTestFunction & BunParameterizedTestFactory;\n}\n\ninterface BunEachFunction {\n (...cases: readonly unknown[]): BunEachRegisterFunction;\n}\n\ninterface BunEachRegisterFunction {\n (\n name: string,\n fn: (...args: never[]) => unknown,\n options?: number | BunTestOptions,\n ): void;\n (\n name: string,\n options: number | BunTestOptions,\n fn: (...args: never[]) => unknown,\n ): void;\n}\n\ntype BunDoneCallback = (error?: unknown) => void;\ntype AnyFunction = (...args: never[]) => unknown;\ntype BunFunction = (...args: unknown[]) => unknown;\ntype BunEachInvoker = (\n thisArg: unknown,\n args: readonly unknown[],\n) => unknown;\ntype ExpectTypeOfFunction = (...args: unknown[]) => unknown;\ntype OnTestFinishedFunction = (callback: () => unknown) => void;\ntype BaseBunTestFunction = AnyFunction & {\n readonly skip?: BaseBunTestFunction;\n readonly todo?: BaseBunTestFunction;\n readonly only?: BaseBunTestFunction;\n readonly failing?: BaseBunTestFunction;\n readonly concurrent?: BaseBunTestFunction;\n readonly serial?: BaseBunTestFunction;\n readonly each?: AnyFunction;\n readonly if?: AnyFunction;\n readonly skipIf?: AnyFunction;\n readonly todoIf?: AnyFunction;\n};\n\nconst helperNames = [\n \"skip\",\n \"todo\",\n \"only\",\n \"failing\",\n \"concurrent\",\n \"serial\",\n] as const;\n\nconst conditionalHelperNames = [\n \"if\",\n \"skipIf\",\n \"todoIf\",\n] as const;\n\nconst expectTypeOf: ExpectTypeOfFunction = (\n bunTestModule as unknown as { readonly expectTypeOf: ExpectTypeOfFunction }\n).expectTypeOf;\nconst onTestFinished: OnTestFinishedFunction = (\n bunTestModule as unknown as {\n readonly onTestFinished: OnTestFinishedFunction;\n }\n).onTestFinished;\nconst vi: typeof jest =\n (bunTestModule as unknown as { readonly vi: typeof jest }).vi;\nconst xdescribe: BunFunction =\n (bunTestModule as unknown as { readonly xdescribe: BunFunction })\n .xdescribe;\nconst xit: BunFunction =\n (bunTestModule as unknown as { readonly xit: BunFunction }).xit;\nconst xtest: BunFunction = (bunTestModule as unknown as {\n readonly xtest: BunFunction;\n})\n .xtest;\n\n/**\n * Creates a `bun:test` test function that reports LogTape records from failed\n * test callbacks.\n *\n * The returned function preserves Bun test options and shorthand helpers such\n * as `test.skip()`, `test.todo()`, `test.only()`, `test.if()`,\n * `test.failing()`, `test.concurrent()`, `test.serial()`, and `test.each()`.\n * Only callback arguments are adapted; options are passed through to\n * `bun:test`.\n *\n * @param options Failure log reporter options.\n * @returns A configured `bun:test`-compatible test function.\n * @since 2.3.0\n */\nexport function createTest(\n options: FailureLogReporterOptions = {},\n): BunTestFunction {\n return createBunTestFunction(\n bunTest as unknown as BaseBunTestFunction,\n options,\n );\n}\n\n/**\n * Creates an `it()` alias that reports LogTape records from failed test\n * callbacks.\n *\n * @param options Failure log reporter options.\n * @returns A configured `bun:test`-compatible `it()` function.\n * @since 2.3.0\n */\nexport function createIt(\n options: FailureLogReporterOptions = {},\n): BunTestFunction {\n return createBunTestFunction(\n bunIt as unknown as BaseBunTestFunction,\n options,\n );\n}\n\n/**\n * A `bun:test` test function that reports LogTape records from failed test\n * callbacks using the default reporter options.\n *\n * @since 2.3.0\n */\nexport const test: BunTestFunction = createTest();\n\n/**\n * A `bun:test` `it()` alias that reports LogTape records from failed test\n * callbacks using the default reporter options.\n *\n * @since 2.3.0\n */\nexport const it: BunTestFunction = createIt();\n\n/**\n * Shorthand for skipping a test.\n *\n * @since 2.3.0\n */\nexport const skip: BunTestFunction = test.skip;\n\n/**\n * Shorthand for marking a test as TODO.\n *\n * @since 2.3.0\n */\nexport const todo: BunTestFunction = test.todo;\n\n/**\n * Shorthand for marking a test as `only`.\n *\n * @since 2.3.0\n */\nexport const only: BunTestFunction = test.only;\n\n/**\n * Shorthand for marking a test as expected to fail.\n *\n * @since 2.3.0\n */\nexport const failing: BunTestFunction = test.failing;\n\n/**\n * Shorthand for running a test concurrently.\n *\n * @since 2.3.0\n */\nexport const concurrent: BunTestFunction = test.concurrent;\n\n/**\n * Shorthand for running a test serially.\n *\n * @since 2.3.0\n */\nexport const serial: BunTestFunction = test.serial;\n\n/**\n * Shorthand for Bun's parameterized tests.\n *\n * @since 2.3.0\n */\nexport const each: BunEachFunction = test.each;\n\nexport default test;\n\nfunction createBunTestFunction(\n baseTest: BaseBunTestFunction,\n options: FailureLogReporterOptions,\n): BunTestFunction {\n const register: BunTestFunction = ((...args: unknown[]) =>\n Reflect.apply(\n baseTest,\n undefined,\n wrapBunTestArguments(args, options),\n )) as BunTestFunction;\n\n for (const helperName of helperNames) {\n const helper = getFunctionProperty(baseTest, helperName);\n if (helper == null) continue;\n Object.defineProperty(register, helperName, {\n configurable: true,\n enumerable: true,\n value: createBunTestFunction(\n helper as BaseBunTestFunction,\n options,\n ),\n writable: true,\n });\n }\n\n for (const helperName of conditionalHelperNames) {\n const helper = getFunctionProperty(baseTest, helperName);\n if (helper == null) continue;\n Object.defineProperty(register, helperName, {\n configurable: true,\n enumerable: true,\n value: ((condition: unknown) => {\n const conditionalTest = Reflect.apply(helper, baseTest, [condition]);\n return createBunTestFunction(\n conditionalTest as BaseBunTestFunction,\n options,\n );\n }) as BunConditionalTestFactory,\n writable: true,\n });\n }\n\n const each = getFunctionProperty(baseTest, \"each\");\n if (each != null) {\n Object.defineProperty(register, \"each\", {\n configurable: true,\n enumerable: true,\n value: createWrappedEach(baseTest, each, options),\n writable: true,\n });\n }\n\n return register;\n}\n\nfunction createWrappedEach(\n baseTest: BaseBunTestFunction,\n baseEach: AnyFunction,\n options: FailureLogReporterOptions,\n): BunEachFunction {\n return ((...cases: readonly unknown[]) => {\n const maxCaseArgumentCount = getMaxCaseArgumentCount(cases);\n const registerEach = Reflect.apply(baseEach, baseTest, cases);\n return ((...args: unknown[]) =>\n Reflect.apply(\n registerEach as AnyFunction,\n undefined,\n wrapBunEachArguments(args, options, maxCaseArgumentCount),\n )) as BunEachRegisterFunction;\n }) as BunEachFunction;\n}\n\nfunction wrapBunTestArguments(\n args: readonly unknown[],\n options: FailureLogReporterOptions,\n): unknown[] {\n const callbackIndex = args.findIndex((arg) => typeof arg === \"function\");\n if (callbackIndex < 0) return [...args];\n\n return [\n ...args.slice(0, callbackIndex),\n wrapBunTestCallback(args[callbackIndex] as AnyFunction, options),\n ...args.slice(callbackIndex + 1),\n ];\n}\n\nfunction wrapBunEachArguments(\n args: readonly unknown[],\n options: FailureLogReporterOptions,\n maxCaseArgumentCount: number,\n): unknown[] {\n const callbackIndex = args.findIndex((arg, index) =>\n index > 0 && typeof arg === \"function\"\n );\n if (callbackIndex < 0) return [...args];\n\n return [\n ...args.slice(0, callbackIndex),\n wrapBunEachCallback(\n args[callbackIndex] as AnyFunction,\n options,\n maxCaseArgumentCount,\n ),\n ...args.slice(callbackIndex + 1),\n ];\n}\n\nfunction wrapBunTestCallback(\n callback: AnyFunction,\n options: FailureLogReporterOptions,\n): AnyFunction {\n const reporter = createFailureLogReporter(options);\n\n if (callback.length >= 1) {\n return function (this: unknown, done: BunDoneCallback): void {\n const wrapped = reporter.wrap(() =>\n runBunDoneCallback(callback, this, [])\n );\n\n void wrapped().then(\n () => done(),\n (error: unknown) => done(error),\n );\n };\n }\n\n return function (this: unknown): unknown {\n return reporter.run(() => Reflect.apply(callback, this, []));\n };\n}\n\nfunction wrapBunEachCallback(\n callback: AnyFunction,\n options: FailureLogReporterOptions,\n maxCaseArgumentCount: number,\n): AnyFunction {\n const reporter = createFailureLogReporter(options);\n const invoke = (thisArg: unknown, args: readonly unknown[]): unknown =>\n runBunEachCallback(\n reporter,\n callback,\n thisArg,\n args,\n maxCaseArgumentCount,\n );\n\n return createArityPreservingFunction(callback.length, invoke);\n}\n\nfunction createArityPreservingFunction(\n length: number,\n invoke: BunEachInvoker,\n): AnyFunction {\n const parameters = Array.from(\n { length },\n (_, index) => `arg${index}`,\n ).join(\", \");\n const createFunction = Function(\n \"invoke\",\n `return function (${parameters}) {` +\n \" return invoke(this, Array.from(arguments));\" +\n \" };\",\n ) as (invoke: BunEachInvoker) => AnyFunction;\n return createFunction(invoke);\n}\n\nfunction runBunEachCallback(\n reporter: ReturnType<typeof createFailureLogReporter>,\n callback: AnyFunction,\n thisArg: unknown,\n args: readonly unknown[],\n maxCaseArgumentCount: number,\n): unknown {\n const lastArgument = args.at(-1);\n if (\n callback.length > maxCaseArgumentCount &&\n typeof lastArgument === \"function\"\n ) {\n const done = lastArgument as BunDoneCallback;\n void reporter.run(() =>\n runBunDoneCallback(callback, thisArg, args.slice(0, -1))\n ).then(\n () => done(),\n (error: unknown) => done(error),\n );\n return undefined;\n }\n\n return reporter.run(() => Reflect.apply(callback, thisArg, args));\n}\n\nfunction runBunDoneCallback(\n callback: AnyFunction,\n thisArg: unknown,\n args: readonly unknown[],\n): Promise<void> {\n return new Promise<void>((resolve, reject) => {\n let callbackReturned = false;\n let doneCalled = false;\n let pendingDone = false;\n let pendingDoneError: unknown;\n let settled = false;\n const settle = (error?: unknown): void => {\n if (settled) return;\n settled = true;\n if (error == null) resolve();\n else reject(error);\n };\n const wrappedDone: BunDoneCallback = (error?: unknown) => {\n if (doneCalled) return;\n doneCalled = true;\n if (!callbackReturned) {\n pendingDone = true;\n pendingDoneError = error;\n return;\n }\n settle(error);\n };\n\n try {\n Reflect.apply(callback, thisArg, [...args, wrappedDone]);\n callbackReturned = true;\n if (pendingDone) settle(pendingDoneError);\n } catch (error) {\n callbackReturned = true;\n reject(error);\n }\n });\n}\n\nfunction getMaxCaseArgumentCount(cases: readonly unknown[]): number {\n const rows = cases.length === 1 && Array.isArray(cases[0])\n ? cases[0] as readonly unknown[]\n : cases;\n let maxArgumentCount = 0;\n for (const row of rows) {\n const argumentCount = Array.isArray(row) ? row.length : 1;\n maxArgumentCount = Math.max(maxArgumentCount, argumentCount);\n }\n return maxArgumentCount;\n}\n\nfunction getFunctionProperty(\n value: BaseBunTestFunction,\n property: string,\n): AnyFunction | undefined {\n try {\n const propertyValue = Reflect.get(value, property);\n return typeof propertyValue === \"function\" ? propertyValue : undefined;\n } catch {\n return undefined;\n }\n}\n"],"mappings":";;;;;AA4IA,MAAM,cAAc;CAClB;CACA;CACA;CACA;CACA;CACA;AACD;AAED,MAAM,yBAAyB;CAC7B;CACA;CACA;AACD;AAED,MAAMA,eACJ,cACA;AACF,MAAMC,iBACJ,cAGA;AACF,MAAMC,KACH,cAA0D;AAC7D,MAAMC,YACH,cACE;AACL,MAAMC,MACH,cAA2D;AA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ACnB;GACD;AACD,UAAO,MAAM;EACd;AAED,MAAI;AACF,WAAQ,MAAM,UAAU,SAAS,CAAC,GAAG,MAAM,WAAY,EAAC;AACxD,sBAAmB;AACnB,OAAI,YAAa,QAAO,iBAAiB;EAC1C,SAAQ,OAAO;AACd,sBAAmB;AACnB,UAAO,MAAM;EACd;CACF;AACF;AAED,SAAS,wBAAwBE,OAAmC;CAClE,MAAM,OAAO,MAAM,WAAW,KAAK,MAAM,QAAQ,MAAM,GAAG,GACtD,MAAM,KACN;CACJ,IAAI,mBAAmB;AACvB,MAAK,MAAM,OAAO,MAAM;EACtB,MAAM,gBAAgB,MAAM,QAAQ,IAAI,GAAG,IAAI,SAAS;AACxD,qBAAmB,KAAK,IAAI,kBAAkB,cAAc;CAC7D;AACD,QAAO;AACR;AAED,SAAS,oBACPC,OACAC,UACyB;AACzB,KAAI;EACF,MAAM,gBAAgB,QAAQ,IAAI,OAAO,SAAS;AAClD,gBAAc,kBAAkB,aAAa;CAC9C,QAAO;AACN;CACD;AACF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logtape/testing-bun",
3
- "version": "2.3.0-dev.0",
3
+ "version": "2.3.0-dev.840+34e837bf",
4
4
  "description": "Bun test runner integration for LogTape failure log reporting",
5
5
  "keywords": [
6
6
  "logging",
@@ -60,16 +60,16 @@
60
60
  "dist/"
61
61
  ],
62
62
  "dependencies": {
63
- "@logtape/testing": "^2.3.0"
63
+ "@logtape/testing": "^2.3.0-dev.840+34e837bf"
64
64
  },
65
65
  "peerDependencies": {
66
- "@logtape/logtape": "^2.3.0"
66
+ "@logtape/logtape": "^2.3.0-dev.840+34e837bf"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@types/bun": "^1.2.15",
70
70
  "tsdown": "^0.12.7",
71
71
  "typescript": "^5.8.3",
72
- "@logtape/logtape": "^2.3.0"
72
+ "@logtape/logtape": "^2.3.0-dev.840+34e837bf"
73
73
  },
74
74
  "scripts": {
75
75
  "build": "tsdown",