@logtape/testing-bun 2.3.0-dev.0
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/LICENSE +20 -0
- package/README.md +77 -0
- package/dist/_virtual/rolldown_runtime.cjs +30 -0
- package/dist/autoload.cjs +274 -0
- package/dist/autoload.d.cts +151 -0
- package/dist/autoload.d.cts.map +1 -0
- package/dist/autoload.d.ts +151 -0
- package/dist/autoload.d.ts.map +1 -0
- package/dist/autoload.js +224 -0
- package/dist/autoload.js.map +1 -0
- package/dist/mod.cjs +236 -0
- package/dist/mod.d.cts +151 -0
- package/dist/mod.d.cts.map +1 -0
- package/dist/mod.d.ts +151 -0
- package/dist/mod.d.ts.map +1 -0
- package/dist/mod.js +208 -0
- package/dist/mod.js.map +1 -0
- package/package.json +82 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright 2024–2026 Hong Minhee
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<!-- deno-fmt-ignore-file -->
|
|
2
|
+
|
|
3
|
+
Bun test runner integration for LogTape
|
|
4
|
+
=======================================
|
|
5
|
+
|
|
6
|
+
[![JSR][JSR badge]][JSR]
|
|
7
|
+
[![npm][npm badge]][npm]
|
|
8
|
+
|
|
9
|
+
*@logtape/testing-bun* provides a [Bun test runner] integration for
|
|
10
|
+
[LogTape]'s failure log reporter. Import its `test` function instead of
|
|
11
|
+
`bun:test` when you want logs emitted by a test callback to be reported only
|
|
12
|
+
when that callback fails.
|
|
13
|
+
|
|
14
|
+
[JSR badge]: https://jsr.io/badges/@logtape/testing-bun
|
|
15
|
+
[JSR]: https://jsr.io/@logtape/testing-bun
|
|
16
|
+
[npm badge]: https://img.shields.io/npm/v/@logtape/testing-bun?logo=npm
|
|
17
|
+
[npm]: https://www.npmjs.com/package/@logtape/testing-bun
|
|
18
|
+
[Bun test runner]: https://bun.com/docs/test
|
|
19
|
+
[LogTape]: https://logtape.org/
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
Installation
|
|
23
|
+
------------
|
|
24
|
+
|
|
25
|
+
~~~~ sh
|
|
26
|
+
bun add @logtape/testing-bun
|
|
27
|
+
~~~~
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
Usage
|
|
31
|
+
-----
|
|
32
|
+
|
|
33
|
+
~~~~ typescript
|
|
34
|
+
import { test } from "@logtape/testing-bun/autoload";
|
|
35
|
+
import { getLogger } from "@logtape/logtape";
|
|
36
|
+
|
|
37
|
+
test("case", () => {
|
|
38
|
+
getLogger(["my-lib"]).debug("Fixture state: {state}.", {
|
|
39
|
+
state: "ready",
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Logs emitted here are printed only if this callback fails.
|
|
43
|
+
});
|
|
44
|
+
~~~~
|
|
45
|
+
|
|
46
|
+
The autoload entry point is the easiest setup for large suites. It configures
|
|
47
|
+
the minimal LogTape `contextLocalStorage` needed by the failure log reporter
|
|
48
|
+
when LogTape has not been configured yet. If your suite already configures
|
|
49
|
+
LogTape, that configuration must include `contextLocalStorage`; otherwise, use
|
|
50
|
+
`@logtape/testing-bun` and manage setup explicitly.
|
|
51
|
+
|
|
52
|
+
Use `createTest()` when a suite needs custom reporter options:
|
|
53
|
+
|
|
54
|
+
~~~~ typescript
|
|
55
|
+
import { createTest } from "@logtape/testing-bun";
|
|
56
|
+
|
|
57
|
+
const test = createTest({
|
|
58
|
+
lowestLevel: "debug",
|
|
59
|
+
mode: "on-failure",
|
|
60
|
+
});
|
|
61
|
+
~~~~
|
|
62
|
+
|
|
63
|
+
The package preserves Bun test options and shorthand helpers such as
|
|
64
|
+
`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.
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
Docs
|
|
73
|
+
----
|
|
74
|
+
|
|
75
|
+
The docs of this package is available at
|
|
76
|
+
<https://logtape.org/manual/testing#bun-test-runner-integration>.
|
|
77
|
+
For the API references, see <https://jsr.io/@logtape/testing-bun/doc>.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
|
|
25
|
+
Object.defineProperty(exports, '__toESM', {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return __toESM;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
//#region rolldown:runtime
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
const node_async_hooks = __toESM(require("node:async_hooks"));
|
|
26
|
+
const __logtape_logtape = __toESM(require("@logtape/logtape"));
|
|
27
|
+
const bun_test = __toESM(require("bun:test"));
|
|
28
|
+
const __logtape_testing_reporter = __toESM(require("@logtape/testing/reporter"));
|
|
29
|
+
|
|
30
|
+
//#region src/mod.ts
|
|
31
|
+
const helperNames = [
|
|
32
|
+
"skip",
|
|
33
|
+
"todo",
|
|
34
|
+
"only",
|
|
35
|
+
"failing",
|
|
36
|
+
"concurrent",
|
|
37
|
+
"serial"
|
|
38
|
+
];
|
|
39
|
+
const conditionalHelperNames = [
|
|
40
|
+
"if",
|
|
41
|
+
"skipIf",
|
|
42
|
+
"todoIf"
|
|
43
|
+
];
|
|
44
|
+
const expectTypeOf = bun_test.expectTypeOf;
|
|
45
|
+
const onTestFinished = bun_test.onTestFinished;
|
|
46
|
+
const vi = bun_test.vi;
|
|
47
|
+
const xdescribe = bun_test.xdescribe;
|
|
48
|
+
const xit = bun_test.xit;
|
|
49
|
+
const xtest = bun_test.xtest;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a `bun:test` test function that reports LogTape records from failed
|
|
52
|
+
* test callbacks.
|
|
53
|
+
*
|
|
54
|
+
* The returned function preserves Bun test options and shorthand helpers such
|
|
55
|
+
* as `test.skip()`, `test.todo()`, `test.only()`, `test.if()`,
|
|
56
|
+
* `test.failing()`, `test.concurrent()`, `test.serial()`, and `test.each()`.
|
|
57
|
+
* Only callback arguments are adapted; options are passed through to
|
|
58
|
+
* `bun:test`.
|
|
59
|
+
*
|
|
60
|
+
* @param options Failure log reporter options.
|
|
61
|
+
* @returns A configured `bun:test`-compatible test function.
|
|
62
|
+
* @since 2.3.0
|
|
63
|
+
*/
|
|
64
|
+
function createTest(options = {}) {
|
|
65
|
+
return createBunTestFunction(bun_test.test, options);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Creates an `it()` alias that reports LogTape records from failed test
|
|
69
|
+
* callbacks.
|
|
70
|
+
*
|
|
71
|
+
* @param options Failure log reporter options.
|
|
72
|
+
* @returns A configured `bun:test`-compatible `it()` function.
|
|
73
|
+
* @since 2.3.0
|
|
74
|
+
*/
|
|
75
|
+
function createIt(options = {}) {
|
|
76
|
+
return createBunTestFunction(bun_test.it, options);
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* A `bun:test` test function that reports LogTape records from failed test
|
|
80
|
+
* callbacks using the default reporter options.
|
|
81
|
+
*
|
|
82
|
+
* @since 2.3.0
|
|
83
|
+
*/
|
|
84
|
+
const test = createTest();
|
|
85
|
+
/**
|
|
86
|
+
* A `bun:test` `it()` alias that reports LogTape records from failed test
|
|
87
|
+
* callbacks using the default reporter options.
|
|
88
|
+
*
|
|
89
|
+
* @since 2.3.0
|
|
90
|
+
*/
|
|
91
|
+
const it = createIt();
|
|
92
|
+
/**
|
|
93
|
+
* Shorthand for skipping a test.
|
|
94
|
+
*
|
|
95
|
+
* @since 2.3.0
|
|
96
|
+
*/
|
|
97
|
+
const skip = test.skip;
|
|
98
|
+
/**
|
|
99
|
+
* Shorthand for marking a test as TODO.
|
|
100
|
+
*
|
|
101
|
+
* @since 2.3.0
|
|
102
|
+
*/
|
|
103
|
+
const todo = test.todo;
|
|
104
|
+
/**
|
|
105
|
+
* Shorthand for marking a test as `only`.
|
|
106
|
+
*
|
|
107
|
+
* @since 2.3.0
|
|
108
|
+
*/
|
|
109
|
+
const only = test.only;
|
|
110
|
+
/**
|
|
111
|
+
* Shorthand for marking a test as expected to fail.
|
|
112
|
+
*
|
|
113
|
+
* @since 2.3.0
|
|
114
|
+
*/
|
|
115
|
+
const failing = test.failing;
|
|
116
|
+
/**
|
|
117
|
+
* Shorthand for running a test concurrently.
|
|
118
|
+
*
|
|
119
|
+
* @since 2.3.0
|
|
120
|
+
*/
|
|
121
|
+
const concurrent = test.concurrent;
|
|
122
|
+
/**
|
|
123
|
+
* Shorthand for running a test serially.
|
|
124
|
+
*
|
|
125
|
+
* @since 2.3.0
|
|
126
|
+
*/
|
|
127
|
+
const serial = test.serial;
|
|
128
|
+
/**
|
|
129
|
+
* Shorthand for Bun's parameterized tests.
|
|
130
|
+
*
|
|
131
|
+
* @since 2.3.0
|
|
132
|
+
*/
|
|
133
|
+
const each = test.each;
|
|
134
|
+
var src_default = test;
|
|
135
|
+
function createBunTestFunction(baseTest, options) {
|
|
136
|
+
const register = (...args) => Reflect.apply(baseTest, void 0, wrapBunTestArguments(args, options));
|
|
137
|
+
for (const helperName of helperNames) {
|
|
138
|
+
const helper = getFunctionProperty(baseTest, helperName);
|
|
139
|
+
if (helper == null) continue;
|
|
140
|
+
Object.defineProperty(register, helperName, {
|
|
141
|
+
configurable: true,
|
|
142
|
+
enumerable: true,
|
|
143
|
+
value: createBunTestFunction(helper, options),
|
|
144
|
+
writable: true
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
for (const helperName of conditionalHelperNames) {
|
|
148
|
+
const helper = getFunctionProperty(baseTest, helperName);
|
|
149
|
+
if (helper == null) continue;
|
|
150
|
+
Object.defineProperty(register, helperName, {
|
|
151
|
+
configurable: true,
|
|
152
|
+
enumerable: true,
|
|
153
|
+
value: (condition) => {
|
|
154
|
+
const conditionalTest = Reflect.apply(helper, baseTest, [condition]);
|
|
155
|
+
return createBunTestFunction(conditionalTest, options);
|
|
156
|
+
},
|
|
157
|
+
writable: true
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
const each$1 = getFunctionProperty(baseTest, "each");
|
|
161
|
+
if (each$1 != null) Object.defineProperty(register, "each", {
|
|
162
|
+
configurable: true,
|
|
163
|
+
enumerable: true,
|
|
164
|
+
value: createWrappedEach(baseTest, each$1, options),
|
|
165
|
+
writable: true
|
|
166
|
+
});
|
|
167
|
+
return register;
|
|
168
|
+
}
|
|
169
|
+
function createWrappedEach(baseTest, baseEach, options) {
|
|
170
|
+
return (...cases) => {
|
|
171
|
+
const registerEach = Reflect.apply(baseEach, baseTest, cases);
|
|
172
|
+
return (...args) => Reflect.apply(registerEach, void 0, wrapBunEachArguments(args, options));
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function wrapBunTestArguments(args, options) {
|
|
176
|
+
const callbackIndex = args.findIndex((arg) => typeof arg === "function");
|
|
177
|
+
if (callbackIndex < 0) return [...args];
|
|
178
|
+
return [
|
|
179
|
+
...args.slice(0, callbackIndex),
|
|
180
|
+
wrapBunTestCallback(args[callbackIndex], options),
|
|
181
|
+
...args.slice(callbackIndex + 1)
|
|
182
|
+
];
|
|
183
|
+
}
|
|
184
|
+
function wrapBunEachArguments(args, options) {
|
|
185
|
+
const callbackIndex = args.findIndex((arg, index) => index > 0 && typeof arg === "function");
|
|
186
|
+
if (callbackIndex < 0) return [...args];
|
|
187
|
+
return [
|
|
188
|
+
...args.slice(0, callbackIndex),
|
|
189
|
+
wrapBunEachCallback(args[callbackIndex], options),
|
|
190
|
+
...args.slice(callbackIndex + 1)
|
|
191
|
+
];
|
|
192
|
+
}
|
|
193
|
+
function wrapBunTestCallback(callback, options) {
|
|
194
|
+
const reporter = (0, __logtape_testing_reporter.createFailureLogReporter)(options);
|
|
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
|
+
}));
|
|
210
|
+
wrapped().then(() => done(), (error) => done(error));
|
|
211
|
+
};
|
|
212
|
+
return function() {
|
|
213
|
+
return reporter.run(() => Reflect.apply(callback, this, []));
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
function wrapBunEachCallback(callback, options) {
|
|
217
|
+
const reporter = (0, __logtape_testing_reporter.createFailureLogReporter)(options);
|
|
218
|
+
return function(...args) {
|
|
219
|
+
return reporter.run(() => Reflect.apply(callback, this, args));
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
function getFunctionProperty(value, property) {
|
|
223
|
+
try {
|
|
224
|
+
const propertyValue = Reflect.get(value, property);
|
|
225
|
+
return typeof propertyValue === "function" ? propertyValue : void 0;
|
|
226
|
+
} catch {
|
|
227
|
+
return void 0;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
//#endregion
|
|
232
|
+
//#region src/autoload.ts
|
|
233
|
+
const config = (0, __logtape_logtape.getConfig)();
|
|
234
|
+
if (config == null) (0, __logtape_logtape.configureSync)({
|
|
235
|
+
contextLocalStorage: new node_async_hooks.AsyncLocalStorage(),
|
|
236
|
+
sinks: {},
|
|
237
|
+
loggers: [{
|
|
238
|
+
category: ["logtape", "meta"],
|
|
239
|
+
sinks: []
|
|
240
|
+
}]
|
|
241
|
+
});
|
|
242
|
+
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;
|
|
244
|
+
|
|
245
|
+
//#endregion
|
|
246
|
+
exports.afterAll = bun_test.afterAll;
|
|
247
|
+
exports.afterEach = bun_test.afterEach;
|
|
248
|
+
exports.beforeAll = bun_test.beforeAll;
|
|
249
|
+
exports.beforeEach = bun_test.beforeEach;
|
|
250
|
+
exports.concurrent = concurrent;
|
|
251
|
+
exports.createIt = createIt;
|
|
252
|
+
exports.createTest = createTest;
|
|
253
|
+
exports.default = autoload_default;
|
|
254
|
+
exports.describe = bun_test.describe;
|
|
255
|
+
exports.each = each;
|
|
256
|
+
exports.expect = bun_test.expect;
|
|
257
|
+
exports.expectTypeOf = expectTypeOf;
|
|
258
|
+
exports.failing = failing;
|
|
259
|
+
exports.it = it;
|
|
260
|
+
exports.jest = bun_test.jest;
|
|
261
|
+
exports.mock = bun_test.mock;
|
|
262
|
+
exports.onTestFinished = onTestFinished;
|
|
263
|
+
exports.only = only;
|
|
264
|
+
exports.serial = serial;
|
|
265
|
+
exports.setDefaultTimeout = bun_test.setDefaultTimeout;
|
|
266
|
+
exports.setSystemTime = bun_test.setSystemTime;
|
|
267
|
+
exports.skip = skip;
|
|
268
|
+
exports.spyOn = bun_test.spyOn;
|
|
269
|
+
exports.test = src_default;
|
|
270
|
+
exports.todo = todo;
|
|
271
|
+
exports.vi = vi;
|
|
272
|
+
exports.xdescribe = xdescribe;
|
|
273
|
+
exports.xit = xit;
|
|
274
|
+
exports.xtest = xtest;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, jest, mock, setDefaultTimeout, setSystemTime, spyOn } from "bun:test";
|
|
2
|
+
import { FailureLogReportMode, FailureLogReporterOptions, FailureLogReporterOptions as FailureLogReporterOptions$1 } from "@logtape/testing/reporter";
|
|
3
|
+
|
|
4
|
+
//#region src/mod.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Options accepted by Bun's `test()` and `it()` functions.
|
|
8
|
+
*
|
|
9
|
+
* The shape mirrors Bun's documented option bag while allowing newer Bun
|
|
10
|
+
* options to pass through even when bundled TypeScript declarations lag behind
|
|
11
|
+
* the current runtime.
|
|
12
|
+
*
|
|
13
|
+
* @since 2.3.0
|
|
14
|
+
*/
|
|
15
|
+
interface BunTestOptions {
|
|
16
|
+
readonly retry?: number;
|
|
17
|
+
readonly repeats?: number;
|
|
18
|
+
readonly timeout?: number;
|
|
19
|
+
readonly [option: string]: unknown;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A callback passed to Bun's `test()` or `it()`.
|
|
23
|
+
*
|
|
24
|
+
* @since 2.3.0
|
|
25
|
+
*/
|
|
26
|
+
type BunTestCallback = (() => unknown) | ((done: BunDoneCallback) => unknown);
|
|
27
|
+
/**
|
|
28
|
+
* A Bun `test()`-compatible function.
|
|
29
|
+
*
|
|
30
|
+
* @since 2.3.0
|
|
31
|
+
*/
|
|
32
|
+
interface BunTestFunction {
|
|
33
|
+
(name: string, fn?: BunTestCallback, options?: number | BunTestOptions): void;
|
|
34
|
+
(name: string, options: number | BunTestOptions, fn?: BunTestCallback): void;
|
|
35
|
+
readonly skip: BunTestFunction & BunParameterizedTestFactory;
|
|
36
|
+
readonly todo: BunTestFunction & BunParameterizedTestFactory;
|
|
37
|
+
readonly only: BunTestFunction & BunParameterizedTestFactory;
|
|
38
|
+
readonly failing: BunTestFunction & BunParameterizedTestFactory;
|
|
39
|
+
readonly concurrent: BunTestFunction & BunParameterizedTestFactory;
|
|
40
|
+
readonly serial: BunTestFunction & BunParameterizedTestFactory;
|
|
41
|
+
readonly each: BunEachFunction;
|
|
42
|
+
readonly if: BunConditionalTestFactory;
|
|
43
|
+
readonly skipIf: BunConditionalTestFactory;
|
|
44
|
+
readonly todoIf: BunConditionalTestFactory;
|
|
45
|
+
}
|
|
46
|
+
interface BunParameterizedTestFactory {
|
|
47
|
+
readonly each: BunEachFunction;
|
|
48
|
+
}
|
|
49
|
+
interface BunConditionalTestFactory {
|
|
50
|
+
(condition: unknown): BunTestFunction & BunParameterizedTestFactory;
|
|
51
|
+
}
|
|
52
|
+
interface BunEachFunction {
|
|
53
|
+
(...cases: readonly unknown[]): BunEachRegisterFunction;
|
|
54
|
+
}
|
|
55
|
+
interface BunEachRegisterFunction {
|
|
56
|
+
(name: string, fn: (...args: never[]) => unknown, options?: number | BunTestOptions): void;
|
|
57
|
+
(name: string, options: number | BunTestOptions, fn: (...args: never[]) => unknown): void;
|
|
58
|
+
}
|
|
59
|
+
type BunDoneCallback = (error?: unknown) => void;
|
|
60
|
+
type BunFunction = (...args: unknown[]) => unknown;
|
|
61
|
+
type ExpectTypeOfFunction = (...args: unknown[]) => unknown;
|
|
62
|
+
type OnTestFinishedFunction = (callback: () => unknown) => void;
|
|
63
|
+
declare const expectTypeOf: ExpectTypeOfFunction;
|
|
64
|
+
declare const onTestFinished: OnTestFinishedFunction;
|
|
65
|
+
declare const vi: typeof jest;
|
|
66
|
+
declare const xdescribe: BunFunction;
|
|
67
|
+
declare const xit: BunFunction;
|
|
68
|
+
declare const xtest: BunFunction;
|
|
69
|
+
/**
|
|
70
|
+
* Creates a `bun:test` test function that reports LogTape records from failed
|
|
71
|
+
* test callbacks.
|
|
72
|
+
*
|
|
73
|
+
* The returned function preserves Bun test options and shorthand helpers such
|
|
74
|
+
* as `test.skip()`, `test.todo()`, `test.only()`, `test.if()`,
|
|
75
|
+
* `test.failing()`, `test.concurrent()`, `test.serial()`, and `test.each()`.
|
|
76
|
+
* Only callback arguments are adapted; options are passed through to
|
|
77
|
+
* `bun:test`.
|
|
78
|
+
*
|
|
79
|
+
* @param options Failure log reporter options.
|
|
80
|
+
* @returns A configured `bun:test`-compatible test function.
|
|
81
|
+
* @since 2.3.0
|
|
82
|
+
*/
|
|
83
|
+
declare function createTest(options?: FailureLogReporterOptions$1): BunTestFunction;
|
|
84
|
+
/**
|
|
85
|
+
* Creates an `it()` alias that reports LogTape records from failed test
|
|
86
|
+
* callbacks.
|
|
87
|
+
*
|
|
88
|
+
* @param options Failure log reporter options.
|
|
89
|
+
* @returns A configured `bun:test`-compatible `it()` function.
|
|
90
|
+
* @since 2.3.0
|
|
91
|
+
*/
|
|
92
|
+
declare function createIt(options?: FailureLogReporterOptions$1): BunTestFunction;
|
|
93
|
+
/**
|
|
94
|
+
* A `bun:test` test function that reports LogTape records from failed test
|
|
95
|
+
* callbacks using the default reporter options.
|
|
96
|
+
*
|
|
97
|
+
* @since 2.3.0
|
|
98
|
+
*/
|
|
99
|
+
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
|
+
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;
|
|
149
|
+
//#endregion
|
|
150
|
+
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
|
+
//# sourceMappingURL=autoload.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autoload.d.cts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":"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"}
|