@logtape/testing-node 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 +78 -0
- package/dist/_virtual/rolldown_runtime.cjs +30 -0
- package/dist/autoload.cjs +240 -0
- package/dist/autoload.d.cts +125 -0
- package/dist/autoload.d.cts.map +1 -0
- package/dist/autoload.d.ts +125 -0
- package/dist/autoload.d.ts.map +1 -0
- package/dist/autoload.js +159 -0
- package/dist/autoload.js.map +1 -0
- package/dist/mod.cjs +202 -0
- package/dist/mod.d.cts +125 -0
- package/dist/mod.d.cts.map +1 -0
- package/dist/mod.d.ts +125 -0
- package/dist/mod.d.ts.map +1 -0
- package/dist/mod.js +143 -0
- package/dist/mod.js.map +1 -0
- package/package.json +81 -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,78 @@
|
|
|
1
|
+
<!-- deno-fmt-ignore-file -->
|
|
2
|
+
|
|
3
|
+
Node.js test runner integration for LogTape
|
|
4
|
+
===========================================
|
|
5
|
+
|
|
6
|
+
[![JSR][JSR badge]][JSR]
|
|
7
|
+
[![npm][npm badge]][npm]
|
|
8
|
+
|
|
9
|
+
*@logtape/testing-node* provides a [Node.js test runner] integration for
|
|
10
|
+
[LogTape]'s failure log reporter. Import its `test` function instead of
|
|
11
|
+
`node: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-node
|
|
15
|
+
[JSR]: https://jsr.io/@logtape/testing-node
|
|
16
|
+
[npm badge]: https://img.shields.io/npm/v/@logtape/testing-node?logo=npm
|
|
17
|
+
[npm]: https://www.npmjs.com/package/@logtape/testing-node
|
|
18
|
+
[Node.js test runner]: https://nodejs.org/api/test.html
|
|
19
|
+
[LogTape]: https://logtape.org/
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
Installation
|
|
23
|
+
------------
|
|
24
|
+
|
|
25
|
+
~~~~ sh
|
|
26
|
+
npm add @logtape/testing-node # for npm
|
|
27
|
+
pnpm add @logtape/testing-node # for pnpm
|
|
28
|
+
yarn add @logtape/testing-node # for Yarn
|
|
29
|
+
bun add @logtape/testing-node # for Bun
|
|
30
|
+
~~~~
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
Usage
|
|
34
|
+
-----
|
|
35
|
+
|
|
36
|
+
~~~~ typescript
|
|
37
|
+
import { test } from "@logtape/testing-node/autoload";
|
|
38
|
+
import { getLogger } from "@logtape/logtape";
|
|
39
|
+
|
|
40
|
+
test("case", async () => {
|
|
41
|
+
getLogger(["my-lib"]).debug("Fixture state: {state}.", {
|
|
42
|
+
state: "ready",
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// Logs emitted here are printed only if this callback fails.
|
|
46
|
+
});
|
|
47
|
+
~~~~
|
|
48
|
+
|
|
49
|
+
The autoload entry point is the easiest setup for large suites. It configures
|
|
50
|
+
the minimal LogTape `contextLocalStorage` needed by the failure log reporter
|
|
51
|
+
when LogTape has not been configured yet. If your suite already configures
|
|
52
|
+
LogTape, that configuration must include `contextLocalStorage`; otherwise, use
|
|
53
|
+
`@logtape/testing-node` and manage setup explicitly.
|
|
54
|
+
|
|
55
|
+
Use `createTest()` when a suite needs custom reporter options:
|
|
56
|
+
|
|
57
|
+
~~~~ typescript
|
|
58
|
+
import { createTest } from "@logtape/testing-node";
|
|
59
|
+
|
|
60
|
+
const test = createTest({
|
|
61
|
+
lowestLevel: "debug",
|
|
62
|
+
mode: "on-failure",
|
|
63
|
+
});
|
|
64
|
+
~~~~
|
|
65
|
+
|
|
66
|
+
The package preserves Node.js test options and shorthand helpers such as
|
|
67
|
+
`test.only()`, `test.skip()`, and `test.todo()`. It also exports a wrapped
|
|
68
|
+
`it()` alias and `createIt()`. Other `node:test` helpers, including
|
|
69
|
+
`describe()`, `before()`, `after()`, `beforeEach()`, and `afterEach()`, are
|
|
70
|
+
re-exported unchanged.
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
Docs
|
|
74
|
+
----
|
|
75
|
+
|
|
76
|
+
The docs of this package is available at
|
|
77
|
+
<https://logtape.org/manual/testing#node-js-test-runner-integration>.
|
|
78
|
+
For the API references, see <https://jsr.io/@logtape/testing-node/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,240 @@
|
|
|
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 node_test = __toESM(require("node:test"));
|
|
28
|
+
const __logtape_testing_reporter = __toESM(require("@logtape/testing/reporter"));
|
|
29
|
+
|
|
30
|
+
//#region src/mod.ts
|
|
31
|
+
/**
|
|
32
|
+
* Creates a `node:test` test function that reports LogTape records from failed
|
|
33
|
+
* test callbacks.
|
|
34
|
+
*
|
|
35
|
+
* The returned function preserves Node.js test options and shorthand helpers
|
|
36
|
+
* such as `test.only()`, `test.skip()`, and `test.todo()`. Only callback
|
|
37
|
+
* arguments are adapted; options are passed through to `node:test`.
|
|
38
|
+
*
|
|
39
|
+
* @param options Failure log reporter options.
|
|
40
|
+
* @returns A configured `node:test`-compatible test function.
|
|
41
|
+
* @since 2.3.0
|
|
42
|
+
*/
|
|
43
|
+
function createTest(options = {}) {
|
|
44
|
+
return createNodeTestFunction(node_test.default, options);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Creates an `it()` alias that reports LogTape records from failed test
|
|
48
|
+
* callbacks.
|
|
49
|
+
*
|
|
50
|
+
* @param options Failure log reporter options.
|
|
51
|
+
* @returns A configured `node:test`-compatible `it()` function.
|
|
52
|
+
* @since 2.3.0
|
|
53
|
+
*/
|
|
54
|
+
function createIt(options = {}) {
|
|
55
|
+
return createNodeTestFunction(node_test.it, options);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* A `node:test` test function that reports LogTape records from failed test
|
|
59
|
+
* callbacks using the default reporter options.
|
|
60
|
+
*
|
|
61
|
+
* @since 2.3.0
|
|
62
|
+
*/
|
|
63
|
+
const test = createTest();
|
|
64
|
+
/**
|
|
65
|
+
* A `node:test` `it()` alias that reports LogTape records from failed test
|
|
66
|
+
* callbacks using the default reporter options.
|
|
67
|
+
*
|
|
68
|
+
* @since 2.3.0
|
|
69
|
+
*/
|
|
70
|
+
const it = createIt();
|
|
71
|
+
/**
|
|
72
|
+
* Shorthand for marking a test as `only`.
|
|
73
|
+
*
|
|
74
|
+
* @since 2.3.0
|
|
75
|
+
*/
|
|
76
|
+
const only = test.only;
|
|
77
|
+
/**
|
|
78
|
+
* Shorthand for skipping a test.
|
|
79
|
+
*
|
|
80
|
+
* @since 2.3.0
|
|
81
|
+
*/
|
|
82
|
+
const skip = test.skip;
|
|
83
|
+
/**
|
|
84
|
+
* Shorthand for marking a test as TODO.
|
|
85
|
+
*
|
|
86
|
+
* @since 2.3.0
|
|
87
|
+
*/
|
|
88
|
+
const todo = test.todo;
|
|
89
|
+
/**
|
|
90
|
+
* Shorthand for expecting a test to fail when supported by the active Node.js
|
|
91
|
+
* runtime.
|
|
92
|
+
*
|
|
93
|
+
* @since 2.3.0
|
|
94
|
+
*/
|
|
95
|
+
const expectFailure = test.expectFailure;
|
|
96
|
+
/**
|
|
97
|
+
* Node.js' test assertion tracker when supported by the active runtime.
|
|
98
|
+
*
|
|
99
|
+
* @since 2.3.0
|
|
100
|
+
*/
|
|
101
|
+
const assert = test.assert;
|
|
102
|
+
/**
|
|
103
|
+
* Node.js' snapshot helper when supported by the active runtime.
|
|
104
|
+
*
|
|
105
|
+
* @since 2.3.0
|
|
106
|
+
*/
|
|
107
|
+
const snapshot = test.snapshot;
|
|
108
|
+
var src_default = test;
|
|
109
|
+
function createNodeTestFunction(baseTest, options, includeExtendedProperties = true) {
|
|
110
|
+
const register = (...args) => Reflect.apply(baseTest, void 0, wrapCallbackArgument(args, options));
|
|
111
|
+
const baseExpectFailure = baseTest.expectFailure;
|
|
112
|
+
const wrapped = Object.assign(register, baseTest, {
|
|
113
|
+
only: (...args) => Reflect.apply(baseTest.only, void 0, wrapCallbackArgument(args, options)),
|
|
114
|
+
skip: (...args) => Reflect.apply(baseTest.skip, void 0, wrapCallbackArgument(args, options)),
|
|
115
|
+
todo: (...args) => Reflect.apply(baseTest.todo, void 0, wrapCallbackArgument(args, options)),
|
|
116
|
+
expectFailure: typeof baseExpectFailure === "function" ? (...args) => Reflect.apply(baseExpectFailure, void 0, wrapCallbackArgument(args, options)) : void 0
|
|
117
|
+
});
|
|
118
|
+
if (includeExtendedProperties) {
|
|
119
|
+
if (typeof baseTest.it === "function") Object.defineProperty(wrapped, "it", {
|
|
120
|
+
configurable: true,
|
|
121
|
+
enumerable: true,
|
|
122
|
+
value: createNodeTestFunction(baseTest.it, options, false),
|
|
123
|
+
writable: true
|
|
124
|
+
});
|
|
125
|
+
if (typeof baseTest.test === "function") Object.defineProperty(wrapped, "test", {
|
|
126
|
+
configurable: true,
|
|
127
|
+
enumerable: true,
|
|
128
|
+
value: wrapped,
|
|
129
|
+
writable: true
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
return wrapped;
|
|
133
|
+
}
|
|
134
|
+
function wrapCallbackArgument(args, options) {
|
|
135
|
+
const callback = args.at(-1);
|
|
136
|
+
if (typeof callback !== "function") return [...args];
|
|
137
|
+
const reporter = (0, __logtape_testing_reporter.createFailureLogReporter)(options);
|
|
138
|
+
const wrapped = wrapNodeCallback(reporter.wrap.bind(reporter), callback);
|
|
139
|
+
return [...args.slice(0, -1), wrapped];
|
|
140
|
+
}
|
|
141
|
+
function wrapNodeCallback(wrap, callback) {
|
|
142
|
+
if (callback.length >= 2) return function(context, done) {
|
|
143
|
+
const runCallback = (...args) => Reflect.apply(callback, this, args);
|
|
144
|
+
wrap(() => new Promise((resolve, reject) => {
|
|
145
|
+
let settled = false;
|
|
146
|
+
const wrappedDone = (error) => {
|
|
147
|
+
if (settled) return;
|
|
148
|
+
settled = true;
|
|
149
|
+
if (error == null) resolve();
|
|
150
|
+
else reject(error);
|
|
151
|
+
};
|
|
152
|
+
try {
|
|
153
|
+
runCallback(context, wrappedDone);
|
|
154
|
+
} catch (error) {
|
|
155
|
+
reject(error);
|
|
156
|
+
}
|
|
157
|
+
}))().then(() => done(), (error) => done(error));
|
|
158
|
+
};
|
|
159
|
+
if (callback.length === 0) return function() {
|
|
160
|
+
return wrap(() => Reflect.apply(callback, this, []))();
|
|
161
|
+
};
|
|
162
|
+
return function(context) {
|
|
163
|
+
return wrap(() => Reflect.apply(callback, this, [context]))();
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/autoload.ts
|
|
169
|
+
const config = (0, __logtape_logtape.getConfig)();
|
|
170
|
+
if (config == null) (0, __logtape_logtape.configureSync)({
|
|
171
|
+
contextLocalStorage: new node_async_hooks.AsyncLocalStorage(),
|
|
172
|
+
sinks: {},
|
|
173
|
+
loggers: [{
|
|
174
|
+
category: ["logtape", "meta"],
|
|
175
|
+
sinks: []
|
|
176
|
+
}]
|
|
177
|
+
});
|
|
178
|
+
else if (config.contextLocalStorage == null) throw new __logtape_logtape.ConfigError("@logtape/testing-node/autoload requires the existing LogTape configuration to provide contextLocalStorage.");
|
|
179
|
+
var autoload_default = src_default;
|
|
180
|
+
|
|
181
|
+
//#endregion
|
|
182
|
+
Object.defineProperty(exports, 'after', {
|
|
183
|
+
enumerable: true,
|
|
184
|
+
get: function () {
|
|
185
|
+
return node_test.after;
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
Object.defineProperty(exports, 'afterEach', {
|
|
189
|
+
enumerable: true,
|
|
190
|
+
get: function () {
|
|
191
|
+
return node_test.afterEach;
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
exports.assert = assert;
|
|
195
|
+
Object.defineProperty(exports, 'before', {
|
|
196
|
+
enumerable: true,
|
|
197
|
+
get: function () {
|
|
198
|
+
return node_test.before;
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
Object.defineProperty(exports, 'beforeEach', {
|
|
202
|
+
enumerable: true,
|
|
203
|
+
get: function () {
|
|
204
|
+
return node_test.beforeEach;
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
exports.createIt = createIt;
|
|
208
|
+
exports.createTest = createTest;
|
|
209
|
+
exports.default = autoload_default;
|
|
210
|
+
Object.defineProperty(exports, 'describe', {
|
|
211
|
+
enumerable: true,
|
|
212
|
+
get: function () {
|
|
213
|
+
return node_test.describe;
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
exports.expectFailure = expectFailure;
|
|
217
|
+
exports.it = it;
|
|
218
|
+
Object.defineProperty(exports, 'mock', {
|
|
219
|
+
enumerable: true,
|
|
220
|
+
get: function () {
|
|
221
|
+
return node_test.mock;
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
exports.only = only;
|
|
225
|
+
Object.defineProperty(exports, 'run', {
|
|
226
|
+
enumerable: true,
|
|
227
|
+
get: function () {
|
|
228
|
+
return node_test.run;
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
exports.skip = skip;
|
|
232
|
+
exports.snapshot = snapshot;
|
|
233
|
+
Object.defineProperty(exports, 'suite', {
|
|
234
|
+
enumerable: true,
|
|
235
|
+
get: function () {
|
|
236
|
+
return node_test.suite;
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
exports.test = src_default;
|
|
240
|
+
exports.todo = todo;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { TestContext, after, afterEach, before, beforeEach, describe, mock, run, suite } from "node: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 Node.js `test()` and `it()` functions.
|
|
8
|
+
*
|
|
9
|
+
* The shape intentionally mirrors Node's documented option bag while allowing
|
|
10
|
+
* newer Node.js options to pass through even when a runtime's bundled TypeScript
|
|
11
|
+
* declarations lag behind the current documentation.
|
|
12
|
+
*
|
|
13
|
+
* @since 2.3.0
|
|
14
|
+
*/
|
|
15
|
+
interface NodeTestOptions {
|
|
16
|
+
readonly concurrency?: number | boolean;
|
|
17
|
+
readonly expectFailure?: boolean | string | RegExp | ((error: unknown) => boolean) | object | Error;
|
|
18
|
+
readonly only?: boolean;
|
|
19
|
+
readonly signal?: AbortSignal;
|
|
20
|
+
readonly skip?: boolean | string;
|
|
21
|
+
readonly tags?: readonly string[];
|
|
22
|
+
readonly todo?: boolean | string;
|
|
23
|
+
readonly timeout?: number;
|
|
24
|
+
readonly plan?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A callback passed to Node.js `test()` or `it()`.
|
|
28
|
+
*
|
|
29
|
+
* @since 2.3.0
|
|
30
|
+
*/
|
|
31
|
+
type NodeTestCallback = (context: TestContext, done?: NodeDoneCallback) => unknown;
|
|
32
|
+
/**
|
|
33
|
+
* A Node.js `test()`-compatible function.
|
|
34
|
+
*
|
|
35
|
+
* @since 2.3.0
|
|
36
|
+
*/
|
|
37
|
+
interface NodeTestFunction {
|
|
38
|
+
(name?: string, options?: NodeTestOptions, fn?: NodeTestCallback): Promise<void>;
|
|
39
|
+
(name?: string, fn?: NodeTestCallback): Promise<void>;
|
|
40
|
+
(options?: NodeTestOptions, fn?: NodeTestCallback): Promise<void>;
|
|
41
|
+
(fn?: NodeTestCallback): Promise<void>;
|
|
42
|
+
readonly only: NodeTestFunction;
|
|
43
|
+
readonly skip: NodeTestFunction;
|
|
44
|
+
readonly todo: NodeTestFunction;
|
|
45
|
+
readonly expectFailure?: NodeTestFunction;
|
|
46
|
+
readonly it?: NodeTestFunction;
|
|
47
|
+
readonly test?: NodeTestFunction;
|
|
48
|
+
}
|
|
49
|
+
type NodeDoneCallback = (error?: unknown) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a `node:test` test function that reports LogTape records from failed
|
|
52
|
+
* test callbacks.
|
|
53
|
+
*
|
|
54
|
+
* The returned function preserves Node.js test options and shorthand helpers
|
|
55
|
+
* such as `test.only()`, `test.skip()`, and `test.todo()`. Only callback
|
|
56
|
+
* arguments are adapted; options are passed through to `node:test`.
|
|
57
|
+
*
|
|
58
|
+
* @param options Failure log reporter options.
|
|
59
|
+
* @returns A configured `node:test`-compatible test function.
|
|
60
|
+
* @since 2.3.0
|
|
61
|
+
*/
|
|
62
|
+
declare function createTest(options?: FailureLogReporterOptions$1): NodeTestFunction;
|
|
63
|
+
/**
|
|
64
|
+
* Creates an `it()` alias that reports LogTape records from failed test
|
|
65
|
+
* callbacks.
|
|
66
|
+
*
|
|
67
|
+
* @param options Failure log reporter options.
|
|
68
|
+
* @returns A configured `node:test`-compatible `it()` function.
|
|
69
|
+
* @since 2.3.0
|
|
70
|
+
*/
|
|
71
|
+
declare function createIt(options?: FailureLogReporterOptions$1): NodeTestFunction;
|
|
72
|
+
/**
|
|
73
|
+
* A `node:test` test function that reports LogTape records from failed test
|
|
74
|
+
* callbacks using the default reporter options.
|
|
75
|
+
*
|
|
76
|
+
* @since 2.3.0
|
|
77
|
+
*/
|
|
78
|
+
declare const test: NodeTestFunction;
|
|
79
|
+
/**
|
|
80
|
+
* A `node:test` `it()` alias that reports LogTape records from failed test
|
|
81
|
+
* callbacks using the default reporter options.
|
|
82
|
+
*
|
|
83
|
+
* @since 2.3.0
|
|
84
|
+
*/
|
|
85
|
+
declare const it: NodeTestFunction;
|
|
86
|
+
/**
|
|
87
|
+
* Shorthand for marking a test as `only`.
|
|
88
|
+
*
|
|
89
|
+
* @since 2.3.0
|
|
90
|
+
*/
|
|
91
|
+
declare const only: NodeTestFunction;
|
|
92
|
+
/**
|
|
93
|
+
* Shorthand for skipping a test.
|
|
94
|
+
*
|
|
95
|
+
* @since 2.3.0
|
|
96
|
+
*/
|
|
97
|
+
declare const skip: NodeTestFunction;
|
|
98
|
+
/**
|
|
99
|
+
* Shorthand for marking a test as TODO.
|
|
100
|
+
*
|
|
101
|
+
* @since 2.3.0
|
|
102
|
+
*/
|
|
103
|
+
declare const todo: NodeTestFunction;
|
|
104
|
+
/**
|
|
105
|
+
* Shorthand for expecting a test to fail when supported by the active Node.js
|
|
106
|
+
* runtime.
|
|
107
|
+
*
|
|
108
|
+
* @since 2.3.0
|
|
109
|
+
*/
|
|
110
|
+
declare const expectFailure: NodeTestFunction | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* Node.js' test assertion tracker when supported by the active runtime.
|
|
113
|
+
*
|
|
114
|
+
* @since 2.3.0
|
|
115
|
+
*/
|
|
116
|
+
declare const assert: unknown;
|
|
117
|
+
/**
|
|
118
|
+
* Node.js' snapshot helper when supported by the active runtime.
|
|
119
|
+
*
|
|
120
|
+
* @since 2.3.0
|
|
121
|
+
*/
|
|
122
|
+
declare const snapshot: unknown;
|
|
123
|
+
//#endregion
|
|
124
|
+
export { FailureLogReportMode, FailureLogReporterOptions, NodeTestCallback, NodeTestFunction, NodeTestOptions, TestContext, after, afterEach, assert, before, beforeEach, createIt, createTest, test as default, test, describe, expectFailure, it, mock, only, run, skip, snapshot, suite, todo };
|
|
125
|
+
//# sourceMappingURL=autoload.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autoload.d.cts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;AAgCA;;;;;AAU+B;AAa/B;;;AAES,UAzBQ,eAAA,CAyBR;EAAgB,SAAA,WAAA,CAAA,EAAA,MAAA,GAAA,OAAA;EAQR,SAAA,aAAgB,CAAA,EAAA,OAAA,GAAA,MAAA,GA5B3B,MA4B2B,GAAA,CAAA,CAAA,KAAA,EAAA,OAAA,EAAA,GAAA,OAAA,CAAA,GAAA,MAAA,GAzB3B,KAyB2B;EAAA,SAAA,IAAA,CAAA,EAAA,OAAA;EAAA,SACL,MAAA,CAAA,EAxBR,WAwBQ;EAAe,SAAO,IAAA,CAAA,EAAA,OAAA,GAAA,MAAA;EAAgB,SAAG,IAAA,CAAA,EAAA,SAAA,MAAA,EAAA;EAAO,SAGrD,IAAA,CAAA,EAAA,OAAA,GAAA,MAAA;EAAgB,SAAG,OAAA,CAAA,EAAA,MAAA;EAAO,SACpC,IAAA,CAAA,EAAA,MAAA;;;;;;;AAII,KAnBL,gBAAA,GAmBK,CAAA,OAAA,EAlBN,WAkBM,EAAA,IAAA,CAAA,EAjBR,gBAiBQ,EAAA,GAAA,OAAA;;;;AAGiB;AACjC;AAyBe,UAtCC,gBAAA,CAsCS;EAAA,CAAA,IAAA,CAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EArCE,eAqCF,EAAA,EAAA,CAAA,EArCwB,gBAqCxB,CAAA,EArC2C,OAqC3C,CAAA,IAAA,CAAA;EAAA,CAAA,IACf,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,EAnCY,gBAmCZ,CAAA,EAnC+B,OAmC/B,CAAA,IAAA,CAAA;EAA8B,CAAA,OACtC,CAAA,EAnCU,eAmCV,EAAA,EAAA,CAAA,EAnCgC,gBAmChC,CAAA,EAnCmD,OAmCnD,CAAA,IAAA,CAAA;EAAgB,CAAA,EAAA,CAAA,EAlCX,gBAkCW,CAAA,EAlCQ,OAkCR,CAAA,IAAA,CAAA;EAeH,SAAA,IAAQ,EAhDP,gBAgDO;EAAA,SAAA,IAAA,EA/CP,gBA+CO;EAAA,SACb,IAAA,EA/CM,gBA+CN;EAA8B,SACtC,aAAA,CAAA,EA/CwB,gBA+CxB;EAAgB,SAAA,EAAA,CAAA,EA9CH,gBA8CG;EAaN,SAAqC,IAAA,CAAA,EA1DhC,gBA0DC;AAQnB;AAOA,KAtEK,gBAAA,GAsEc,CAAA,KAA4B,CAA5B,EAAA,OAA4B,EAAA,GAAA,IAAA;AAO/C;AAOA;AAQA;AAOA;AAOA;;;;;;;;iBAnFgB,UAAA,WACL,8BACR;;;;;;;;;iBAea,QAAA,WACL,8BACR;;;;;;;cAaU,MAAM;;;;;;;cAQN,IAAI;;;;;;cAOJ,MAAM;;;;;;cAON,MAAM;;;;;;cAON,MAAM;;;;;;;cAQN,eAAe;;;;;;cAOf;;;;;;cAOA"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { TestContext, after, afterEach, before, beforeEach, describe, mock, run, suite } from "node: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 Node.js `test()` and `it()` functions.
|
|
8
|
+
*
|
|
9
|
+
* The shape intentionally mirrors Node's documented option bag while allowing
|
|
10
|
+
* newer Node.js options to pass through even when a runtime's bundled TypeScript
|
|
11
|
+
* declarations lag behind the current documentation.
|
|
12
|
+
*
|
|
13
|
+
* @since 2.3.0
|
|
14
|
+
*/
|
|
15
|
+
interface NodeTestOptions {
|
|
16
|
+
readonly concurrency?: number | boolean;
|
|
17
|
+
readonly expectFailure?: boolean | string | RegExp | ((error: unknown) => boolean) | object | Error;
|
|
18
|
+
readonly only?: boolean;
|
|
19
|
+
readonly signal?: AbortSignal;
|
|
20
|
+
readonly skip?: boolean | string;
|
|
21
|
+
readonly tags?: readonly string[];
|
|
22
|
+
readonly todo?: boolean | string;
|
|
23
|
+
readonly timeout?: number;
|
|
24
|
+
readonly plan?: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* A callback passed to Node.js `test()` or `it()`.
|
|
28
|
+
*
|
|
29
|
+
* @since 2.3.0
|
|
30
|
+
*/
|
|
31
|
+
type NodeTestCallback = (context: TestContext, done?: NodeDoneCallback) => unknown;
|
|
32
|
+
/**
|
|
33
|
+
* A Node.js `test()`-compatible function.
|
|
34
|
+
*
|
|
35
|
+
* @since 2.3.0
|
|
36
|
+
*/
|
|
37
|
+
interface NodeTestFunction {
|
|
38
|
+
(name?: string, options?: NodeTestOptions, fn?: NodeTestCallback): Promise<void>;
|
|
39
|
+
(name?: string, fn?: NodeTestCallback): Promise<void>;
|
|
40
|
+
(options?: NodeTestOptions, fn?: NodeTestCallback): Promise<void>;
|
|
41
|
+
(fn?: NodeTestCallback): Promise<void>;
|
|
42
|
+
readonly only: NodeTestFunction;
|
|
43
|
+
readonly skip: NodeTestFunction;
|
|
44
|
+
readonly todo: NodeTestFunction;
|
|
45
|
+
readonly expectFailure?: NodeTestFunction;
|
|
46
|
+
readonly it?: NodeTestFunction;
|
|
47
|
+
readonly test?: NodeTestFunction;
|
|
48
|
+
}
|
|
49
|
+
type NodeDoneCallback = (error?: unknown) => void;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a `node:test` test function that reports LogTape records from failed
|
|
52
|
+
* test callbacks.
|
|
53
|
+
*
|
|
54
|
+
* The returned function preserves Node.js test options and shorthand helpers
|
|
55
|
+
* such as `test.only()`, `test.skip()`, and `test.todo()`. Only callback
|
|
56
|
+
* arguments are adapted; options are passed through to `node:test`.
|
|
57
|
+
*
|
|
58
|
+
* @param options Failure log reporter options.
|
|
59
|
+
* @returns A configured `node:test`-compatible test function.
|
|
60
|
+
* @since 2.3.0
|
|
61
|
+
*/
|
|
62
|
+
declare function createTest(options?: FailureLogReporterOptions$1): NodeTestFunction;
|
|
63
|
+
/**
|
|
64
|
+
* Creates an `it()` alias that reports LogTape records from failed test
|
|
65
|
+
* callbacks.
|
|
66
|
+
*
|
|
67
|
+
* @param options Failure log reporter options.
|
|
68
|
+
* @returns A configured `node:test`-compatible `it()` function.
|
|
69
|
+
* @since 2.3.0
|
|
70
|
+
*/
|
|
71
|
+
declare function createIt(options?: FailureLogReporterOptions$1): NodeTestFunction;
|
|
72
|
+
/**
|
|
73
|
+
* A `node:test` test function that reports LogTape records from failed test
|
|
74
|
+
* callbacks using the default reporter options.
|
|
75
|
+
*
|
|
76
|
+
* @since 2.3.0
|
|
77
|
+
*/
|
|
78
|
+
declare const test: NodeTestFunction;
|
|
79
|
+
/**
|
|
80
|
+
* A `node:test` `it()` alias that reports LogTape records from failed test
|
|
81
|
+
* callbacks using the default reporter options.
|
|
82
|
+
*
|
|
83
|
+
* @since 2.3.0
|
|
84
|
+
*/
|
|
85
|
+
declare const it: NodeTestFunction;
|
|
86
|
+
/**
|
|
87
|
+
* Shorthand for marking a test as `only`.
|
|
88
|
+
*
|
|
89
|
+
* @since 2.3.0
|
|
90
|
+
*/
|
|
91
|
+
declare const only: NodeTestFunction;
|
|
92
|
+
/**
|
|
93
|
+
* Shorthand for skipping a test.
|
|
94
|
+
*
|
|
95
|
+
* @since 2.3.0
|
|
96
|
+
*/
|
|
97
|
+
declare const skip: NodeTestFunction;
|
|
98
|
+
/**
|
|
99
|
+
* Shorthand for marking a test as TODO.
|
|
100
|
+
*
|
|
101
|
+
* @since 2.3.0
|
|
102
|
+
*/
|
|
103
|
+
declare const todo: NodeTestFunction;
|
|
104
|
+
/**
|
|
105
|
+
* Shorthand for expecting a test to fail when supported by the active Node.js
|
|
106
|
+
* runtime.
|
|
107
|
+
*
|
|
108
|
+
* @since 2.3.0
|
|
109
|
+
*/
|
|
110
|
+
declare const expectFailure: NodeTestFunction | undefined;
|
|
111
|
+
/**
|
|
112
|
+
* Node.js' test assertion tracker when supported by the active runtime.
|
|
113
|
+
*
|
|
114
|
+
* @since 2.3.0
|
|
115
|
+
*/
|
|
116
|
+
declare const assert: unknown;
|
|
117
|
+
/**
|
|
118
|
+
* Node.js' snapshot helper when supported by the active runtime.
|
|
119
|
+
*
|
|
120
|
+
* @since 2.3.0
|
|
121
|
+
*/
|
|
122
|
+
declare const snapshot: unknown;
|
|
123
|
+
//#endregion
|
|
124
|
+
export { FailureLogReportMode, FailureLogReporterOptions, NodeTestCallback, NodeTestFunction, NodeTestOptions, TestContext, after, afterEach, assert, before, beforeEach, createIt, createTest, test as default, test, describe, expectFailure, it, mock, only, run, skip, snapshot, suite, todo };
|
|
125
|
+
//# sourceMappingURL=autoload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"autoload.d.ts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;AAgCA;;;;;AAU+B;AAa/B;;;AAES,UAzBQ,eAAA,CAyBR;EAAgB,SAAA,WAAA,CAAA,EAAA,MAAA,GAAA,OAAA;EAQR,SAAA,aAAgB,CAAA,EAAA,OAAA,GAAA,MAAA,GA5B3B,MA4B2B,GAAA,CAAA,CAAA,KAAA,EAAA,OAAA,EAAA,GAAA,OAAA,CAAA,GAAA,MAAA,GAzB3B,KAyB2B;EAAA,SAAA,IAAA,CAAA,EAAA,OAAA;EAAA,SACL,MAAA,CAAA,EAxBR,WAwBQ;EAAe,SAAO,IAAA,CAAA,EAAA,OAAA,GAAA,MAAA;EAAgB,SAAG,IAAA,CAAA,EAAA,SAAA,MAAA,EAAA;EAAO,SAGrD,IAAA,CAAA,EAAA,OAAA,GAAA,MAAA;EAAgB,SAAG,OAAA,CAAA,EAAA,MAAA;EAAO,SACpC,IAAA,CAAA,EAAA,MAAA;;;;;;;AAII,KAnBL,gBAAA,GAmBK,CAAA,OAAA,EAlBN,WAkBM,EAAA,IAAA,CAAA,EAjBR,gBAiBQ,EAAA,GAAA,OAAA;;;;AAGiB;AACjC;AAyBe,UAtCC,gBAAA,CAsCS;EAAA,CAAA,IAAA,CAAA,EAAA,MAAA,EAAA,OAAA,CAAA,EArCE,eAqCF,EAAA,EAAA,CAAA,EArCwB,gBAqCxB,CAAA,EArC2C,OAqC3C,CAAA,IAAA,CAAA;EAAA,CAAA,IACf,CAAA,EAAA,MAAA,EAAA,EAAA,CAAA,EAnCY,gBAmCZ,CAAA,EAnC+B,OAmC/B,CAAA,IAAA,CAAA;EAA8B,CAAA,OACtC,CAAA,EAnCU,eAmCV,EAAA,EAAA,CAAA,EAnCgC,gBAmChC,CAAA,EAnCmD,OAmCnD,CAAA,IAAA,CAAA;EAAgB,CAAA,EAAA,CAAA,EAlCX,gBAkCW,CAAA,EAlCQ,OAkCR,CAAA,IAAA,CAAA;EAeH,SAAA,IAAQ,EAhDP,gBAgDO;EAAA,SAAA,IAAA,EA/CP,gBA+CO;EAAA,SACb,IAAA,EA/CM,gBA+CN;EAA8B,SACtC,aAAA,CAAA,EA/CwB,gBA+CxB;EAAgB,SAAA,EAAA,CAAA,EA9CH,gBA8CG;EAaN,SAAqC,IAAA,CAAA,EA1DhC,gBA0DC;AAQnB;AAOA,KAtEK,gBAAA,GAsEc,CAAA,KAA4B,CAA5B,EAAA,OAA4B,EAAA,GAAA,IAAA;AAO/C;AAOA;AAQA;AAOA;AAOA;;;;;;;;iBAnFgB,UAAA,WACL,8BACR;;;;;;;;;iBAea,QAAA,WACL,8BACR;;;;;;;cAaU,MAAM;;;;;;;cAQN,IAAI;;;;;;cAOJ,MAAM;;;;;;cAON,MAAM;;;;;;cAON,MAAM;;;;;;;cAQN,eAAe;;;;;;cAOf;;;;;;cAOA"}
|