@logtape/testing-vitest 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 +108 -5
- package/dist/autoload.d.ts +13 -57
- package/dist/autoload.d.ts.map +1 -1
- package/dist/autoload.js +38 -27
- package/dist/autoload.js.map +1 -1
- package/dist/mod.js +6 -5
- package/dist/mod.js.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,8 +1,111 @@
|
|
|
1
|
-
|
|
2
|
-
=======================
|
|
1
|
+
<!-- deno-fmt-ignore-file -->
|
|
3
2
|
|
|
4
|
-
Vitest integration for LogTape
|
|
3
|
+
Vitest integration for LogTape
|
|
4
|
+
==============================
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
[![JSR][JSR badge]][JSR]
|
|
7
|
+
[![npm][npm badge]][npm]
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
*@logtape/testing-vitest* provides a [Vitest] integration for [LogTape]'s
|
|
10
|
+
failure log reporter. Import its `test` or `it` function instead of Vitest's
|
|
11
|
+
own helpers 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-vitest
|
|
15
|
+
[JSR]: https://jsr.io/@logtape/testing-vitest
|
|
16
|
+
[npm badge]: https://img.shields.io/npm/v/@logtape/testing-vitest?logo=npm
|
|
17
|
+
[npm]: https://www.npmjs.com/package/@logtape/testing-vitest
|
|
18
|
+
[Vitest]: https://vitest.dev/
|
|
19
|
+
[LogTape]: https://logtape.org/
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
Installation
|
|
23
|
+
------------
|
|
24
|
+
|
|
25
|
+
~~~~ sh
|
|
26
|
+
npm add @logtape/testing-vitest # for npm
|
|
27
|
+
pnpm add @logtape/testing-vitest # for pnpm
|
|
28
|
+
yarn add @logtape/testing-vitest # for Yarn
|
|
29
|
+
bun add @logtape/testing-vitest # for Bun
|
|
30
|
+
deno add jsr:@logtape/testing-vitest npm:vitest
|
|
31
|
+
~~~~
|
|
32
|
+
|
|
33
|
+
Use this package when your tests are run by Vitest. If you use Deno's
|
|
34
|
+
built-in test runner instead of Vitest, use *@logtape/testing-deno* instead.
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
Usage
|
|
38
|
+
-----
|
|
39
|
+
|
|
40
|
+
~~~~ typescript
|
|
41
|
+
import { expect, test } from "@logtape/testing-vitest/autoload";
|
|
42
|
+
import { getLogger } from "@logtape/logtape";
|
|
43
|
+
|
|
44
|
+
test("case", () => {
|
|
45
|
+
getLogger(["my-lib"]).info("Fixture state: {state}.", {
|
|
46
|
+
state: "ready",
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
expect(1 + 1).toBe(2);
|
|
50
|
+
// Logs emitted here are printed only if this callback fails.
|
|
51
|
+
});
|
|
52
|
+
~~~~
|
|
53
|
+
|
|
54
|
+
The autoload entry point is the easiest setup for large suites. It configures
|
|
55
|
+
the minimal LogTape `contextLocalStorage` needed by the failure log reporter
|
|
56
|
+
when LogTape has not been configured yet. If your suite already configures
|
|
57
|
+
LogTape, that configuration must include `contextLocalStorage`; otherwise, use
|
|
58
|
+
`@logtape/testing-vitest` and manage setup explicitly from Vitest's
|
|
59
|
+
`setupFiles` option.
|
|
60
|
+
|
|
61
|
+
Set `LOGTAPE_TEST_MODE` to `on-failure`, `always`, or `never`, and
|
|
62
|
+
`LOGTAPE_TEST_LOWEST_LEVEL` to a LogTape level such as `debug` or `info` to
|
|
63
|
+
configure the default reporter used by the autoload `test` and `it` exports.
|
|
64
|
+
|
|
65
|
+
Use `createTest()` when a suite needs custom reporter options:
|
|
66
|
+
|
|
67
|
+
~~~~ typescript
|
|
68
|
+
import { createTest } from "@logtape/testing-vitest";
|
|
69
|
+
|
|
70
|
+
const test = createTest({
|
|
71
|
+
lowestLevel: "debug",
|
|
72
|
+
mode: "on-failure",
|
|
73
|
+
});
|
|
74
|
+
~~~~
|
|
75
|
+
|
|
76
|
+
Use `createVitest()` when existing test files import several Vitest helpers and
|
|
77
|
+
you want a namespace-like object:
|
|
78
|
+
|
|
79
|
+
~~~~ typescript
|
|
80
|
+
import { createVitest } from "@logtape/testing-vitest";
|
|
81
|
+
|
|
82
|
+
const { expect, test, vi } = createVitest({
|
|
83
|
+
lowestLevel: "debug",
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test("case", () => {
|
|
87
|
+
expect(typeof vi.fn).toBe("function");
|
|
88
|
+
});
|
|
89
|
+
~~~~
|
|
90
|
+
|
|
91
|
+
The package preserves Vitest test options such as `retry`, `repeats`,
|
|
92
|
+
`timeout`, `concurrent`, `skip`, `only`, `todo`, `fails`, `tags`, and `meta`.
|
|
93
|
+
It also preserves shorthand helpers such as `test.skip()`, `test.todo()`,
|
|
94
|
+
`test.only()`, `test.fails()`, `test.concurrent()`, `test.sequential()`,
|
|
95
|
+
`test.skipIf()`, `test.runIf()`, `test.each()`, `test.for()`, and
|
|
96
|
+
`test.extend()`. It exports a wrapped `it()` alias and `createIt()`. Other
|
|
97
|
+
Vitest helpers, including `describe()`, `suite()`, `beforeAll()`,
|
|
98
|
+
`beforeEach()`, `afterEach()`, `afterAll()`, `aroundAll()`, `aroundEach()`,
|
|
99
|
+
`expect`, `expectTypeOf`, `vi`, `vitest`, `bench()`, `onTestFailed()`, and
|
|
100
|
+
`onTestFinished()`, are re-exported unchanged.
|
|
101
|
+
|
|
102
|
+
This package is ESM-only because Vitest cannot be synchronously imported from
|
|
103
|
+
CommonJS modules.
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
Docs
|
|
107
|
+
----
|
|
108
|
+
|
|
109
|
+
The docs of this package is available at
|
|
110
|
+
<https://logtape.org/manual/testing#vitest-integration>.
|
|
111
|
+
For the API references, see <https://jsr.io/@logtape/testing-vitest/doc>.
|
package/dist/autoload.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { TestAPI, TestAPI as VitestTestFunction, TestContext as VitestTestContext, TestFunction as VitestTestCallback, TestOptions as VitestTestOptions, afterAll, afterEach, aroundAll, aroundEach, assert, beforeAll, beforeEach, bench, chai, createExpect, describe, expect, expectTypeOf, inject, onTestFailed, onTestFinished, should, suite, vi, vitest } from "vitest";
|
|
2
1
|
import { FailureLogReportMode, FailureLogReporterOptions, FailureLogReporterOptions as FailureLogReporterOptions$1 } from "@logtape/testing/reporter";
|
|
2
|
+
import { TestAPI, TestAPI as VitestTestFunction, TestContext as VitestTestContext, TestFunction as VitestTestCallback, TestOptions as VitestTestOptions, afterAll, afterEach, aroundAll, aroundEach, assert, beforeAll, beforeEach, bench, chai, createExpect, describe, expect, expectTypeOf, inject, onTestFailed, onTestFinished, should, suite, vi, vitest } from "vitest";
|
|
3
3
|
|
|
4
4
|
//#region src/mod.d.ts
|
|
5
5
|
|
|
@@ -75,62 +75,18 @@ declare function createVitest(options?: FailureLogReporterOptions$1): VitestTest
|
|
|
75
75
|
*
|
|
76
76
|
* @since 2.3.0
|
|
77
77
|
*/
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
declare const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
*/
|
|
91
|
-
declare const skip: TestAPI["skip"];
|
|
92
|
-
/**
|
|
93
|
-
* Shorthand for marking a test as TODO.
|
|
94
|
-
*
|
|
95
|
-
* @since 2.3.0
|
|
96
|
-
*/
|
|
97
|
-
declare const todo: TestAPI["todo"];
|
|
98
|
-
/**
|
|
99
|
-
* Shorthand for marking a test as `only`.
|
|
100
|
-
*
|
|
101
|
-
* @since 2.3.0
|
|
102
|
-
*/
|
|
103
|
-
declare const only: TestAPI["only"];
|
|
104
|
-
/**
|
|
105
|
-
* Shorthand for marking a test as expected to fail.
|
|
106
|
-
*
|
|
107
|
-
* @since 2.3.0
|
|
108
|
-
*/
|
|
109
|
-
declare const fails: TestAPI["fails"];
|
|
110
|
-
/**
|
|
111
|
-
* Shorthand for running a test concurrently.
|
|
112
|
-
*
|
|
113
|
-
* @since 2.3.0
|
|
114
|
-
*/
|
|
115
|
-
declare const concurrent: TestAPI["concurrent"];
|
|
116
|
-
/**
|
|
117
|
-
* Shorthand for running a test sequentially.
|
|
118
|
-
*
|
|
119
|
-
* @since 2.3.0
|
|
120
|
-
*/
|
|
121
|
-
declare const sequential: TestAPI["sequential"];
|
|
122
|
-
/**
|
|
123
|
-
* Shorthand for Vitest's parameterized tests.
|
|
124
|
-
*
|
|
125
|
-
* @since 2.3.0
|
|
126
|
-
*/
|
|
127
|
-
declare const each: TestAPI["each"];
|
|
128
|
-
/**
|
|
129
|
-
* Shorthand for Vitest's parameterized tests with a preserved test context.
|
|
130
|
-
*
|
|
131
|
-
* @since 2.3.0
|
|
132
|
-
*/
|
|
133
|
-
declare const for_: TestAPI["for"];
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/autoload.d.ts
|
|
80
|
+
declare const test: VitestTestFunction;
|
|
81
|
+
declare const it: VitestTestFunction;
|
|
82
|
+
declare const concurrent: VitestTestFunction["concurrent"];
|
|
83
|
+
declare const each: VitestTestFunction["each"];
|
|
84
|
+
declare const fails: VitestTestFunction["fails"];
|
|
85
|
+
declare const for_: VitestTestFunction["for"];
|
|
86
|
+
declare const only: VitestTestFunction["only"];
|
|
87
|
+
declare const sequential: VitestTestFunction["sequential"];
|
|
88
|
+
declare const skip: VitestTestFunction["skip"];
|
|
89
|
+
declare const todo: VitestTestFunction["todo"];
|
|
134
90
|
//#endregion
|
|
135
91
|
export { FailureLogReportMode, FailureLogReporterOptions, VitestTestCallback, VitestTestContext, VitestTestFunction, VitestTestOptions, VitestTesting, afterAll, afterEach, aroundAll, aroundEach, assert, beforeAll, beforeEach, bench, chai, concurrent, createExpect, createIt, createTest, createVitest, test as default, test, describe, each, expect, expectTypeOf, fails, for_ as for, inject, it, onTestFailed, onTestFinished, only, sequential, should, skip, suite, todo, vi, vitest };
|
|
136
92
|
//# sourceMappingURL=autoload.d.ts.map
|
package/dist/autoload.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autoload.d.ts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AA8E6B,UAPZ,aAAA,CAOY;EAAS,SACR,QAAA,EAAA,OAPF,QAOE;EAAU,SAChB,SAAA,EAAA,OAPK,SAOL;EAAI,SACI,SAAA,EAAA,OAPH,SAOG;EAAY,SAChB,UAAA,EAAA,OAPE,UAOF;EAAQ,SACV,MAAA,EAAA,OAPA,MAOA;EAAM,SACA,KAAA,EAAA,OAPP,KAOO;EAAY,SAClB,SAAA,EAAA,OAPG,SAOH;EAAM,SACjB,UAAA,EAAA,OAPe,UAOf;EAAkB,SACD,IAAA,EAAA,OAPR,IAOQ;EAAY,SACV,YAAA,EAAA,OAPF,YAOE;EAAc,SACtB,QAAA,EAAA,OAPE,QAOF;EAAM,SACP,MAAA,EAAA,OAPC,MAOD;EAAK,SACb,YAAA,EAAA,OAPe,YAOf;EAAkB,SACb,MAAA,EAAA,OAPI,MAOJ;EAAE,SACE,EAAA,EAPX,OAOW;EAAM,SAAA,YAAA,EAAA,OANA,YAMA;EAsEhB,SAAA,cAAU,EAAA,OA3EQ,cA2ER;EAAA,SAAA,MAAA,EAAA,OA1EA,MA0EA;EAAA,SACf,KAAA,EAAA,OA1Ec,KA0Ed;EAA8B,SACtC,IAAA,EA1Ec,OA0Ed;EAAkB,SAAA,EAAA,EAAA,OAzEC,EAyED;EAeL,SAAA,MAAQ,EAAA,OAvFE,MAuFF;;;;AAEH;AAkBrB;;;;AAEgB;
|
|
1
|
+
{"version":3,"file":"autoload.d.ts","names":[],"sources":["../src/mod.ts","../src/autoload.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;AA8E6B,UAPZ,aAAA,CAOY;EAAS,SACR,QAAA,EAAA,OAPF,QAOE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,IDLuB,ECKjB,kBDLiB,CAAA,MAAA,CAAA;cCMvB,UDLwB,ECKZ,kBDLY,CAAA,YAAA,CAAA;cCMxB,IDLoB,ECKd,kBDLc,CAAA,MAAA,CAAA;cCMpB,IDLmB,ECKb,kBDLa,CAAA,MAAA,CAAA"}
|
package/dist/autoload.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
2
|
import { ConfigError, configureSync, getConfig } from "@logtape/logtape";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { createFailureLogReporter, getFailureLogReporterOptionsFromEnv } from "@logtape/testing/reporter";
|
|
4
|
+
import { afterAll, afterEach, aroundAll, aroundEach, assert, beforeAll, beforeEach, bench, chai, createExpect, describe, expect, expectTypeOf, inject, it as it$1, onTestFailed, onTestFinished, should, suite, test as test$1, vi, vitest } from "vitest";
|
|
5
5
|
|
|
6
6
|
//#region src/mod.ts
|
|
7
7
|
const helperNames = [
|
|
@@ -37,7 +37,7 @@ const nestedSuiteNames = ["describe", "suite"];
|
|
|
37
37
|
* @since 2.3.0
|
|
38
38
|
*/
|
|
39
39
|
function createTest(options = {}) {
|
|
40
|
-
return createVitestTestFunction(test, options);
|
|
40
|
+
return createVitestTestFunction(test$1, options);
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Creates an `it()` alias that reports LogTape records from failed test
|
|
@@ -93,76 +93,76 @@ function createVitest(options = {}) {
|
|
|
93
93
|
*
|
|
94
94
|
* @since 2.3.0
|
|
95
95
|
*/
|
|
96
|
-
const test$
|
|
96
|
+
const test$2 = createTest();
|
|
97
97
|
/**
|
|
98
98
|
* A Vitest `it()` alias that reports LogTape records from failed test
|
|
99
99
|
* callbacks using the default reporter options.
|
|
100
100
|
*
|
|
101
101
|
* @since 2.3.0
|
|
102
102
|
*/
|
|
103
|
-
const it = createIt();
|
|
103
|
+
const it$2 = createIt();
|
|
104
104
|
/**
|
|
105
105
|
* Shorthand for skipping a test.
|
|
106
106
|
*
|
|
107
107
|
* @since 2.3.0
|
|
108
108
|
*/
|
|
109
|
-
const skip = test$
|
|
109
|
+
const skip$1 = test$2.skip;
|
|
110
110
|
/**
|
|
111
111
|
* Shorthand for marking a test as TODO.
|
|
112
112
|
*
|
|
113
113
|
* @since 2.3.0
|
|
114
114
|
*/
|
|
115
|
-
const todo = test$
|
|
115
|
+
const todo$1 = test$2.todo;
|
|
116
116
|
/**
|
|
117
117
|
* Shorthand for marking a test as `only`.
|
|
118
118
|
*
|
|
119
119
|
* @since 2.3.0
|
|
120
120
|
*/
|
|
121
|
-
const only = test$
|
|
121
|
+
const only$1 = test$2.only;
|
|
122
122
|
/**
|
|
123
123
|
* Shorthand for marking a test as expected to fail.
|
|
124
124
|
*
|
|
125
125
|
* @since 2.3.0
|
|
126
126
|
*/
|
|
127
|
-
const fails = test$
|
|
127
|
+
const fails$1 = test$2.fails;
|
|
128
128
|
/**
|
|
129
129
|
* Shorthand for running a test concurrently.
|
|
130
130
|
*
|
|
131
131
|
* @since 2.3.0
|
|
132
132
|
*/
|
|
133
|
-
const concurrent = test$
|
|
133
|
+
const concurrent$1 = test$2.concurrent;
|
|
134
134
|
/**
|
|
135
135
|
* Shorthand for running a test sequentially.
|
|
136
136
|
*
|
|
137
137
|
* @since 2.3.0
|
|
138
138
|
*/
|
|
139
|
-
const sequential = test$
|
|
139
|
+
const sequential$1 = test$2.sequential;
|
|
140
140
|
/**
|
|
141
141
|
* Shorthand for Vitest's parameterized tests.
|
|
142
142
|
*
|
|
143
143
|
* @since 2.3.0
|
|
144
144
|
*/
|
|
145
|
-
const each = test$
|
|
145
|
+
const each$1 = test$2.each;
|
|
146
146
|
/**
|
|
147
147
|
* Shorthand for Vitest's parameterized tests with a preserved test context.
|
|
148
148
|
*
|
|
149
149
|
* @since 2.3.0
|
|
150
150
|
*/
|
|
151
|
-
const for_ = test$
|
|
152
|
-
|
|
153
|
-
function createVitestTestFunction(baseTest, options, cache = /* @__PURE__ */ new WeakMap(), depth = 0) {
|
|
151
|
+
const for_$1 = test$2.for;
|
|
152
|
+
function createVitestTestFunction(baseTest, options, cache = /* @__PURE__ */ new WeakMap()) {
|
|
154
153
|
const cached = cache.get(baseTest);
|
|
155
154
|
if (cached != null) return cached;
|
|
156
155
|
const register = (...args) => Reflect.apply(baseTest, void 0, wrapVitestArguments(args, options));
|
|
157
156
|
cache.set(baseTest, register);
|
|
158
|
-
|
|
157
|
+
for (const helperName of helperNames) {
|
|
159
158
|
const helper = getFunctionProperty(baseTest, helperName);
|
|
160
159
|
if (helper == null) continue;
|
|
161
160
|
Object.defineProperty(register, helperName, {
|
|
162
161
|
configurable: true,
|
|
163
162
|
enumerable: true,
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
get() {
|
|
164
|
+
return createVitestTestFunction(helper, options, cache);
|
|
165
|
+
}
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
168
|
for (const helperName of conditionalHelperNames) {
|
|
@@ -173,7 +173,7 @@ function createVitestTestFunction(baseTest, options, cache = /* @__PURE__ */ new
|
|
|
173
173
|
enumerable: true,
|
|
174
174
|
value: (condition) => {
|
|
175
175
|
const conditionalTest = Reflect.apply(helper, baseTest, [condition]);
|
|
176
|
-
return createVitestTestFunction(conditionalTest, options, cache
|
|
176
|
+
return createVitestTestFunction(conditionalTest, options, cache);
|
|
177
177
|
},
|
|
178
178
|
writable: true
|
|
179
179
|
});
|
|
@@ -198,18 +198,18 @@ function createVitestTestFunction(baseTest, options, cache = /* @__PURE__ */ new
|
|
|
198
198
|
writable: true
|
|
199
199
|
});
|
|
200
200
|
}
|
|
201
|
-
const each$
|
|
202
|
-
if (each$
|
|
201
|
+
const each$2 = getFunctionProperty(baseTest, "each");
|
|
202
|
+
if (each$2 != null) Object.defineProperty(register, "each", {
|
|
203
203
|
configurable: true,
|
|
204
204
|
enumerable: true,
|
|
205
|
-
value: createWrappedParameterized(baseTest, each$
|
|
205
|
+
value: createWrappedParameterized(baseTest, each$2, options),
|
|
206
206
|
writable: true
|
|
207
207
|
});
|
|
208
|
-
const for_$
|
|
209
|
-
if (for_$
|
|
208
|
+
const for_$2 = getFunctionProperty(baseTest, "for");
|
|
209
|
+
if (for_$2 != null) Object.defineProperty(register, "for", {
|
|
210
210
|
configurable: true,
|
|
211
211
|
enumerable: true,
|
|
212
|
-
value: createWrappedParameterized(baseTest, for_$
|
|
212
|
+
value: createWrappedParameterized(baseTest, for_$2, options),
|
|
213
213
|
writable: true
|
|
214
214
|
});
|
|
215
215
|
const extend = getFunctionProperty(baseTest, "extend");
|
|
@@ -299,8 +299,19 @@ if (config == null) configureSync({
|
|
|
299
299
|
}]
|
|
300
300
|
});
|
|
301
301
|
else if (config.contextLocalStorage == null) throw new ConfigError("@logtape/testing-vitest/autoload requires the existing LogTape configuration to provide contextLocalStorage.");
|
|
302
|
-
|
|
302
|
+
const reporterOptions = getFailureLogReporterOptionsFromEnv({ getEnv: (name) => process.env[name] });
|
|
303
|
+
const test = createTest(reporterOptions);
|
|
304
|
+
const it = createIt(reporterOptions);
|
|
305
|
+
const concurrent = test.concurrent;
|
|
306
|
+
const each = test.each;
|
|
307
|
+
const fails = test.fails;
|
|
308
|
+
const for_ = test.for;
|
|
309
|
+
const only = test.only;
|
|
310
|
+
const sequential = test.sequential;
|
|
311
|
+
const skip = test.skip;
|
|
312
|
+
const todo = test.todo;
|
|
313
|
+
var autoload_default = test;
|
|
303
314
|
|
|
304
315
|
//#endregion
|
|
305
|
-
export { afterAll, afterEach, aroundAll, aroundEach, assert, beforeAll, beforeEach, bench, chai, concurrent, createExpect, createIt, createTest, createVitest, autoload_default as default, describe, each, expect, expectTypeOf, fails, for_ as for, inject, it, onTestFailed, onTestFinished, only, sequential, should, skip, suite,
|
|
316
|
+
export { afterAll, afterEach, aroundAll, aroundEach, assert, beforeAll, beforeEach, bench, chai, concurrent, createExpect, createIt, createTest, createVitest, autoload_default as default, describe, each, expect, expectTypeOf, fails, for_ as for, inject, it, onTestFailed, onTestFinished, only, sequential, should, skip, suite, test, todo, vi, vitest };
|
|
306
317
|
//# sourceMappingURL=autoload.js.map
|
package/dist/autoload.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autoload.js","names":["options: FailureLogReporterOptions","vitestTest","vitestIt","test: VitestTestFunction","it: VitestTestFunction","skip: VitestTestFunction[\"skip\"]","test","todo: VitestTestFunction[\"todo\"]","only: VitestTestFunction[\"only\"]","fails: VitestTestFunction[\"fails\"]","concurrent: VitestTestFunction[\"concurrent\"]","sequential: VitestTestFunction[\"sequential\"]","each: VitestTestFunction[\"each\"]","for_: VitestTestFunction[\"for\"]","baseTest: BaseVitestTestFunction","cache: WeakMap<BaseVitestTestFunction, VitestTestFunction>","condition: unknown","each","for_","baseParameterized: AnyFunction","baseFunction: AnyFunction","args: readonly unknown[]","callback: AnyFunction","value: BaseVitestTestFunction","property: string","test"],"sources":["../src/mod.ts","../src/autoload.ts"],"sourcesContent":["import {\n afterAll,\n afterEach,\n aroundAll,\n aroundEach,\n assert,\n beforeAll,\n beforeEach,\n bench,\n chai,\n createExpect,\n describe,\n expect,\n expectTypeOf,\n inject,\n it as vitestIt,\n onTestFailed,\n onTestFinished,\n should,\n suite,\n test as vitestTest,\n vi,\n vitest,\n} from \"vitest\";\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 type {\n TestAPI as VitestTestFunction,\n TestContext as VitestTestContext,\n TestFunction as VitestTestCallback,\n TestOptions as VitestTestOptions,\n} from \"vitest\";\nexport {\n afterAll,\n afterEach,\n aroundAll,\n aroundEach,\n assert,\n beforeAll,\n beforeEach,\n bench,\n chai,\n createExpect,\n describe,\n expect,\n expectTypeOf,\n inject,\n onTestFailed,\n onTestFinished,\n should,\n suite,\n vi,\n vitest,\n};\n\nimport type { TestAPI as VitestTestFunction } from \"vitest\";\n\n/**\n * A Vitest-compatible namespace with LogTape-wrapped `test()` and `it()`\n * functions.\n *\n * @since 2.3.0\n */\nexport interface VitestTesting {\n readonly afterAll: typeof afterAll;\n readonly afterEach: typeof afterEach;\n readonly aroundAll: typeof aroundAll;\n readonly aroundEach: typeof aroundEach;\n readonly assert: typeof assert;\n readonly bench: typeof bench;\n readonly beforeAll: typeof beforeAll;\n readonly beforeEach: typeof beforeEach;\n readonly chai: typeof chai;\n readonly createExpect: typeof createExpect;\n readonly describe: typeof describe;\n readonly expect: typeof expect;\n readonly expectTypeOf: typeof expectTypeOf;\n readonly inject: typeof inject;\n readonly it: VitestTestFunction;\n readonly onTestFailed: typeof onTestFailed;\n readonly onTestFinished: typeof onTestFinished;\n readonly should: typeof should;\n readonly suite: typeof suite;\n readonly test: VitestTestFunction;\n readonly vi: typeof vi;\n readonly vitest: typeof vitest;\n}\n\ntype AnyFunction = (...args: never[]) => unknown;\ntype BaseVitestTestFunction = AnyFunction & {\n readonly skip?: BaseVitestTestFunction;\n readonly todo?: BaseVitestTestFunction;\n readonly only?: BaseVitestTestFunction;\n readonly fails?: BaseVitestTestFunction;\n readonly concurrent?: BaseVitestTestFunction;\n readonly sequential?: BaseVitestTestFunction;\n readonly each?: AnyFunction;\n readonly for?: AnyFunction;\n readonly skipIf?: AnyFunction;\n readonly runIf?: AnyFunction;\n readonly extend?: AnyFunction;\n readonly override?: AnyFunction;\n readonly scoped?: AnyFunction;\n readonly beforeAll?: AnyFunction;\n readonly afterAll?: AnyFunction;\n readonly aroundAll?: AnyFunction;\n readonly beforeEach?: AnyFunction;\n readonly afterEach?: AnyFunction;\n readonly aroundEach?: AnyFunction;\n readonly describe?: AnyFunction;\n readonly suite?: AnyFunction;\n};\n\nconst helperNames = [\n \"skip\",\n \"todo\",\n \"only\",\n \"fails\",\n \"concurrent\",\n \"sequential\",\n] as const;\n\nconst conditionalHelperNames = [\n \"skipIf\",\n \"runIf\",\n] as const;\n\nconst hookNames = [\n \"beforeAll\",\n \"afterAll\",\n \"aroundAll\",\n \"beforeEach\",\n \"afterEach\",\n \"aroundEach\",\n] as const;\n\nconst nestedSuiteNames = [\n \"describe\",\n \"suite\",\n] as const;\n\n/**\n * Creates a Vitest `test()` function that reports LogTape records from failed\n * test callbacks.\n *\n * The returned function preserves Vitest test options and shorthand helpers\n * such as `test.skip()`, `test.todo()`, `test.only()`, `test.fails()`,\n * `test.concurrent()`, `test.sequential()`, `test.skipIf()`,\n * `test.runIf()`, `test.each()`, `test.for()`, and `test.extend()`. Only\n * callback arguments are adapted; options are passed through to Vitest.\n *\n * @param options Failure log reporter options.\n * @returns A configured Vitest-compatible test function.\n * @since 2.3.0\n */\nexport function createTest(\n options: FailureLogReporterOptions = {},\n): VitestTestFunction {\n return createVitestTestFunction(\n vitestTest as unknown as BaseVitestTestFunction,\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 Vitest-compatible `it()` function.\n * @since 2.3.0\n */\nexport function createIt(\n options: FailureLogReporterOptions = {},\n): VitestTestFunction {\n return createVitestTestFunction(\n vitestIt as unknown as BaseVitestTestFunction,\n options,\n );\n}\n\n/**\n * Creates a Vitest-compatible namespace with wrapped `test()` and `it()`\n * functions.\n *\n * This is useful when existing test files already import several helpers from\n * Vitest and you want to switch them to one LogTape-aware namespace.\n *\n * @param options Failure log reporter options.\n * @returns A Vitest-compatible namespace.\n * @since 2.3.0\n */\nexport function createVitest(\n options: FailureLogReporterOptions = {},\n): VitestTesting {\n return {\n afterAll,\n afterEach,\n aroundAll,\n aroundEach,\n assert,\n bench,\n beforeAll,\n beforeEach,\n chai,\n createExpect,\n describe,\n expect,\n expectTypeOf,\n inject,\n it: createIt(options),\n onTestFailed,\n onTestFinished,\n should,\n suite,\n test: createTest(options),\n vi,\n vitest,\n };\n}\n\n/**\n * A Vitest `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: VitestTestFunction = createTest();\n\n/**\n * A Vitest `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: VitestTestFunction = createIt();\n\n/**\n * Shorthand for skipping a test.\n *\n * @since 2.3.0\n */\nexport const skip: VitestTestFunction[\"skip\"] = test.skip;\n\n/**\n * Shorthand for marking a test as TODO.\n *\n * @since 2.3.0\n */\nexport const todo: VitestTestFunction[\"todo\"] = test.todo;\n\n/**\n * Shorthand for marking a test as `only`.\n *\n * @since 2.3.0\n */\nexport const only: VitestTestFunction[\"only\"] = test.only;\n\n/**\n * Shorthand for marking a test as expected to fail.\n *\n * @since 2.3.0\n */\nexport const fails: VitestTestFunction[\"fails\"] = test.fails;\n\n/**\n * Shorthand for running a test concurrently.\n *\n * @since 2.3.0\n */\nexport const concurrent: VitestTestFunction[\"concurrent\"] = test.concurrent;\n\n/**\n * Shorthand for running a test sequentially.\n *\n * @since 2.3.0\n */\nexport const sequential: VitestTestFunction[\"sequential\"] = test.sequential;\n\n/**\n * Shorthand for Vitest's parameterized tests.\n *\n * @since 2.3.0\n */\nexport const each: VitestTestFunction[\"each\"] = test.each;\n\n/**\n * Shorthand for Vitest's parameterized tests with a preserved test context.\n *\n * @since 2.3.0\n */\nconst for_: VitestTestFunction[\"for\"] = test.for;\n\nexport { for_ as for };\nexport default test;\n\nfunction createVitestTestFunction(\n baseTest: BaseVitestTestFunction,\n options: FailureLogReporterOptions,\n cache: WeakMap<BaseVitestTestFunction, VitestTestFunction> = new WeakMap(),\n depth = 0,\n): VitestTestFunction {\n const cached = cache.get(baseTest);\n if (cached != null) return cached;\n\n const register = ((...args: unknown[]) =>\n Reflect.apply(\n baseTest,\n undefined,\n wrapVitestArguments(args, options),\n )) as unknown as VitestTestFunction;\n cache.set(baseTest, register);\n\n if (depth < 2) {\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: createVitestTestFunction(\n helper as BaseVitestTestFunction,\n options,\n cache,\n depth + 1,\n ),\n writable: true,\n });\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 createVitestTestFunction(\n conditionalTest as BaseVitestTestFunction,\n options,\n cache,\n depth + 1,\n );\n }) as VitestTestFunction[typeof helperName],\n writable: true,\n });\n }\n\n for (const helperName of hookNames) {\n const helper = getFunctionProperty(baseTest, helperName);\n if (helper == null) continue;\n Object.defineProperty(register, helperName, {\n configurable: true,\n enumerable: true,\n value: createWrappedFunction(helper, options),\n writable: true,\n });\n }\n\n for (const helperName of nestedSuiteNames) {\n const helper = getFunctionProperty(baseTest, helperName);\n if (helper == null) continue;\n Object.defineProperty(register, helperName, {\n configurable: true,\n enumerable: true,\n value: helper,\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: createWrappedParameterized(baseTest, each, options),\n writable: true,\n });\n }\n\n const for_ = getFunctionProperty(baseTest, \"for\");\n if (for_ != null) {\n Object.defineProperty(register, \"for\", {\n configurable: true,\n enumerable: true,\n value: createWrappedParameterized(baseTest, for_, options),\n writable: true,\n });\n }\n\n const extend = getFunctionProperty(baseTest, \"extend\");\n if (extend != null) {\n Object.defineProperty(register, \"extend\", {\n configurable: true,\n enumerable: true,\n value: ((...args: never[]) => {\n const extendedTest = Reflect.apply(extend, baseTest, args);\n return createVitestTestFunction(\n extendedTest as BaseVitestTestFunction,\n options,\n cache,\n );\n }) as VitestTestFunction[\"extend\"],\n writable: true,\n });\n }\n\n const override = getFunctionProperty(baseTest, \"override\");\n if (override != null) {\n Object.defineProperty(register, \"override\", {\n configurable: true,\n enumerable: true,\n value: override,\n writable: true,\n });\n }\n\n const scoped = getFunctionProperty(baseTest, \"scoped\");\n if (scoped != null) {\n Object.defineProperty(register, \"scoped\", {\n configurable: true,\n enumerable: true,\n value: scoped,\n writable: true,\n });\n }\n\n return register;\n}\n\nfunction createWrappedParameterized(\n baseTest: BaseVitestTestFunction,\n baseParameterized: AnyFunction,\n options: FailureLogReporterOptions,\n): AnyFunction {\n return ((...cases: readonly unknown[]) => {\n const registerParameterized = Reflect.apply(\n baseParameterized,\n baseTest,\n cases,\n );\n return ((...args: unknown[]) =>\n Reflect.apply(\n registerParameterized as AnyFunction,\n undefined,\n wrapVitestParameterizedArguments(args, options),\n )) as AnyFunction;\n }) as AnyFunction;\n}\n\nfunction createWrappedFunction(\n baseFunction: AnyFunction,\n options: FailureLogReporterOptions,\n): AnyFunction {\n return function (this: unknown, ...args: never[]): unknown {\n return Reflect.apply(\n baseFunction,\n this,\n wrapVitestArguments(args, options),\n );\n };\n}\n\nfunction wrapVitestArguments(\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 wrapVitestCallback(args[callbackIndex] as AnyFunction, options),\n ...args.slice(callbackIndex + 1),\n ];\n}\n\nfunction wrapVitestParameterizedArguments(\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 wrapVitestCallback(args[callbackIndex] as AnyFunction, options),\n ...args.slice(callbackIndex + 1),\n ];\n}\n\nfunction wrapVitestCallback(\n callback: AnyFunction,\n options: FailureLogReporterOptions,\n): AnyFunction {\n const reporter = createFailureLogReporter(options);\n const wrapped = function (this: unknown, ...args: never[]) {\n return reporter.run(() => Reflect.apply(callback, this, args));\n };\n Object.defineProperty(wrapped, \"toString\", {\n configurable: true,\n value: () => String(callback),\n });\n return wrapped;\n}\n\nfunction getFunctionProperty(\n value: BaseVitestTestFunction,\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 aroundAll,\n aroundEach,\n assert,\n beforeAll,\n beforeEach,\n bench,\n chai,\n concurrent,\n createExpect,\n createIt,\n createTest,\n createVitest,\n default as test,\n describe,\n each,\n expect,\n expectTypeOf,\n fails,\n for as for_,\n inject,\n it,\n only,\n onTestFailed,\n onTestFinished,\n sequential,\n should,\n skip,\n suite,\n todo,\n vi,\n vitest,\n} from \"./mod.ts\";\n\nexport type {\n FailureLogReporterOptions,\n FailureLogReportMode,\n VitestTestCallback,\n VitestTestContext,\n VitestTestFunction,\n VitestTesting,\n VitestTestOptions,\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-vitest/autoload requires the existing LogTape \" +\n \"configuration to provide contextLocalStorage.\",\n );\n}\n\nexport {\n afterAll,\n afterEach,\n aroundAll,\n aroundEach,\n assert,\n beforeAll,\n beforeEach,\n bench,\n chai,\n concurrent,\n createExpect,\n createIt,\n createTest,\n createVitest,\n describe,\n each,\n expect,\n expectTypeOf,\n fails,\n inject,\n it,\n only,\n onTestFailed,\n onTestFinished,\n sequential,\n should,\n skip,\n suite,\n test,\n todo,\n vi,\n vitest,\n};\nexport { for_ as for };\nexport default test;\n"],"mappings":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CACX,MAAM,gBAAgB,KAAK,UAAU,CAAC,KAAK,UACzC,QAAQ,YAAY,QAAQ,WAC7B;AACD,KAAI,gBAAgB,EAAG,QAAO,CAAC,GAAG,IAAK;AAEvC,QAAO;EACL,GAAG,KAAK,MAAM,GAAG,cAAc;EAC/B,mBAAmB,KAAK,gBAA+B,QAAQ;EAC/D,GAAG,KAAK,MAAM,gBAAgB,EAAE;CACjC;AACF;AAED,SAAS,mBACPsB,UACAtB,SACa;CACb,MAAM,WAAW,yBAAyB,QAAQ;CAClD,MAAM,UAAU,SAAyB,GAAG,MAAe;AACzD,SAAO,SAAS,IAAI,MAAM,QAAQ,MAAM,UAAU,MAAM,KAAK,CAAC;CAC/D;AACD,QAAO,eAAe,SAAS,YAAY;EACzC,cAAc;EACd,OAAO,MAAM,OAAO,SAAS;CAC9B,EAAC;AACF,QAAO;AACR;AAED,SAAS,oBACPuB,OACAC,UACyB;AACzB,KAAI;EACF,MAAM,gBAAgB,QAAQ,IAAI,OAAO,SAAS;AAClD,gBAAc,kBAAkB,aAAa;CAC9C,QAAO;AACN;CACD;AACF;;;;ACzdD,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;AAwCJ,uBAAeC"}
|
|
1
|
+
{"version":3,"file":"autoload.js","names":["options: FailureLogReporterOptions","vitestTest","vitestIt","test: VitestTestFunction","it: VitestTestFunction","skip: VitestTestFunction[\"skip\"]","test","todo: VitestTestFunction[\"todo\"]","only: VitestTestFunction[\"only\"]","fails: VitestTestFunction[\"fails\"]","concurrent: VitestTestFunction[\"concurrent\"]","sequential: VitestTestFunction[\"sequential\"]","each: VitestTestFunction[\"each\"]","for_: VitestTestFunction[\"for\"]","baseTest: BaseVitestTestFunction","cache: WeakMap<BaseVitestTestFunction, VitestTestFunction>","register: VitestTestFunction","condition: unknown","each","for_","baseParameterized: AnyFunction","baseFunction: AnyFunction","args: readonly unknown[]","callback: AnyFunction","value: BaseVitestTestFunction","property: string","reporterOptions: FailureLogReporterOptions","test: VitestTestFunction","it: VitestTestFunction","concurrent: VitestTestFunction[\"concurrent\"]","each: VitestTestFunction[\"each\"]","fails: VitestTestFunction[\"fails\"]","for_: VitestTestFunction[\"for\"]","only: VitestTestFunction[\"only\"]","sequential: VitestTestFunction[\"sequential\"]","skip: VitestTestFunction[\"skip\"]","todo: VitestTestFunction[\"todo\"]"],"sources":["../src/mod.ts","../src/autoload.ts"],"sourcesContent":["import {\n afterAll,\n afterEach,\n aroundAll,\n aroundEach,\n assert,\n beforeAll,\n beforeEach,\n bench,\n chai,\n createExpect,\n describe,\n expect,\n expectTypeOf,\n inject,\n it as vitestIt,\n onTestFailed,\n onTestFinished,\n should,\n suite,\n test as vitestTest,\n vi,\n vitest,\n} from \"vitest\";\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 type {\n TestAPI as VitestTestFunction,\n TestContext as VitestTestContext,\n TestFunction as VitestTestCallback,\n TestOptions as VitestTestOptions,\n} from \"vitest\";\nexport {\n afterAll,\n afterEach,\n aroundAll,\n aroundEach,\n assert,\n beforeAll,\n beforeEach,\n bench,\n chai,\n createExpect,\n describe,\n expect,\n expectTypeOf,\n inject,\n onTestFailed,\n onTestFinished,\n should,\n suite,\n vi,\n vitest,\n};\n\nimport type { TestAPI as VitestTestFunction } from \"vitest\";\n\n/**\n * A Vitest-compatible namespace with LogTape-wrapped `test()` and `it()`\n * functions.\n *\n * @since 2.3.0\n */\nexport interface VitestTesting {\n readonly afterAll: typeof afterAll;\n readonly afterEach: typeof afterEach;\n readonly aroundAll: typeof aroundAll;\n readonly aroundEach: typeof aroundEach;\n readonly assert: typeof assert;\n readonly bench: typeof bench;\n readonly beforeAll: typeof beforeAll;\n readonly beforeEach: typeof beforeEach;\n readonly chai: typeof chai;\n readonly createExpect: typeof createExpect;\n readonly describe: typeof describe;\n readonly expect: typeof expect;\n readonly expectTypeOf: typeof expectTypeOf;\n readonly inject: typeof inject;\n readonly it: VitestTestFunction;\n readonly onTestFailed: typeof onTestFailed;\n readonly onTestFinished: typeof onTestFinished;\n readonly should: typeof should;\n readonly suite: typeof suite;\n readonly test: VitestTestFunction;\n readonly vi: typeof vi;\n readonly vitest: typeof vitest;\n}\n\ntype AnyFunction = (...args: never[]) => unknown;\ntype BaseVitestTestFunction = AnyFunction & {\n readonly skip?: BaseVitestTestFunction;\n readonly todo?: BaseVitestTestFunction;\n readonly only?: BaseVitestTestFunction;\n readonly fails?: BaseVitestTestFunction;\n readonly concurrent?: BaseVitestTestFunction;\n readonly sequential?: BaseVitestTestFunction;\n readonly each?: AnyFunction;\n readonly for?: AnyFunction;\n readonly skipIf?: AnyFunction;\n readonly runIf?: AnyFunction;\n readonly extend?: AnyFunction;\n readonly override?: AnyFunction;\n readonly scoped?: AnyFunction;\n readonly beforeAll?: AnyFunction;\n readonly afterAll?: AnyFunction;\n readonly aroundAll?: AnyFunction;\n readonly beforeEach?: AnyFunction;\n readonly afterEach?: AnyFunction;\n readonly aroundEach?: AnyFunction;\n readonly describe?: AnyFunction;\n readonly suite?: AnyFunction;\n};\n\nconst helperNames = [\n \"skip\",\n \"todo\",\n \"only\",\n \"fails\",\n \"concurrent\",\n \"sequential\",\n] as const;\n\nconst conditionalHelperNames = [\n \"skipIf\",\n \"runIf\",\n] as const;\n\nconst hookNames = [\n \"beforeAll\",\n \"afterAll\",\n \"aroundAll\",\n \"beforeEach\",\n \"afterEach\",\n \"aroundEach\",\n] as const;\n\nconst nestedSuiteNames = [\n \"describe\",\n \"suite\",\n] as const;\n\n/**\n * Creates a Vitest `test()` function that reports LogTape records from failed\n * test callbacks.\n *\n * The returned function preserves Vitest test options and shorthand helpers\n * such as `test.skip()`, `test.todo()`, `test.only()`, `test.fails()`,\n * `test.concurrent()`, `test.sequential()`, `test.skipIf()`,\n * `test.runIf()`, `test.each()`, `test.for()`, and `test.extend()`. Only\n * callback arguments are adapted; options are passed through to Vitest.\n *\n * @param options Failure log reporter options.\n * @returns A configured Vitest-compatible test function.\n * @since 2.3.0\n */\nexport function createTest(\n options: FailureLogReporterOptions = {},\n): VitestTestFunction {\n return createVitestTestFunction(\n vitestTest as unknown as BaseVitestTestFunction,\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 Vitest-compatible `it()` function.\n * @since 2.3.0\n */\nexport function createIt(\n options: FailureLogReporterOptions = {},\n): VitestTestFunction {\n return createVitestTestFunction(\n vitestIt as unknown as BaseVitestTestFunction,\n options,\n );\n}\n\n/**\n * Creates a Vitest-compatible namespace with wrapped `test()` and `it()`\n * functions.\n *\n * This is useful when existing test files already import several helpers from\n * Vitest and you want to switch them to one LogTape-aware namespace.\n *\n * @param options Failure log reporter options.\n * @returns A Vitest-compatible namespace.\n * @since 2.3.0\n */\nexport function createVitest(\n options: FailureLogReporterOptions = {},\n): VitestTesting {\n return {\n afterAll,\n afterEach,\n aroundAll,\n aroundEach,\n assert,\n bench,\n beforeAll,\n beforeEach,\n chai,\n createExpect,\n describe,\n expect,\n expectTypeOf,\n inject,\n it: createIt(options),\n onTestFailed,\n onTestFinished,\n should,\n suite,\n test: createTest(options),\n vi,\n vitest,\n };\n}\n\n/**\n * A Vitest `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: VitestTestFunction = createTest();\n\n/**\n * A Vitest `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: VitestTestFunction = createIt();\n\n/**\n * Shorthand for skipping a test.\n *\n * @since 2.3.0\n */\nexport const skip: VitestTestFunction[\"skip\"] = test.skip;\n\n/**\n * Shorthand for marking a test as TODO.\n *\n * @since 2.3.0\n */\nexport const todo: VitestTestFunction[\"todo\"] = test.todo;\n\n/**\n * Shorthand for marking a test as `only`.\n *\n * @since 2.3.0\n */\nexport const only: VitestTestFunction[\"only\"] = test.only;\n\n/**\n * Shorthand for marking a test as expected to fail.\n *\n * @since 2.3.0\n */\nexport const fails: VitestTestFunction[\"fails\"] = test.fails;\n\n/**\n * Shorthand for running a test concurrently.\n *\n * @since 2.3.0\n */\nexport const concurrent: VitestTestFunction[\"concurrent\"] = test.concurrent;\n\n/**\n * Shorthand for running a test sequentially.\n *\n * @since 2.3.0\n */\nexport const sequential: VitestTestFunction[\"sequential\"] = test.sequential;\n\n/**\n * Shorthand for Vitest's parameterized tests.\n *\n * @since 2.3.0\n */\nexport const each: VitestTestFunction[\"each\"] = test.each;\n\n/**\n * Shorthand for Vitest's parameterized tests with a preserved test context.\n *\n * @since 2.3.0\n */\nconst for_: VitestTestFunction[\"for\"] = test.for;\n\nexport { for_ as for };\nexport default test;\n\nfunction createVitestTestFunction(\n baseTest: BaseVitestTestFunction,\n options: FailureLogReporterOptions,\n cache: WeakMap<BaseVitestTestFunction, VitestTestFunction> = new WeakMap(),\n): VitestTestFunction {\n const cached = cache.get(baseTest);\n if (cached != null) return cached;\n\n const register: VitestTestFunction = ((...args: unknown[]) =>\n Reflect.apply(\n baseTest,\n undefined,\n wrapVitestArguments(args, options),\n )) as unknown as VitestTestFunction;\n cache.set(baseTest, register);\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 get() {\n return createVitestTestFunction(\n helper as BaseVitestTestFunction,\n options,\n cache,\n );\n },\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 createVitestTestFunction(\n conditionalTest as BaseVitestTestFunction,\n options,\n cache,\n );\n }) as VitestTestFunction[typeof helperName],\n writable: true,\n });\n }\n\n for (const helperName of hookNames) {\n const helper = getFunctionProperty(baseTest, helperName);\n if (helper == null) continue;\n Object.defineProperty(register, helperName, {\n configurable: true,\n enumerable: true,\n value: createWrappedFunction(helper, options),\n writable: true,\n });\n }\n\n for (const helperName of nestedSuiteNames) {\n const helper = getFunctionProperty(baseTest, helperName);\n if (helper == null) continue;\n Object.defineProperty(register, helperName, {\n configurable: true,\n enumerable: true,\n value: helper,\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: createWrappedParameterized(baseTest, each, options),\n writable: true,\n });\n }\n\n const for_ = getFunctionProperty(baseTest, \"for\");\n if (for_ != null) {\n Object.defineProperty(register, \"for\", {\n configurable: true,\n enumerable: true,\n value: createWrappedParameterized(baseTest, for_, options),\n writable: true,\n });\n }\n\n const extend = getFunctionProperty(baseTest, \"extend\");\n if (extend != null) {\n Object.defineProperty(register, \"extend\", {\n configurable: true,\n enumerable: true,\n value: ((...args: never[]) => {\n const extendedTest = Reflect.apply(extend, baseTest, args);\n return createVitestTestFunction(\n extendedTest as BaseVitestTestFunction,\n options,\n cache,\n );\n }) as VitestTestFunction[\"extend\"],\n writable: true,\n });\n }\n\n const override = getFunctionProperty(baseTest, \"override\");\n if (override != null) {\n Object.defineProperty(register, \"override\", {\n configurable: true,\n enumerable: true,\n value: override,\n writable: true,\n });\n }\n\n const scoped = getFunctionProperty(baseTest, \"scoped\");\n if (scoped != null) {\n Object.defineProperty(register, \"scoped\", {\n configurable: true,\n enumerable: true,\n value: scoped,\n writable: true,\n });\n }\n\n return register;\n}\n\nfunction createWrappedParameterized(\n baseTest: BaseVitestTestFunction,\n baseParameterized: AnyFunction,\n options: FailureLogReporterOptions,\n): AnyFunction {\n return ((...cases: readonly unknown[]) => {\n const registerParameterized = Reflect.apply(\n baseParameterized,\n baseTest,\n cases,\n );\n return ((...args: unknown[]) =>\n Reflect.apply(\n registerParameterized as AnyFunction,\n undefined,\n wrapVitestParameterizedArguments(args, options),\n )) as AnyFunction;\n }) as AnyFunction;\n}\n\nfunction createWrappedFunction(\n baseFunction: AnyFunction,\n options: FailureLogReporterOptions,\n): AnyFunction {\n return function (this: unknown, ...args: never[]): unknown {\n return Reflect.apply(\n baseFunction,\n this,\n wrapVitestArguments(args, options),\n );\n };\n}\n\nfunction wrapVitestArguments(\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 wrapVitestCallback(args[callbackIndex] as AnyFunction, options),\n ...args.slice(callbackIndex + 1),\n ];\n}\n\nfunction wrapVitestParameterizedArguments(\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 wrapVitestCallback(args[callbackIndex] as AnyFunction, options),\n ...args.slice(callbackIndex + 1),\n ];\n}\n\nfunction wrapVitestCallback(\n callback: AnyFunction,\n options: FailureLogReporterOptions,\n): AnyFunction {\n const reporter = createFailureLogReporter(options);\n const wrapped = function (this: unknown, ...args: never[]) {\n return reporter.run(() => Reflect.apply(callback, this, args));\n };\n Object.defineProperty(wrapped, \"toString\", {\n configurable: true,\n value: () => String(callback),\n });\n return wrapped;\n}\n\nfunction getFunctionProperty(\n value: BaseVitestTestFunction,\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 aroundAll,\n aroundEach,\n assert,\n beforeAll,\n beforeEach,\n bench,\n chai,\n createExpect,\n createIt,\n createTest,\n createVitest,\n describe,\n expect,\n expectTypeOf,\n inject,\n onTestFailed,\n onTestFinished,\n should,\n suite,\n vi,\n vitest,\n type VitestTestFunction,\n} from \"./mod.ts\";\n\nexport type {\n FailureLogReporterOptions,\n FailureLogReportMode,\n VitestTestCallback,\n VitestTestContext,\n VitestTestFunction,\n VitestTesting,\n VitestTestOptions,\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-vitest/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: VitestTestFunction = createTest(reporterOptions);\nconst it: VitestTestFunction = createIt(reporterOptions);\nconst concurrent: VitestTestFunction[\"concurrent\"] = test.concurrent;\nconst each: VitestTestFunction[\"each\"] = test.each;\nconst fails: VitestTestFunction[\"fails\"] = test.fails;\nconst for_: VitestTestFunction[\"for\"] = test.for;\nconst only: VitestTestFunction[\"only\"] = test.only;\nconst sequential: VitestTestFunction[\"sequential\"] = test.sequential;\nconst skip: VitestTestFunction[\"skip\"] = test.skip;\nconst todo: VitestTestFunction[\"todo\"] = test.todo;\n\nexport {\n afterAll,\n afterEach,\n aroundAll,\n aroundEach,\n assert,\n beforeAll,\n beforeEach,\n bench,\n chai,\n concurrent,\n createExpect,\n createIt,\n createTest,\n createVitest,\n describe,\n each,\n expect,\n expectTypeOf,\n fails,\n inject,\n it,\n only,\n onTestFailed,\n onTestFinished,\n sequential,\n should,\n skip,\n suite,\n test,\n todo,\n vi,\n vitest,\n};\nexport { for_ as for };\nexport default test;\n"],"mappings":";;;;;;AAyHA,MAAM,cAAc;CAClB;CACA;CACA;CACA;CACA;CACA;AACD;AAED,MAAM,yBAAyB,CAC7B,UACA,OACD;AAED,MAAM,YAAY;CAChB;CACA;CACA;CACA;CACA;CACA;AACD;AAED,MAAM,mBAAmB,CACvB,YACA,OACD;;;;;;;;;;;;;;;AAgBD,SAAgB,WACdA,UAAqC,CAAE,GACnB;AACpB,QAAO,yBACLC,QACA,QACD;AACF;;;;;;;;;AAUD,SAAgB,SACdD,UAAqC,CAAE,GACnB;AACpB,QAAO,yBACLE,MACA,QACD;AACF;;;;;;;;;;;;AAaD,SAAgB,aACdF,UAAqC,CAAE,GACxB;AACf,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,IAAI,SAAS,QAAQ;EACrB;EACA;EACA;EACA;EACA,MAAM,WAAW,QAAQ;EACzB;EACA;CACD;AACF;;;;;;;AAQD,MAAaG,SAA2B,YAAY;;;;;;;AAQpD,MAAaC,OAAyB,UAAU;;;;;;AAOhD,MAAaC,SAAmCC,OAAK;;;;;;AAOrD,MAAaC,SAAmCD,OAAK;;;;;;AAOrD,MAAaE,SAAmCF,OAAK;;;;;;AAOrD,MAAaG,UAAqCH,OAAK;;;;;;AAOvD,MAAaI,eAA+CJ,OAAK;;;;;;AAOjE,MAAaK,eAA+CL,OAAK;;;;;;AAOjE,MAAaM,SAAmCN,OAAK;;;;;;AAOrD,MAAMO,SAAkCP,OAAK;AAK7C,SAAS,yBACPQ,UACAd,SACAe,wBAA6D,IAAI,WAC7C;CACpB,MAAM,S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,gBAAgB;AACxD,MAAMC,aAA+C,KAAK;AAC1D,MAAMC,OAAmC,KAAK;AAC9C,MAAMC,QAAqC,KAAK;AAChD,MAAMC,OAAkC,KAAK;AAC7C,MAAMC,OAAmC,KAAK;AAC9C,MAAMC,aAA+C,KAAK;AAC1D,MAAMC,OAAmC,KAAK;AAC9C,MAAMC,OAAmC,KAAK;AAqC9C,uBAAe"}
|
package/dist/mod.js
CHANGED
|
@@ -148,19 +148,20 @@ const each = test.each;
|
|
|
148
148
|
*/
|
|
149
149
|
const for_ = test.for;
|
|
150
150
|
var src_default = test;
|
|
151
|
-
function createVitestTestFunction(baseTest, options, cache = /* @__PURE__ */ new WeakMap()
|
|
151
|
+
function createVitestTestFunction(baseTest, options, cache = /* @__PURE__ */ new WeakMap()) {
|
|
152
152
|
const cached = cache.get(baseTest);
|
|
153
153
|
if (cached != null) return cached;
|
|
154
154
|
const register = (...args) => Reflect.apply(baseTest, void 0, wrapVitestArguments(args, options));
|
|
155
155
|
cache.set(baseTest, register);
|
|
156
|
-
|
|
156
|
+
for (const helperName of helperNames) {
|
|
157
157
|
const helper = getFunctionProperty(baseTest, helperName);
|
|
158
158
|
if (helper == null) continue;
|
|
159
159
|
Object.defineProperty(register, helperName, {
|
|
160
160
|
configurable: true,
|
|
161
161
|
enumerable: true,
|
|
162
|
-
|
|
163
|
-
|
|
162
|
+
get() {
|
|
163
|
+
return createVitestTestFunction(helper, options, cache);
|
|
164
|
+
}
|
|
164
165
|
});
|
|
165
166
|
}
|
|
166
167
|
for (const helperName of conditionalHelperNames) {
|
|
@@ -171,7 +172,7 @@ function createVitestTestFunction(baseTest, options, cache = /* @__PURE__ */ new
|
|
|
171
172
|
enumerable: true,
|
|
172
173
|
value: (condition) => {
|
|
173
174
|
const conditionalTest = Reflect.apply(helper, baseTest, [condition]);
|
|
174
|
-
return createVitestTestFunction(conditionalTest, options, cache
|
|
175
|
+
return createVitestTestFunction(conditionalTest, options, cache);
|
|
175
176
|
},
|
|
176
177
|
writable: true
|
|
177
178
|
});
|
package/dist/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","names":["options: FailureLogReporterOptions","vitestTest","vitestIt","test: VitestTestFunction","it: VitestTestFunction","skip: VitestTestFunction[\"skip\"]","todo: VitestTestFunction[\"todo\"]","only: VitestTestFunction[\"only\"]","fails: VitestTestFunction[\"fails\"]","concurrent: VitestTestFunction[\"concurrent\"]","sequential: VitestTestFunction[\"sequential\"]","each: VitestTestFunction[\"each\"]","for_: VitestTestFunction[\"for\"]","baseTest: BaseVitestTestFunction","cache: WeakMap<BaseVitestTestFunction, VitestTestFunction>","condition: unknown","each","for_","baseParameterized: AnyFunction","baseFunction: AnyFunction","args: readonly unknown[]","callback: AnyFunction","value: BaseVitestTestFunction","property: string"],"sources":["../src/mod.ts"],"sourcesContent":["import {\n afterAll,\n afterEach,\n aroundAll,\n aroundEach,\n assert,\n beforeAll,\n beforeEach,\n bench,\n chai,\n createExpect,\n describe,\n expect,\n expectTypeOf,\n inject,\n it as vitestIt,\n onTestFailed,\n onTestFinished,\n should,\n suite,\n test as vitestTest,\n vi,\n vitest,\n} from \"vitest\";\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 type {\n TestAPI as VitestTestFunction,\n TestContext as VitestTestContext,\n TestFunction as VitestTestCallback,\n TestOptions as VitestTestOptions,\n} from \"vitest\";\nexport {\n afterAll,\n afterEach,\n aroundAll,\n aroundEach,\n assert,\n beforeAll,\n beforeEach,\n bench,\n chai,\n createExpect,\n describe,\n expect,\n expectTypeOf,\n inject,\n onTestFailed,\n onTestFinished,\n should,\n suite,\n vi,\n vitest,\n};\n\nimport type { TestAPI as VitestTestFunction } from \"vitest\";\n\n/**\n * A Vitest-compatible namespace with LogTape-wrapped `test()` and `it()`\n * functions.\n *\n * @since 2.3.0\n */\nexport interface VitestTesting {\n readonly afterAll: typeof afterAll;\n readonly afterEach: typeof afterEach;\n readonly aroundAll: typeof aroundAll;\n readonly aroundEach: typeof aroundEach;\n readonly assert: typeof assert;\n readonly bench: typeof bench;\n readonly beforeAll: typeof beforeAll;\n readonly beforeEach: typeof beforeEach;\n readonly chai: typeof chai;\n readonly createExpect: typeof createExpect;\n readonly describe: typeof describe;\n readonly expect: typeof expect;\n readonly expectTypeOf: typeof expectTypeOf;\n readonly inject: typeof inject;\n readonly it: VitestTestFunction;\n readonly onTestFailed: typeof onTestFailed;\n readonly onTestFinished: typeof onTestFinished;\n readonly should: typeof should;\n readonly suite: typeof suite;\n readonly test: VitestTestFunction;\n readonly vi: typeof vi;\n readonly vitest: typeof vitest;\n}\n\ntype AnyFunction = (...args: never[]) => unknown;\ntype BaseVitestTestFunction = AnyFunction & {\n readonly skip?: BaseVitestTestFunction;\n readonly todo?: BaseVitestTestFunction;\n readonly only?: BaseVitestTestFunction;\n readonly fails?: BaseVitestTestFunction;\n readonly concurrent?: BaseVitestTestFunction;\n readonly sequential?: BaseVitestTestFunction;\n readonly each?: AnyFunction;\n readonly for?: AnyFunction;\n readonly skipIf?: AnyFunction;\n readonly runIf?: AnyFunction;\n readonly extend?: AnyFunction;\n readonly override?: AnyFunction;\n readonly scoped?: AnyFunction;\n readonly beforeAll?: AnyFunction;\n readonly afterAll?: AnyFunction;\n readonly aroundAll?: AnyFunction;\n readonly beforeEach?: AnyFunction;\n readonly afterEach?: AnyFunction;\n readonly aroundEach?: AnyFunction;\n readonly describe?: AnyFunction;\n readonly suite?: AnyFunction;\n};\n\nconst helperNames = [\n \"skip\",\n \"todo\",\n \"only\",\n \"fails\",\n \"concurrent\",\n \"sequential\",\n] as const;\n\nconst conditionalHelperNames = [\n \"skipIf\",\n \"runIf\",\n] as const;\n\nconst hookNames = [\n \"beforeAll\",\n \"afterAll\",\n \"aroundAll\",\n \"beforeEach\",\n \"afterEach\",\n \"aroundEach\",\n] as const;\n\nconst nestedSuiteNames = [\n \"describe\",\n \"suite\",\n] as const;\n\n/**\n * Creates a Vitest `test()` function that reports LogTape records from failed\n * test callbacks.\n *\n * The returned function preserves Vitest test options and shorthand helpers\n * such as `test.skip()`, `test.todo()`, `test.only()`, `test.fails()`,\n * `test.concurrent()`, `test.sequential()`, `test.skipIf()`,\n * `test.runIf()`, `test.each()`, `test.for()`, and `test.extend()`. Only\n * callback arguments are adapted; options are passed through to Vitest.\n *\n * @param options Failure log reporter options.\n * @returns A configured Vitest-compatible test function.\n * @since 2.3.0\n */\nexport function createTest(\n options: FailureLogReporterOptions = {},\n): VitestTestFunction {\n return createVitestTestFunction(\n vitestTest as unknown as BaseVitestTestFunction,\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 Vitest-compatible `it()` function.\n * @since 2.3.0\n */\nexport function createIt(\n options: FailureLogReporterOptions = {},\n): VitestTestFunction {\n return createVitestTestFunction(\n vitestIt as unknown as BaseVitestTestFunction,\n options,\n );\n}\n\n/**\n * Creates a Vitest-compatible namespace with wrapped `test()` and `it()`\n * functions.\n *\n * This is useful when existing test files already import several helpers from\n * Vitest and you want to switch them to one LogTape-aware namespace.\n *\n * @param options Failure log reporter options.\n * @returns A Vitest-compatible namespace.\n * @since 2.3.0\n */\nexport function createVitest(\n options: FailureLogReporterOptions = {},\n): VitestTesting {\n return {\n afterAll,\n afterEach,\n aroundAll,\n aroundEach,\n assert,\n bench,\n beforeAll,\n beforeEach,\n chai,\n createExpect,\n describe,\n expect,\n expectTypeOf,\n inject,\n it: createIt(options),\n onTestFailed,\n onTestFinished,\n should,\n suite,\n test: createTest(options),\n vi,\n vitest,\n };\n}\n\n/**\n * A Vitest `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: VitestTestFunction = createTest();\n\n/**\n * A Vitest `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: VitestTestFunction = createIt();\n\n/**\n * Shorthand for skipping a test.\n *\n * @since 2.3.0\n */\nexport const skip: VitestTestFunction[\"skip\"] = test.skip;\n\n/**\n * Shorthand for marking a test as TODO.\n *\n * @since 2.3.0\n */\nexport const todo: VitestTestFunction[\"todo\"] = test.todo;\n\n/**\n * Shorthand for marking a test as `only`.\n *\n * @since 2.3.0\n */\nexport const only: VitestTestFunction[\"only\"] = test.only;\n\n/**\n * Shorthand for marking a test as expected to fail.\n *\n * @since 2.3.0\n */\nexport const fails: VitestTestFunction[\"fails\"] = test.fails;\n\n/**\n * Shorthand for running a test concurrently.\n *\n * @since 2.3.0\n */\nexport const concurrent: VitestTestFunction[\"concurrent\"] = test.concurrent;\n\n/**\n * Shorthand for running a test sequentially.\n *\n * @since 2.3.0\n */\nexport const sequential: VitestTestFunction[\"sequential\"] = test.sequential;\n\n/**\n * Shorthand for Vitest's parameterized tests.\n *\n * @since 2.3.0\n */\nexport const each: VitestTestFunction[\"each\"] = test.each;\n\n/**\n * Shorthand for Vitest's parameterized tests with a preserved test context.\n *\n * @since 2.3.0\n */\nconst for_: VitestTestFunction[\"for\"] = test.for;\n\nexport { for_ as for };\nexport default test;\n\nfunction createVitestTestFunction(\n baseTest: BaseVitestTestFunction,\n options: FailureLogReporterOptions,\n cache: WeakMap<BaseVitestTestFunction, VitestTestFunction> = new WeakMap(),\n depth = 0,\n): VitestTestFunction {\n const cached = cache.get(baseTest);\n if (cached != null) return cached;\n\n const register = ((...args: unknown[]) =>\n Reflect.apply(\n baseTest,\n undefined,\n wrapVitestArguments(args, options),\n )) as unknown as VitestTestFunction;\n cache.set(baseTest, register);\n\n if (depth < 2) {\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: createVitestTestFunction(\n helper as BaseVitestTestFunction,\n options,\n cache,\n depth + 1,\n ),\n writable: true,\n });\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 createVitestTestFunction(\n conditionalTest as BaseVitestTestFunction,\n options,\n cache,\n depth + 1,\n );\n }) as VitestTestFunction[typeof helperName],\n writable: true,\n });\n }\n\n for (const helperName of hookNames) {\n const helper = getFunctionProperty(baseTest, helperName);\n if (helper == null) continue;\n Object.defineProperty(register, helperName, {\n configurable: true,\n enumerable: true,\n value: createWrappedFunction(helper, options),\n writable: true,\n });\n }\n\n for (const helperName of nestedSuiteNames) {\n const helper = getFunctionProperty(baseTest, helperName);\n if (helper == null) continue;\n Object.defineProperty(register, helperName, {\n configurable: true,\n enumerable: true,\n value: helper,\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: createWrappedParameterized(baseTest, each, options),\n writable: true,\n });\n }\n\n const for_ = getFunctionProperty(baseTest, \"for\");\n if (for_ != null) {\n Object.defineProperty(register, \"for\", {\n configurable: true,\n enumerable: true,\n value: createWrappedParameterized(baseTest, for_, options),\n writable: true,\n });\n }\n\n const extend = getFunctionProperty(baseTest, \"extend\");\n if (extend != null) {\n Object.defineProperty(register, \"extend\", {\n configurable: true,\n enumerable: true,\n value: ((...args: never[]) => {\n const extendedTest = Reflect.apply(extend, baseTest, args);\n return createVitestTestFunction(\n extendedTest as BaseVitestTestFunction,\n options,\n cache,\n );\n }) as VitestTestFunction[\"extend\"],\n writable: true,\n });\n }\n\n const override = getFunctionProperty(baseTest, \"override\");\n if (override != null) {\n Object.defineProperty(register, \"override\", {\n configurable: true,\n enumerable: true,\n value: override,\n writable: true,\n });\n }\n\n const scoped = getFunctionProperty(baseTest, \"scoped\");\n if (scoped != null) {\n Object.defineProperty(register, \"scoped\", {\n configurable: true,\n enumerable: true,\n value: scoped,\n writable: true,\n });\n }\n\n return register;\n}\n\nfunction createWrappedParameterized(\n baseTest: BaseVitestTestFunction,\n baseParameterized: AnyFunction,\n options: FailureLogReporterOptions,\n): AnyFunction {\n return ((...cases: readonly unknown[]) => {\n const registerParameterized = Reflect.apply(\n baseParameterized,\n baseTest,\n cases,\n );\n return ((...args: unknown[]) =>\n Reflect.apply(\n registerParameterized as AnyFunction,\n undefined,\n wrapVitestParameterizedArguments(args, options),\n )) as AnyFunction;\n }) as AnyFunction;\n}\n\nfunction createWrappedFunction(\n baseFunction: AnyFunction,\n options: FailureLogReporterOptions,\n): AnyFunction {\n return function (this: unknown, ...args: never[]): unknown {\n return Reflect.apply(\n baseFunction,\n this,\n wrapVitestArguments(args, options),\n );\n };\n}\n\nfunction wrapVitestArguments(\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 wrapVitestCallback(args[callbackIndex] as AnyFunction, options),\n ...args.slice(callbackIndex + 1),\n ];\n}\n\nfunction wrapVitestParameterizedArguments(\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 wrapVitestCallback(args[callbackIndex] as AnyFunction, options),\n ...args.slice(callbackIndex + 1),\n ];\n}\n\nfunction wrapVitestCallback(\n callback: AnyFunction,\n options: FailureLogReporterOptions,\n): AnyFunction {\n const reporter = createFailureLogReporter(options);\n const wrapped = function (this: unknown, ...args: never[]) {\n return reporter.run(() => Reflect.apply(callback, this, args));\n };\n Object.defineProperty(wrapped, \"toString\", {\n configurable: true,\n value: () => String(callback),\n });\n return wrapped;\n}\n\nfunction getFunctionProperty(\n value: BaseVitestTestFunction,\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":";;;;AAyHA,MAAM,cAAc;CAClB;CACA;CACA;CACA;CACA;CACA;AACD;AAED,MAAM,yBAAyB,CAC7B,UACA,OACD;AAED,MAAM,YAAY;CAChB;CACA;CACA;CACA;CACA;CACA;AACD;AAED,MAAM,mBAAmB,CACvB,YACA,OACD;;;;;;;;;;;;;;;AAgBD,SAAgB,WACdA,UAAqC,CAAE,GACnB;AACpB,QAAO,yBACLC,QACA,QACD;AACF;;;;;;;;;AAUD,SAAgB,SACdD,UAAqC,CAAE,GACnB;AACpB,QAAO,yBACLE,MACA,QACD;AACF;;;;;;;;;;;;AAaD,SAAgB,aACdF,UAAqC,CAAE,GACxB;AACf,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,IAAI,SAAS,QAAQ;EACrB;EACA;EACA;EACA;EACA,MAAM,WAAW,QAAQ;EACzB;EACA;CACD;AACF;;;;;;;AAQD,MAAaG,OAA2B,YAAY;;;;;;;AAQpD,MAAaC,KAAyB,UAAU;;;;;;AAOhD,MAAaC,OAAmC,KAAK;;;;;;AAOrD,MAAaC,OAAmC,KAAK;;;;;;AAOrD,MAAaC,OAAmC,KAAK;;;;;;AAOrD,MAAaC,QAAqC,KAAK;;;;;;AAOvD,MAAaC,aAA+C,KAAK;;;;;;AAOjE,MAAaC,aAA+C,KAAK;;;;;;AAOjE,MAAaC,OAAmC,KAAK;;;;;;AAOrD,MAAMC,OAAkC,KAAK;AAG7C,kBAAe;AAEf,SAAS,yBACPC,UACAb,SACAc,wBAA6D,IAAI,WACjE,QAAQ,GACY;CACpB,MAAM,SAAS,MAAM,IAAI,SAAS;AAClC,KAAI,UAAU,KAAM,QAAO;CAE3B,MAAM,WAAY,CAAC,GAAG,SACpB,QAA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Ac;EAC/B,mBAAmB,KAAK,gBAA+B,QAAQ;EAC/D,GAAG,KAAK,MAAM,gBAAgB,EAAE;CACjC;AACF;AAED,SAAS,iCACPoB,MACApB,SACW;CACX,MAAM,gBAAgB,KAAK,UAAU,CAAC,KAAK,UACzC,QAAQ,YAAY,QAAQ,WAC7B;AACD,KAAI,gBAAgB,EAAG,QAAO,CAAC,GAAG,IAAK;AAEvC,QAAO;EACL,GAAG,KAAK,MAAM,GAAG,cAAc;EAC/B,mBAAmB,KAAK,gBAA+B,QAAQ;EAC/D,GAAG,KAAK,MAAM,gBAAgB,EAAE;CACjC;AACF;AAED,SAAS,mBACPqB,UACArB,SACa;CACb,MAAM,WAAW,yBAAyB,QAAQ;CAClD,MAAM,UAAU,SAAyB,GAAG,MAAe;AACzD,SAAO,SAAS,IAAI,MAAM,QAAQ,MAAM,UAAU,MAAM,KAAK,CAAC;CAC/D;AACD,QAAO,eAAe,SAAS,YAAY;EACzC,cAAc;EACd,OAAO,MAAM,OAAO,SAAS;CAC9B,EAAC;AACF,QAAO;AACR;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":["options: FailureLogReporterOptions","vitestTest","vitestIt","test: VitestTestFunction","it: VitestTestFunction","skip: VitestTestFunction[\"skip\"]","todo: VitestTestFunction[\"todo\"]","only: VitestTestFunction[\"only\"]","fails: VitestTestFunction[\"fails\"]","concurrent: VitestTestFunction[\"concurrent\"]","sequential: VitestTestFunction[\"sequential\"]","each: VitestTestFunction[\"each\"]","for_: VitestTestFunction[\"for\"]","baseTest: BaseVitestTestFunction","cache: WeakMap<BaseVitestTestFunction, VitestTestFunction>","register: VitestTestFunction","condition: unknown","each","for_","baseParameterized: AnyFunction","baseFunction: AnyFunction","args: readonly unknown[]","callback: AnyFunction","value: BaseVitestTestFunction","property: string"],"sources":["../src/mod.ts"],"sourcesContent":["import {\n afterAll,\n afterEach,\n aroundAll,\n aroundEach,\n assert,\n beforeAll,\n beforeEach,\n bench,\n chai,\n createExpect,\n describe,\n expect,\n expectTypeOf,\n inject,\n it as vitestIt,\n onTestFailed,\n onTestFinished,\n should,\n suite,\n test as vitestTest,\n vi,\n vitest,\n} from \"vitest\";\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 type {\n TestAPI as VitestTestFunction,\n TestContext as VitestTestContext,\n TestFunction as VitestTestCallback,\n TestOptions as VitestTestOptions,\n} from \"vitest\";\nexport {\n afterAll,\n afterEach,\n aroundAll,\n aroundEach,\n assert,\n beforeAll,\n beforeEach,\n bench,\n chai,\n createExpect,\n describe,\n expect,\n expectTypeOf,\n inject,\n onTestFailed,\n onTestFinished,\n should,\n suite,\n vi,\n vitest,\n};\n\nimport type { TestAPI as VitestTestFunction } from \"vitest\";\n\n/**\n * A Vitest-compatible namespace with LogTape-wrapped `test()` and `it()`\n * functions.\n *\n * @since 2.3.0\n */\nexport interface VitestTesting {\n readonly afterAll: typeof afterAll;\n readonly afterEach: typeof afterEach;\n readonly aroundAll: typeof aroundAll;\n readonly aroundEach: typeof aroundEach;\n readonly assert: typeof assert;\n readonly bench: typeof bench;\n readonly beforeAll: typeof beforeAll;\n readonly beforeEach: typeof beforeEach;\n readonly chai: typeof chai;\n readonly createExpect: typeof createExpect;\n readonly describe: typeof describe;\n readonly expect: typeof expect;\n readonly expectTypeOf: typeof expectTypeOf;\n readonly inject: typeof inject;\n readonly it: VitestTestFunction;\n readonly onTestFailed: typeof onTestFailed;\n readonly onTestFinished: typeof onTestFinished;\n readonly should: typeof should;\n readonly suite: typeof suite;\n readonly test: VitestTestFunction;\n readonly vi: typeof vi;\n readonly vitest: typeof vitest;\n}\n\ntype AnyFunction = (...args: never[]) => unknown;\ntype BaseVitestTestFunction = AnyFunction & {\n readonly skip?: BaseVitestTestFunction;\n readonly todo?: BaseVitestTestFunction;\n readonly only?: BaseVitestTestFunction;\n readonly fails?: BaseVitestTestFunction;\n readonly concurrent?: BaseVitestTestFunction;\n readonly sequential?: BaseVitestTestFunction;\n readonly each?: AnyFunction;\n readonly for?: AnyFunction;\n readonly skipIf?: AnyFunction;\n readonly runIf?: AnyFunction;\n readonly extend?: AnyFunction;\n readonly override?: AnyFunction;\n readonly scoped?: AnyFunction;\n readonly beforeAll?: AnyFunction;\n readonly afterAll?: AnyFunction;\n readonly aroundAll?: AnyFunction;\n readonly beforeEach?: AnyFunction;\n readonly afterEach?: AnyFunction;\n readonly aroundEach?: AnyFunction;\n readonly describe?: AnyFunction;\n readonly suite?: AnyFunction;\n};\n\nconst helperNames = [\n \"skip\",\n \"todo\",\n \"only\",\n \"fails\",\n \"concurrent\",\n \"sequential\",\n] as const;\n\nconst conditionalHelperNames = [\n \"skipIf\",\n \"runIf\",\n] as const;\n\nconst hookNames = [\n \"beforeAll\",\n \"afterAll\",\n \"aroundAll\",\n \"beforeEach\",\n \"afterEach\",\n \"aroundEach\",\n] as const;\n\nconst nestedSuiteNames = [\n \"describe\",\n \"suite\",\n] as const;\n\n/**\n * Creates a Vitest `test()` function that reports LogTape records from failed\n * test callbacks.\n *\n * The returned function preserves Vitest test options and shorthand helpers\n * such as `test.skip()`, `test.todo()`, `test.only()`, `test.fails()`,\n * `test.concurrent()`, `test.sequential()`, `test.skipIf()`,\n * `test.runIf()`, `test.each()`, `test.for()`, and `test.extend()`. Only\n * callback arguments are adapted; options are passed through to Vitest.\n *\n * @param options Failure log reporter options.\n * @returns A configured Vitest-compatible test function.\n * @since 2.3.0\n */\nexport function createTest(\n options: FailureLogReporterOptions = {},\n): VitestTestFunction {\n return createVitestTestFunction(\n vitestTest as unknown as BaseVitestTestFunction,\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 Vitest-compatible `it()` function.\n * @since 2.3.0\n */\nexport function createIt(\n options: FailureLogReporterOptions = {},\n): VitestTestFunction {\n return createVitestTestFunction(\n vitestIt as unknown as BaseVitestTestFunction,\n options,\n );\n}\n\n/**\n * Creates a Vitest-compatible namespace with wrapped `test()` and `it()`\n * functions.\n *\n * This is useful when existing test files already import several helpers from\n * Vitest and you want to switch them to one LogTape-aware namespace.\n *\n * @param options Failure log reporter options.\n * @returns A Vitest-compatible namespace.\n * @since 2.3.0\n */\nexport function createVitest(\n options: FailureLogReporterOptions = {},\n): VitestTesting {\n return {\n afterAll,\n afterEach,\n aroundAll,\n aroundEach,\n assert,\n bench,\n beforeAll,\n beforeEach,\n chai,\n createExpect,\n describe,\n expect,\n expectTypeOf,\n inject,\n it: createIt(options),\n onTestFailed,\n onTestFinished,\n should,\n suite,\n test: createTest(options),\n vi,\n vitest,\n };\n}\n\n/**\n * A Vitest `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: VitestTestFunction = createTest();\n\n/**\n * A Vitest `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: VitestTestFunction = createIt();\n\n/**\n * Shorthand for skipping a test.\n *\n * @since 2.3.0\n */\nexport const skip: VitestTestFunction[\"skip\"] = test.skip;\n\n/**\n * Shorthand for marking a test as TODO.\n *\n * @since 2.3.0\n */\nexport const todo: VitestTestFunction[\"todo\"] = test.todo;\n\n/**\n * Shorthand for marking a test as `only`.\n *\n * @since 2.3.0\n */\nexport const only: VitestTestFunction[\"only\"] = test.only;\n\n/**\n * Shorthand for marking a test as expected to fail.\n *\n * @since 2.3.0\n */\nexport const fails: VitestTestFunction[\"fails\"] = test.fails;\n\n/**\n * Shorthand for running a test concurrently.\n *\n * @since 2.3.0\n */\nexport const concurrent: VitestTestFunction[\"concurrent\"] = test.concurrent;\n\n/**\n * Shorthand for running a test sequentially.\n *\n * @since 2.3.0\n */\nexport const sequential: VitestTestFunction[\"sequential\"] = test.sequential;\n\n/**\n * Shorthand for Vitest's parameterized tests.\n *\n * @since 2.3.0\n */\nexport const each: VitestTestFunction[\"each\"] = test.each;\n\n/**\n * Shorthand for Vitest's parameterized tests with a preserved test context.\n *\n * @since 2.3.0\n */\nconst for_: VitestTestFunction[\"for\"] = test.for;\n\nexport { for_ as for };\nexport default test;\n\nfunction createVitestTestFunction(\n baseTest: BaseVitestTestFunction,\n options: FailureLogReporterOptions,\n cache: WeakMap<BaseVitestTestFunction, VitestTestFunction> = new WeakMap(),\n): VitestTestFunction {\n const cached = cache.get(baseTest);\n if (cached != null) return cached;\n\n const register: VitestTestFunction = ((...args: unknown[]) =>\n Reflect.apply(\n baseTest,\n undefined,\n wrapVitestArguments(args, options),\n )) as unknown as VitestTestFunction;\n cache.set(baseTest, register);\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 get() {\n return createVitestTestFunction(\n helper as BaseVitestTestFunction,\n options,\n cache,\n );\n },\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 createVitestTestFunction(\n conditionalTest as BaseVitestTestFunction,\n options,\n cache,\n );\n }) as VitestTestFunction[typeof helperName],\n writable: true,\n });\n }\n\n for (const helperName of hookNames) {\n const helper = getFunctionProperty(baseTest, helperName);\n if (helper == null) continue;\n Object.defineProperty(register, helperName, {\n configurable: true,\n enumerable: true,\n value: createWrappedFunction(helper, options),\n writable: true,\n });\n }\n\n for (const helperName of nestedSuiteNames) {\n const helper = getFunctionProperty(baseTest, helperName);\n if (helper == null) continue;\n Object.defineProperty(register, helperName, {\n configurable: true,\n enumerable: true,\n value: helper,\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: createWrappedParameterized(baseTest, each, options),\n writable: true,\n });\n }\n\n const for_ = getFunctionProperty(baseTest, \"for\");\n if (for_ != null) {\n Object.defineProperty(register, \"for\", {\n configurable: true,\n enumerable: true,\n value: createWrappedParameterized(baseTest, for_, options),\n writable: true,\n });\n }\n\n const extend = getFunctionProperty(baseTest, \"extend\");\n if (extend != null) {\n Object.defineProperty(register, \"extend\", {\n configurable: true,\n enumerable: true,\n value: ((...args: never[]) => {\n const extendedTest = Reflect.apply(extend, baseTest, args);\n return createVitestTestFunction(\n extendedTest as BaseVitestTestFunction,\n options,\n cache,\n );\n }) as VitestTestFunction[\"extend\"],\n writable: true,\n });\n }\n\n const override = getFunctionProperty(baseTest, \"override\");\n if (override != null) {\n Object.defineProperty(register, \"override\", {\n configurable: true,\n enumerable: true,\n value: override,\n writable: true,\n });\n }\n\n const scoped = getFunctionProperty(baseTest, \"scoped\");\n if (scoped != null) {\n Object.defineProperty(register, \"scoped\", {\n configurable: true,\n enumerable: true,\n value: scoped,\n writable: true,\n });\n }\n\n return register;\n}\n\nfunction createWrappedParameterized(\n baseTest: BaseVitestTestFunction,\n baseParameterized: AnyFunction,\n options: FailureLogReporterOptions,\n): AnyFunction {\n return ((...cases: readonly unknown[]) => {\n const registerParameterized = Reflect.apply(\n baseParameterized,\n baseTest,\n cases,\n );\n return ((...args: unknown[]) =>\n Reflect.apply(\n registerParameterized as AnyFunction,\n undefined,\n wrapVitestParameterizedArguments(args, options),\n )) as AnyFunction;\n }) as AnyFunction;\n}\n\nfunction createWrappedFunction(\n baseFunction: AnyFunction,\n options: FailureLogReporterOptions,\n): AnyFunction {\n return function (this: unknown, ...args: never[]): unknown {\n return Reflect.apply(\n baseFunction,\n this,\n wrapVitestArguments(args, options),\n );\n };\n}\n\nfunction wrapVitestArguments(\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 wrapVitestCallback(args[callbackIndex] as AnyFunction, options),\n ...args.slice(callbackIndex + 1),\n ];\n}\n\nfunction wrapVitestParameterizedArguments(\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 wrapVitestCallback(args[callbackIndex] as AnyFunction, options),\n ...args.slice(callbackIndex + 1),\n ];\n}\n\nfunction wrapVitestCallback(\n callback: AnyFunction,\n options: FailureLogReporterOptions,\n): AnyFunction {\n const reporter = createFailureLogReporter(options);\n const wrapped = function (this: unknown, ...args: never[]) {\n return reporter.run(() => Reflect.apply(callback, this, args));\n };\n Object.defineProperty(wrapped, \"toString\", {\n configurable: true,\n value: () => String(callback),\n });\n return wrapped;\n}\n\nfunction getFunctionProperty(\n value: BaseVitestTestFunction,\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":";;;;AAyHA,MAAM,cAAc;CAClB;CACA;CACA;CACA;CACA;CACA;AACD;AAED,MAAM,yBAAyB,CAC7B,UACA,OACD;AAED,MAAM,YAAY;CAChB;CACA;CACA;CACA;CACA;CACA;AACD;AAED,MAAM,mBAAmB,CACvB,YACA,OACD;;;;;;;;;;;;;;;AAgBD,SAAgB,WACdA,UAAqC,CAAE,GACnB;AACpB,QAAO,yBACLC,QACA,QACD;AACF;;;;;;;;;AAUD,SAAgB,SACdD,UAAqC,CAAE,GACnB;AACpB,QAAO,yBACLE,MACA,QACD;AACF;;;;;;;;;;;;AAaD,SAAgB,a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AAO,eAAe,SAAS,YAAY;EACzC,cAAc;EACd,OAAO,MAAM,OAAO,SAAS;CAC9B,EAAC;AACF,QAAO;AACR;AAED,SAAS,oBACPuB,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-vitest",
|
|
3
|
-
"version": "2.3.0-dev.
|
|
3
|
+
"version": "2.3.0-dev.840+34e837bf",
|
|
4
4
|
"description": "Vitest integration for LogTape failure log reporting",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"logging",
|
|
@@ -50,17 +50,17 @@
|
|
|
50
50
|
"dist/"
|
|
51
51
|
],
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@logtape/testing": "^2.3.0"
|
|
53
|
+
"@logtape/testing": "^2.3.0-dev.840+34e837bf"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"vitest": "^4.1.6",
|
|
57
|
-
"@logtape/logtape": "^2.3.0"
|
|
57
|
+
"@logtape/logtape": "^2.3.0-dev.840+34e837bf"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"tsdown": "^0.12.7",
|
|
61
61
|
"typescript": "^5.8.3",
|
|
62
62
|
"vitest": "^4.1.6",
|
|
63
|
-
"@logtape/logtape": "^2.3.0"
|
|
63
|
+
"@logtape/logtape": "^2.3.0-dev.840+34e837bf"
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|
|
66
66
|
"build": "tsdown",
|