@logtape/testing-vitest 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 +8 -0
- package/dist/autoload.d.ts +136 -0
- package/dist/autoload.d.ts.map +1 -0
- package/dist/autoload.js +306 -0
- package/dist/autoload.js.map +1 -0
- package/dist/mod.d.ts +136 -0
- package/dist/mod.d.ts.map +1 -0
- package/dist/mod.js +290 -0
- package/dist/mod.js.map +1 -0
- package/package.json +73 -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,136 @@
|
|
|
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
|
+
import { FailureLogReportMode, FailureLogReporterOptions, FailureLogReporterOptions as FailureLogReporterOptions$1 } from "@logtape/testing/reporter";
|
|
3
|
+
|
|
4
|
+
//#region src/mod.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A Vitest-compatible namespace with LogTape-wrapped `test()` and `it()`
|
|
8
|
+
* functions.
|
|
9
|
+
*
|
|
10
|
+
* @since 2.3.0
|
|
11
|
+
*/
|
|
12
|
+
interface VitestTesting {
|
|
13
|
+
readonly afterAll: typeof afterAll;
|
|
14
|
+
readonly afterEach: typeof afterEach;
|
|
15
|
+
readonly aroundAll: typeof aroundAll;
|
|
16
|
+
readonly aroundEach: typeof aroundEach;
|
|
17
|
+
readonly assert: typeof assert;
|
|
18
|
+
readonly bench: typeof bench;
|
|
19
|
+
readonly beforeAll: typeof beforeAll;
|
|
20
|
+
readonly beforeEach: typeof beforeEach;
|
|
21
|
+
readonly chai: typeof chai;
|
|
22
|
+
readonly createExpect: typeof createExpect;
|
|
23
|
+
readonly describe: typeof describe;
|
|
24
|
+
readonly expect: typeof expect;
|
|
25
|
+
readonly expectTypeOf: typeof expectTypeOf;
|
|
26
|
+
readonly inject: typeof inject;
|
|
27
|
+
readonly it: TestAPI;
|
|
28
|
+
readonly onTestFailed: typeof onTestFailed;
|
|
29
|
+
readonly onTestFinished: typeof onTestFinished;
|
|
30
|
+
readonly should: typeof should;
|
|
31
|
+
readonly suite: typeof suite;
|
|
32
|
+
readonly test: TestAPI;
|
|
33
|
+
readonly vi: typeof vi;
|
|
34
|
+
readonly vitest: typeof vitest;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Creates a Vitest `test()` function that reports LogTape records from failed
|
|
38
|
+
* test callbacks.
|
|
39
|
+
*
|
|
40
|
+
* The returned function preserves Vitest test options and shorthand helpers
|
|
41
|
+
* such as `test.skip()`, `test.todo()`, `test.only()`, `test.fails()`,
|
|
42
|
+
* `test.concurrent()`, `test.sequential()`, `test.skipIf()`,
|
|
43
|
+
* `test.runIf()`, `test.each()`, `test.for()`, and `test.extend()`. Only
|
|
44
|
+
* callback arguments are adapted; options are passed through to Vitest.
|
|
45
|
+
*
|
|
46
|
+
* @param options Failure log reporter options.
|
|
47
|
+
* @returns A configured Vitest-compatible test function.
|
|
48
|
+
* @since 2.3.0
|
|
49
|
+
*/
|
|
50
|
+
declare function createTest(options?: FailureLogReporterOptions$1): TestAPI;
|
|
51
|
+
/**
|
|
52
|
+
* Creates an `it()` alias that reports LogTape records from failed test
|
|
53
|
+
* callbacks.
|
|
54
|
+
*
|
|
55
|
+
* @param options Failure log reporter options.
|
|
56
|
+
* @returns A configured Vitest-compatible `it()` function.
|
|
57
|
+
* @since 2.3.0
|
|
58
|
+
*/
|
|
59
|
+
declare function createIt(options?: FailureLogReporterOptions$1): TestAPI;
|
|
60
|
+
/**
|
|
61
|
+
* Creates a Vitest-compatible namespace with wrapped `test()` and `it()`
|
|
62
|
+
* functions.
|
|
63
|
+
*
|
|
64
|
+
* This is useful when existing test files already import several helpers from
|
|
65
|
+
* Vitest and you want to switch them to one LogTape-aware namespace.
|
|
66
|
+
*
|
|
67
|
+
* @param options Failure log reporter options.
|
|
68
|
+
* @returns A Vitest-compatible namespace.
|
|
69
|
+
* @since 2.3.0
|
|
70
|
+
*/
|
|
71
|
+
declare function createVitest(options?: FailureLogReporterOptions$1): VitestTesting;
|
|
72
|
+
/**
|
|
73
|
+
* A Vitest `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: TestAPI;
|
|
79
|
+
/**
|
|
80
|
+
* A Vitest `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: TestAPI;
|
|
86
|
+
/**
|
|
87
|
+
* Shorthand for skipping a test.
|
|
88
|
+
*
|
|
89
|
+
* @since 2.3.0
|
|
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"];
|
|
134
|
+
//#endregion
|
|
135
|
+
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
|
+
//# sourceMappingURL=autoload.d.ts.map
|
|
@@ -0,0 +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;AAiChB;AAQA;AAOA;AAOA;AAOA;AAOA;AAOa,iBAnHG,UAAA,CAmH2B,OAAA,CAAA,EAlHhC,2BAkHgC,CAAA,EAjHxC,OAiHwC;AAO3C;AAOA;AAA0D;;;;;;iBAhH1C,QAAA,WACL,8BACR;;;;;;;;;;;;iBAkBa,YAAA,WACL,8BACR;;;;;;;cAiCU,MAAM;;;;;;;cAQN,IAAI;;;;;;cAOJ,MAAM;;;;;;cAON,MAAM;;;;;;cAON,MAAM;;;;;;cAON,OAAO;;;;;;cAOP,YAAY;;;;;;cAOZ,YAAY;;;;;;cAOZ,MAAM;;;;;;cAOb,MAAM"}
|
package/dist/autoload.js
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
2
|
+
import { ConfigError, configureSync, getConfig } from "@logtape/logtape";
|
|
3
|
+
import { afterAll, afterEach, aroundAll, aroundEach, assert, beforeAll, beforeEach, bench, chai, createExpect, describe, expect, expectTypeOf, inject, it as it$1, onTestFailed, onTestFinished, should, suite, test, vi, vitest } from "vitest";
|
|
4
|
+
import { createFailureLogReporter } from "@logtape/testing/reporter";
|
|
5
|
+
|
|
6
|
+
//#region src/mod.ts
|
|
7
|
+
const helperNames = [
|
|
8
|
+
"skip",
|
|
9
|
+
"todo",
|
|
10
|
+
"only",
|
|
11
|
+
"fails",
|
|
12
|
+
"concurrent",
|
|
13
|
+
"sequential"
|
|
14
|
+
];
|
|
15
|
+
const conditionalHelperNames = ["skipIf", "runIf"];
|
|
16
|
+
const hookNames = [
|
|
17
|
+
"beforeAll",
|
|
18
|
+
"afterAll",
|
|
19
|
+
"aroundAll",
|
|
20
|
+
"beforeEach",
|
|
21
|
+
"afterEach",
|
|
22
|
+
"aroundEach"
|
|
23
|
+
];
|
|
24
|
+
const nestedSuiteNames = ["describe", "suite"];
|
|
25
|
+
/**
|
|
26
|
+
* Creates a Vitest `test()` function that reports LogTape records from failed
|
|
27
|
+
* test callbacks.
|
|
28
|
+
*
|
|
29
|
+
* The returned function preserves Vitest test options and shorthand helpers
|
|
30
|
+
* such as `test.skip()`, `test.todo()`, `test.only()`, `test.fails()`,
|
|
31
|
+
* `test.concurrent()`, `test.sequential()`, `test.skipIf()`,
|
|
32
|
+
* `test.runIf()`, `test.each()`, `test.for()`, and `test.extend()`. Only
|
|
33
|
+
* callback arguments are adapted; options are passed through to Vitest.
|
|
34
|
+
*
|
|
35
|
+
* @param options Failure log reporter options.
|
|
36
|
+
* @returns A configured Vitest-compatible test function.
|
|
37
|
+
* @since 2.3.0
|
|
38
|
+
*/
|
|
39
|
+
function createTest(options = {}) {
|
|
40
|
+
return createVitestTestFunction(test, options);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Creates an `it()` alias that reports LogTape records from failed test
|
|
44
|
+
* callbacks.
|
|
45
|
+
*
|
|
46
|
+
* @param options Failure log reporter options.
|
|
47
|
+
* @returns A configured Vitest-compatible `it()` function.
|
|
48
|
+
* @since 2.3.0
|
|
49
|
+
*/
|
|
50
|
+
function createIt(options = {}) {
|
|
51
|
+
return createVitestTestFunction(it$1, options);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Creates a Vitest-compatible namespace with wrapped `test()` and `it()`
|
|
55
|
+
* functions.
|
|
56
|
+
*
|
|
57
|
+
* This is useful when existing test files already import several helpers from
|
|
58
|
+
* Vitest and you want to switch them to one LogTape-aware namespace.
|
|
59
|
+
*
|
|
60
|
+
* @param options Failure log reporter options.
|
|
61
|
+
* @returns A Vitest-compatible namespace.
|
|
62
|
+
* @since 2.3.0
|
|
63
|
+
*/
|
|
64
|
+
function createVitest(options = {}) {
|
|
65
|
+
return {
|
|
66
|
+
afterAll,
|
|
67
|
+
afterEach,
|
|
68
|
+
aroundAll,
|
|
69
|
+
aroundEach,
|
|
70
|
+
assert,
|
|
71
|
+
bench,
|
|
72
|
+
beforeAll,
|
|
73
|
+
beforeEach,
|
|
74
|
+
chai,
|
|
75
|
+
createExpect,
|
|
76
|
+
describe,
|
|
77
|
+
expect,
|
|
78
|
+
expectTypeOf,
|
|
79
|
+
inject,
|
|
80
|
+
it: createIt(options),
|
|
81
|
+
onTestFailed,
|
|
82
|
+
onTestFinished,
|
|
83
|
+
should,
|
|
84
|
+
suite,
|
|
85
|
+
test: createTest(options),
|
|
86
|
+
vi,
|
|
87
|
+
vitest
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* A Vitest `test()` function that reports LogTape records from failed test
|
|
92
|
+
* callbacks using the default reporter options.
|
|
93
|
+
*
|
|
94
|
+
* @since 2.3.0
|
|
95
|
+
*/
|
|
96
|
+
const test$1 = createTest();
|
|
97
|
+
/**
|
|
98
|
+
* A Vitest `it()` alias that reports LogTape records from failed test
|
|
99
|
+
* callbacks using the default reporter options.
|
|
100
|
+
*
|
|
101
|
+
* @since 2.3.0
|
|
102
|
+
*/
|
|
103
|
+
const it = createIt();
|
|
104
|
+
/**
|
|
105
|
+
* Shorthand for skipping a test.
|
|
106
|
+
*
|
|
107
|
+
* @since 2.3.0
|
|
108
|
+
*/
|
|
109
|
+
const skip = test$1.skip;
|
|
110
|
+
/**
|
|
111
|
+
* Shorthand for marking a test as TODO.
|
|
112
|
+
*
|
|
113
|
+
* @since 2.3.0
|
|
114
|
+
*/
|
|
115
|
+
const todo = test$1.todo;
|
|
116
|
+
/**
|
|
117
|
+
* Shorthand for marking a test as `only`.
|
|
118
|
+
*
|
|
119
|
+
* @since 2.3.0
|
|
120
|
+
*/
|
|
121
|
+
const only = test$1.only;
|
|
122
|
+
/**
|
|
123
|
+
* Shorthand for marking a test as expected to fail.
|
|
124
|
+
*
|
|
125
|
+
* @since 2.3.0
|
|
126
|
+
*/
|
|
127
|
+
const fails = test$1.fails;
|
|
128
|
+
/**
|
|
129
|
+
* Shorthand for running a test concurrently.
|
|
130
|
+
*
|
|
131
|
+
* @since 2.3.0
|
|
132
|
+
*/
|
|
133
|
+
const concurrent = test$1.concurrent;
|
|
134
|
+
/**
|
|
135
|
+
* Shorthand for running a test sequentially.
|
|
136
|
+
*
|
|
137
|
+
* @since 2.3.0
|
|
138
|
+
*/
|
|
139
|
+
const sequential = test$1.sequential;
|
|
140
|
+
/**
|
|
141
|
+
* Shorthand for Vitest's parameterized tests.
|
|
142
|
+
*
|
|
143
|
+
* @since 2.3.0
|
|
144
|
+
*/
|
|
145
|
+
const each = test$1.each;
|
|
146
|
+
/**
|
|
147
|
+
* Shorthand for Vitest's parameterized tests with a preserved test context.
|
|
148
|
+
*
|
|
149
|
+
* @since 2.3.0
|
|
150
|
+
*/
|
|
151
|
+
const for_ = test$1.for;
|
|
152
|
+
var src_default = test$1;
|
|
153
|
+
function createVitestTestFunction(baseTest, options, cache = /* @__PURE__ */ new WeakMap(), depth = 0) {
|
|
154
|
+
const cached = cache.get(baseTest);
|
|
155
|
+
if (cached != null) return cached;
|
|
156
|
+
const register = (...args) => Reflect.apply(baseTest, void 0, wrapVitestArguments(args, options));
|
|
157
|
+
cache.set(baseTest, register);
|
|
158
|
+
if (depth < 2) for (const helperName of helperNames) {
|
|
159
|
+
const helper = getFunctionProperty(baseTest, helperName);
|
|
160
|
+
if (helper == null) continue;
|
|
161
|
+
Object.defineProperty(register, helperName, {
|
|
162
|
+
configurable: true,
|
|
163
|
+
enumerable: true,
|
|
164
|
+
value: createVitestTestFunction(helper, options, cache, depth + 1),
|
|
165
|
+
writable: true
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
for (const helperName of conditionalHelperNames) {
|
|
169
|
+
const helper = getFunctionProperty(baseTest, helperName);
|
|
170
|
+
if (helper == null) continue;
|
|
171
|
+
Object.defineProperty(register, helperName, {
|
|
172
|
+
configurable: true,
|
|
173
|
+
enumerable: true,
|
|
174
|
+
value: (condition) => {
|
|
175
|
+
const conditionalTest = Reflect.apply(helper, baseTest, [condition]);
|
|
176
|
+
return createVitestTestFunction(conditionalTest, options, cache, depth + 1);
|
|
177
|
+
},
|
|
178
|
+
writable: true
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
for (const helperName of hookNames) {
|
|
182
|
+
const helper = getFunctionProperty(baseTest, helperName);
|
|
183
|
+
if (helper == null) continue;
|
|
184
|
+
Object.defineProperty(register, helperName, {
|
|
185
|
+
configurable: true,
|
|
186
|
+
enumerable: true,
|
|
187
|
+
value: createWrappedFunction(helper, options),
|
|
188
|
+
writable: true
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
for (const helperName of nestedSuiteNames) {
|
|
192
|
+
const helper = getFunctionProperty(baseTest, helperName);
|
|
193
|
+
if (helper == null) continue;
|
|
194
|
+
Object.defineProperty(register, helperName, {
|
|
195
|
+
configurable: true,
|
|
196
|
+
enumerable: true,
|
|
197
|
+
value: helper,
|
|
198
|
+
writable: true
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
const each$1 = getFunctionProperty(baseTest, "each");
|
|
202
|
+
if (each$1 != null) Object.defineProperty(register, "each", {
|
|
203
|
+
configurable: true,
|
|
204
|
+
enumerable: true,
|
|
205
|
+
value: createWrappedParameterized(baseTest, each$1, options),
|
|
206
|
+
writable: true
|
|
207
|
+
});
|
|
208
|
+
const for_$1 = getFunctionProperty(baseTest, "for");
|
|
209
|
+
if (for_$1 != null) Object.defineProperty(register, "for", {
|
|
210
|
+
configurable: true,
|
|
211
|
+
enumerable: true,
|
|
212
|
+
value: createWrappedParameterized(baseTest, for_$1, options),
|
|
213
|
+
writable: true
|
|
214
|
+
});
|
|
215
|
+
const extend = getFunctionProperty(baseTest, "extend");
|
|
216
|
+
if (extend != null) Object.defineProperty(register, "extend", {
|
|
217
|
+
configurable: true,
|
|
218
|
+
enumerable: true,
|
|
219
|
+
value: (...args) => {
|
|
220
|
+
const extendedTest = Reflect.apply(extend, baseTest, args);
|
|
221
|
+
return createVitestTestFunction(extendedTest, options, cache);
|
|
222
|
+
},
|
|
223
|
+
writable: true
|
|
224
|
+
});
|
|
225
|
+
const override = getFunctionProperty(baseTest, "override");
|
|
226
|
+
if (override != null) Object.defineProperty(register, "override", {
|
|
227
|
+
configurable: true,
|
|
228
|
+
enumerable: true,
|
|
229
|
+
value: override,
|
|
230
|
+
writable: true
|
|
231
|
+
});
|
|
232
|
+
const scoped = getFunctionProperty(baseTest, "scoped");
|
|
233
|
+
if (scoped != null) Object.defineProperty(register, "scoped", {
|
|
234
|
+
configurable: true,
|
|
235
|
+
enumerable: true,
|
|
236
|
+
value: scoped,
|
|
237
|
+
writable: true
|
|
238
|
+
});
|
|
239
|
+
return register;
|
|
240
|
+
}
|
|
241
|
+
function createWrappedParameterized(baseTest, baseParameterized, options) {
|
|
242
|
+
return (...cases) => {
|
|
243
|
+
const registerParameterized = Reflect.apply(baseParameterized, baseTest, cases);
|
|
244
|
+
return (...args) => Reflect.apply(registerParameterized, void 0, wrapVitestParameterizedArguments(args, options));
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
function createWrappedFunction(baseFunction, options) {
|
|
248
|
+
return function(...args) {
|
|
249
|
+
return Reflect.apply(baseFunction, this, wrapVitestArguments(args, options));
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
function wrapVitestArguments(args, options) {
|
|
253
|
+
const callbackIndex = args.findIndex((arg) => typeof arg === "function");
|
|
254
|
+
if (callbackIndex < 0) return [...args];
|
|
255
|
+
return [
|
|
256
|
+
...args.slice(0, callbackIndex),
|
|
257
|
+
wrapVitestCallback(args[callbackIndex], options),
|
|
258
|
+
...args.slice(callbackIndex + 1)
|
|
259
|
+
];
|
|
260
|
+
}
|
|
261
|
+
function wrapVitestParameterizedArguments(args, options) {
|
|
262
|
+
const callbackIndex = args.findIndex((arg, index) => index > 0 && typeof arg === "function");
|
|
263
|
+
if (callbackIndex < 0) return [...args];
|
|
264
|
+
return [
|
|
265
|
+
...args.slice(0, callbackIndex),
|
|
266
|
+
wrapVitestCallback(args[callbackIndex], options),
|
|
267
|
+
...args.slice(callbackIndex + 1)
|
|
268
|
+
];
|
|
269
|
+
}
|
|
270
|
+
function wrapVitestCallback(callback, options) {
|
|
271
|
+
const reporter = createFailureLogReporter(options);
|
|
272
|
+
const wrapped = function(...args) {
|
|
273
|
+
return reporter.run(() => Reflect.apply(callback, this, args));
|
|
274
|
+
};
|
|
275
|
+
Object.defineProperty(wrapped, "toString", {
|
|
276
|
+
configurable: true,
|
|
277
|
+
value: () => String(callback)
|
|
278
|
+
});
|
|
279
|
+
return wrapped;
|
|
280
|
+
}
|
|
281
|
+
function getFunctionProperty(value, property) {
|
|
282
|
+
try {
|
|
283
|
+
const propertyValue = Reflect.get(value, property);
|
|
284
|
+
return typeof propertyValue === "function" ? propertyValue : void 0;
|
|
285
|
+
} catch {
|
|
286
|
+
return void 0;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region src/autoload.ts
|
|
292
|
+
const config = getConfig();
|
|
293
|
+
if (config == null) configureSync({
|
|
294
|
+
contextLocalStorage: new AsyncLocalStorage(),
|
|
295
|
+
sinks: {},
|
|
296
|
+
loggers: [{
|
|
297
|
+
category: ["logtape", "meta"],
|
|
298
|
+
sinks: []
|
|
299
|
+
}]
|
|
300
|
+
});
|
|
301
|
+
else if (config.contextLocalStorage == null) throw new ConfigError("@logtape/testing-vitest/autoload requires the existing LogTape configuration to provide contextLocalStorage.");
|
|
302
|
+
var autoload_default = src_default;
|
|
303
|
+
|
|
304
|
+
//#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, src_default as test, todo, vi, vitest };
|
|
306
|
+
//# sourceMappingURL=autoload.js.map
|
|
@@ -0,0 +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":";;;;;;AAyHA,MAAM,cAAc;CAClB;CACA;CACA;CACA;CACA;CACA;AACD;AAED,MAAM,yBAAyB,CAC7B,UAC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AAgB,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"}
|
package/dist/mod.d.ts
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
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
|
+
import { FailureLogReportMode, FailureLogReporterOptions, FailureLogReporterOptions as FailureLogReporterOptions$1 } from "@logtape/testing/reporter";
|
|
3
|
+
|
|
4
|
+
//#region src/mod.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A Vitest-compatible namespace with LogTape-wrapped `test()` and `it()`
|
|
8
|
+
* functions.
|
|
9
|
+
*
|
|
10
|
+
* @since 2.3.0
|
|
11
|
+
*/
|
|
12
|
+
interface VitestTesting {
|
|
13
|
+
readonly afterAll: typeof afterAll;
|
|
14
|
+
readonly afterEach: typeof afterEach;
|
|
15
|
+
readonly aroundAll: typeof aroundAll;
|
|
16
|
+
readonly aroundEach: typeof aroundEach;
|
|
17
|
+
readonly assert: typeof assert;
|
|
18
|
+
readonly bench: typeof bench;
|
|
19
|
+
readonly beforeAll: typeof beforeAll;
|
|
20
|
+
readonly beforeEach: typeof beforeEach;
|
|
21
|
+
readonly chai: typeof chai;
|
|
22
|
+
readonly createExpect: typeof createExpect;
|
|
23
|
+
readonly describe: typeof describe;
|
|
24
|
+
readonly expect: typeof expect;
|
|
25
|
+
readonly expectTypeOf: typeof expectTypeOf;
|
|
26
|
+
readonly inject: typeof inject;
|
|
27
|
+
readonly it: TestAPI;
|
|
28
|
+
readonly onTestFailed: typeof onTestFailed;
|
|
29
|
+
readonly onTestFinished: typeof onTestFinished;
|
|
30
|
+
readonly should: typeof should;
|
|
31
|
+
readonly suite: typeof suite;
|
|
32
|
+
readonly test: TestAPI;
|
|
33
|
+
readonly vi: typeof vi;
|
|
34
|
+
readonly vitest: typeof vitest;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Creates a Vitest `test()` function that reports LogTape records from failed
|
|
38
|
+
* test callbacks.
|
|
39
|
+
*
|
|
40
|
+
* The returned function preserves Vitest test options and shorthand helpers
|
|
41
|
+
* such as `test.skip()`, `test.todo()`, `test.only()`, `test.fails()`,
|
|
42
|
+
* `test.concurrent()`, `test.sequential()`, `test.skipIf()`,
|
|
43
|
+
* `test.runIf()`, `test.each()`, `test.for()`, and `test.extend()`. Only
|
|
44
|
+
* callback arguments are adapted; options are passed through to Vitest.
|
|
45
|
+
*
|
|
46
|
+
* @param options Failure log reporter options.
|
|
47
|
+
* @returns A configured Vitest-compatible test function.
|
|
48
|
+
* @since 2.3.0
|
|
49
|
+
*/
|
|
50
|
+
declare function createTest(options?: FailureLogReporterOptions$1): TestAPI;
|
|
51
|
+
/**
|
|
52
|
+
* Creates an `it()` alias that reports LogTape records from failed test
|
|
53
|
+
* callbacks.
|
|
54
|
+
*
|
|
55
|
+
* @param options Failure log reporter options.
|
|
56
|
+
* @returns A configured Vitest-compatible `it()` function.
|
|
57
|
+
* @since 2.3.0
|
|
58
|
+
*/
|
|
59
|
+
declare function createIt(options?: FailureLogReporterOptions$1): TestAPI;
|
|
60
|
+
/**
|
|
61
|
+
* Creates a Vitest-compatible namespace with wrapped `test()` and `it()`
|
|
62
|
+
* functions.
|
|
63
|
+
*
|
|
64
|
+
* This is useful when existing test files already import several helpers from
|
|
65
|
+
* Vitest and you want to switch them to one LogTape-aware namespace.
|
|
66
|
+
*
|
|
67
|
+
* @param options Failure log reporter options.
|
|
68
|
+
* @returns A Vitest-compatible namespace.
|
|
69
|
+
* @since 2.3.0
|
|
70
|
+
*/
|
|
71
|
+
declare function createVitest(options?: FailureLogReporterOptions$1): VitestTesting;
|
|
72
|
+
/**
|
|
73
|
+
* A Vitest `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: TestAPI;
|
|
79
|
+
/**
|
|
80
|
+
* A Vitest `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: TestAPI;
|
|
86
|
+
/**
|
|
87
|
+
* Shorthand for skipping a test.
|
|
88
|
+
*
|
|
89
|
+
* @since 2.3.0
|
|
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"];
|
|
134
|
+
//#endregion
|
|
135
|
+
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
|
+
//# sourceMappingURL=mod.d.ts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,MAAM;;;;;;cAON,MAAM;;;;;;cAON,MAAM;;;;;;cAON,OAAO;;;;;;cAOP,YAAY;;;;;;cAOZ,YAAY;;;;;;cAOZ,MAAM;;;;;;cAOb,MAAM"}
|
package/dist/mod.js
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
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";
|
|
2
|
+
import { createFailureLogReporter } from "@logtape/testing/reporter";
|
|
3
|
+
|
|
4
|
+
//#region src/mod.ts
|
|
5
|
+
const helperNames = [
|
|
6
|
+
"skip",
|
|
7
|
+
"todo",
|
|
8
|
+
"only",
|
|
9
|
+
"fails",
|
|
10
|
+
"concurrent",
|
|
11
|
+
"sequential"
|
|
12
|
+
];
|
|
13
|
+
const conditionalHelperNames = ["skipIf", "runIf"];
|
|
14
|
+
const hookNames = [
|
|
15
|
+
"beforeAll",
|
|
16
|
+
"afterAll",
|
|
17
|
+
"aroundAll",
|
|
18
|
+
"beforeEach",
|
|
19
|
+
"afterEach",
|
|
20
|
+
"aroundEach"
|
|
21
|
+
];
|
|
22
|
+
const nestedSuiteNames = ["describe", "suite"];
|
|
23
|
+
/**
|
|
24
|
+
* Creates a Vitest `test()` function that reports LogTape records from failed
|
|
25
|
+
* test callbacks.
|
|
26
|
+
*
|
|
27
|
+
* The returned function preserves Vitest test options and shorthand helpers
|
|
28
|
+
* such as `test.skip()`, `test.todo()`, `test.only()`, `test.fails()`,
|
|
29
|
+
* `test.concurrent()`, `test.sequential()`, `test.skipIf()`,
|
|
30
|
+
* `test.runIf()`, `test.each()`, `test.for()`, and `test.extend()`. Only
|
|
31
|
+
* callback arguments are adapted; options are passed through to Vitest.
|
|
32
|
+
*
|
|
33
|
+
* @param options Failure log reporter options.
|
|
34
|
+
* @returns A configured Vitest-compatible test function.
|
|
35
|
+
* @since 2.3.0
|
|
36
|
+
*/
|
|
37
|
+
function createTest(options = {}) {
|
|
38
|
+
return createVitestTestFunction(test$1, options);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Creates an `it()` alias that reports LogTape records from failed test
|
|
42
|
+
* callbacks.
|
|
43
|
+
*
|
|
44
|
+
* @param options Failure log reporter options.
|
|
45
|
+
* @returns A configured Vitest-compatible `it()` function.
|
|
46
|
+
* @since 2.3.0
|
|
47
|
+
*/
|
|
48
|
+
function createIt(options = {}) {
|
|
49
|
+
return createVitestTestFunction(it$1, options);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Creates a Vitest-compatible namespace with wrapped `test()` and `it()`
|
|
53
|
+
* functions.
|
|
54
|
+
*
|
|
55
|
+
* This is useful when existing test files already import several helpers from
|
|
56
|
+
* Vitest and you want to switch them to one LogTape-aware namespace.
|
|
57
|
+
*
|
|
58
|
+
* @param options Failure log reporter options.
|
|
59
|
+
* @returns A Vitest-compatible namespace.
|
|
60
|
+
* @since 2.3.0
|
|
61
|
+
*/
|
|
62
|
+
function createVitest(options = {}) {
|
|
63
|
+
return {
|
|
64
|
+
afterAll,
|
|
65
|
+
afterEach,
|
|
66
|
+
aroundAll,
|
|
67
|
+
aroundEach,
|
|
68
|
+
assert,
|
|
69
|
+
bench,
|
|
70
|
+
beforeAll,
|
|
71
|
+
beforeEach,
|
|
72
|
+
chai,
|
|
73
|
+
createExpect,
|
|
74
|
+
describe,
|
|
75
|
+
expect,
|
|
76
|
+
expectTypeOf,
|
|
77
|
+
inject,
|
|
78
|
+
it: createIt(options),
|
|
79
|
+
onTestFailed,
|
|
80
|
+
onTestFinished,
|
|
81
|
+
should,
|
|
82
|
+
suite,
|
|
83
|
+
test: createTest(options),
|
|
84
|
+
vi,
|
|
85
|
+
vitest
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A Vitest `test()` function that reports LogTape records from failed test
|
|
90
|
+
* callbacks using the default reporter options.
|
|
91
|
+
*
|
|
92
|
+
* @since 2.3.0
|
|
93
|
+
*/
|
|
94
|
+
const test = createTest();
|
|
95
|
+
/**
|
|
96
|
+
* A Vitest `it()` alias that reports LogTape records from failed test
|
|
97
|
+
* callbacks using the default reporter options.
|
|
98
|
+
*
|
|
99
|
+
* @since 2.3.0
|
|
100
|
+
*/
|
|
101
|
+
const it = createIt();
|
|
102
|
+
/**
|
|
103
|
+
* Shorthand for skipping a test.
|
|
104
|
+
*
|
|
105
|
+
* @since 2.3.0
|
|
106
|
+
*/
|
|
107
|
+
const skip = test.skip;
|
|
108
|
+
/**
|
|
109
|
+
* Shorthand for marking a test as TODO.
|
|
110
|
+
*
|
|
111
|
+
* @since 2.3.0
|
|
112
|
+
*/
|
|
113
|
+
const todo = test.todo;
|
|
114
|
+
/**
|
|
115
|
+
* Shorthand for marking a test as `only`.
|
|
116
|
+
*
|
|
117
|
+
* @since 2.3.0
|
|
118
|
+
*/
|
|
119
|
+
const only = test.only;
|
|
120
|
+
/**
|
|
121
|
+
* Shorthand for marking a test as expected to fail.
|
|
122
|
+
*
|
|
123
|
+
* @since 2.3.0
|
|
124
|
+
*/
|
|
125
|
+
const fails = test.fails;
|
|
126
|
+
/**
|
|
127
|
+
* Shorthand for running a test concurrently.
|
|
128
|
+
*
|
|
129
|
+
* @since 2.3.0
|
|
130
|
+
*/
|
|
131
|
+
const concurrent = test.concurrent;
|
|
132
|
+
/**
|
|
133
|
+
* Shorthand for running a test sequentially.
|
|
134
|
+
*
|
|
135
|
+
* @since 2.3.0
|
|
136
|
+
*/
|
|
137
|
+
const sequential = test.sequential;
|
|
138
|
+
/**
|
|
139
|
+
* Shorthand for Vitest's parameterized tests.
|
|
140
|
+
*
|
|
141
|
+
* @since 2.3.0
|
|
142
|
+
*/
|
|
143
|
+
const each = test.each;
|
|
144
|
+
/**
|
|
145
|
+
* Shorthand for Vitest's parameterized tests with a preserved test context.
|
|
146
|
+
*
|
|
147
|
+
* @since 2.3.0
|
|
148
|
+
*/
|
|
149
|
+
const for_ = test.for;
|
|
150
|
+
var src_default = test;
|
|
151
|
+
function createVitestTestFunction(baseTest, options, cache = /* @__PURE__ */ new WeakMap(), depth = 0) {
|
|
152
|
+
const cached = cache.get(baseTest);
|
|
153
|
+
if (cached != null) return cached;
|
|
154
|
+
const register = (...args) => Reflect.apply(baseTest, void 0, wrapVitestArguments(args, options));
|
|
155
|
+
cache.set(baseTest, register);
|
|
156
|
+
if (depth < 2) for (const helperName of helperNames) {
|
|
157
|
+
const helper = getFunctionProperty(baseTest, helperName);
|
|
158
|
+
if (helper == null) continue;
|
|
159
|
+
Object.defineProperty(register, helperName, {
|
|
160
|
+
configurable: true,
|
|
161
|
+
enumerable: true,
|
|
162
|
+
value: createVitestTestFunction(helper, options, cache, depth + 1),
|
|
163
|
+
writable: true
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
for (const helperName of conditionalHelperNames) {
|
|
167
|
+
const helper = getFunctionProperty(baseTest, helperName);
|
|
168
|
+
if (helper == null) continue;
|
|
169
|
+
Object.defineProperty(register, helperName, {
|
|
170
|
+
configurable: true,
|
|
171
|
+
enumerable: true,
|
|
172
|
+
value: (condition) => {
|
|
173
|
+
const conditionalTest = Reflect.apply(helper, baseTest, [condition]);
|
|
174
|
+
return createVitestTestFunction(conditionalTest, options, cache, depth + 1);
|
|
175
|
+
},
|
|
176
|
+
writable: true
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
for (const helperName of hookNames) {
|
|
180
|
+
const helper = getFunctionProperty(baseTest, helperName);
|
|
181
|
+
if (helper == null) continue;
|
|
182
|
+
Object.defineProperty(register, helperName, {
|
|
183
|
+
configurable: true,
|
|
184
|
+
enumerable: true,
|
|
185
|
+
value: createWrappedFunction(helper, options),
|
|
186
|
+
writable: true
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
for (const helperName of nestedSuiteNames) {
|
|
190
|
+
const helper = getFunctionProperty(baseTest, helperName);
|
|
191
|
+
if (helper == null) continue;
|
|
192
|
+
Object.defineProperty(register, helperName, {
|
|
193
|
+
configurable: true,
|
|
194
|
+
enumerable: true,
|
|
195
|
+
value: helper,
|
|
196
|
+
writable: true
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
const each$1 = getFunctionProperty(baseTest, "each");
|
|
200
|
+
if (each$1 != null) Object.defineProperty(register, "each", {
|
|
201
|
+
configurable: true,
|
|
202
|
+
enumerable: true,
|
|
203
|
+
value: createWrappedParameterized(baseTest, each$1, options),
|
|
204
|
+
writable: true
|
|
205
|
+
});
|
|
206
|
+
const for_$1 = getFunctionProperty(baseTest, "for");
|
|
207
|
+
if (for_$1 != null) Object.defineProperty(register, "for", {
|
|
208
|
+
configurable: true,
|
|
209
|
+
enumerable: true,
|
|
210
|
+
value: createWrappedParameterized(baseTest, for_$1, options),
|
|
211
|
+
writable: true
|
|
212
|
+
});
|
|
213
|
+
const extend = getFunctionProperty(baseTest, "extend");
|
|
214
|
+
if (extend != null) Object.defineProperty(register, "extend", {
|
|
215
|
+
configurable: true,
|
|
216
|
+
enumerable: true,
|
|
217
|
+
value: (...args) => {
|
|
218
|
+
const extendedTest = Reflect.apply(extend, baseTest, args);
|
|
219
|
+
return createVitestTestFunction(extendedTest, options, cache);
|
|
220
|
+
},
|
|
221
|
+
writable: true
|
|
222
|
+
});
|
|
223
|
+
const override = getFunctionProperty(baseTest, "override");
|
|
224
|
+
if (override != null) Object.defineProperty(register, "override", {
|
|
225
|
+
configurable: true,
|
|
226
|
+
enumerable: true,
|
|
227
|
+
value: override,
|
|
228
|
+
writable: true
|
|
229
|
+
});
|
|
230
|
+
const scoped = getFunctionProperty(baseTest, "scoped");
|
|
231
|
+
if (scoped != null) Object.defineProperty(register, "scoped", {
|
|
232
|
+
configurable: true,
|
|
233
|
+
enumerable: true,
|
|
234
|
+
value: scoped,
|
|
235
|
+
writable: true
|
|
236
|
+
});
|
|
237
|
+
return register;
|
|
238
|
+
}
|
|
239
|
+
function createWrappedParameterized(baseTest, baseParameterized, options) {
|
|
240
|
+
return (...cases) => {
|
|
241
|
+
const registerParameterized = Reflect.apply(baseParameterized, baseTest, cases);
|
|
242
|
+
return (...args) => Reflect.apply(registerParameterized, void 0, wrapVitestParameterizedArguments(args, options));
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
function createWrappedFunction(baseFunction, options) {
|
|
246
|
+
return function(...args) {
|
|
247
|
+
return Reflect.apply(baseFunction, this, wrapVitestArguments(args, options));
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function wrapVitestArguments(args, options) {
|
|
251
|
+
const callbackIndex = args.findIndex((arg) => typeof arg === "function");
|
|
252
|
+
if (callbackIndex < 0) return [...args];
|
|
253
|
+
return [
|
|
254
|
+
...args.slice(0, callbackIndex),
|
|
255
|
+
wrapVitestCallback(args[callbackIndex], options),
|
|
256
|
+
...args.slice(callbackIndex + 1)
|
|
257
|
+
];
|
|
258
|
+
}
|
|
259
|
+
function wrapVitestParameterizedArguments(args, options) {
|
|
260
|
+
const callbackIndex = args.findIndex((arg, index) => index > 0 && typeof arg === "function");
|
|
261
|
+
if (callbackIndex < 0) return [...args];
|
|
262
|
+
return [
|
|
263
|
+
...args.slice(0, callbackIndex),
|
|
264
|
+
wrapVitestCallback(args[callbackIndex], options),
|
|
265
|
+
...args.slice(callbackIndex + 1)
|
|
266
|
+
];
|
|
267
|
+
}
|
|
268
|
+
function wrapVitestCallback(callback, options) {
|
|
269
|
+
const reporter = createFailureLogReporter(options);
|
|
270
|
+
const wrapped = function(...args) {
|
|
271
|
+
return reporter.run(() => Reflect.apply(callback, this, args));
|
|
272
|
+
};
|
|
273
|
+
Object.defineProperty(wrapped, "toString", {
|
|
274
|
+
configurable: true,
|
|
275
|
+
value: () => String(callback)
|
|
276
|
+
});
|
|
277
|
+
return wrapped;
|
|
278
|
+
}
|
|
279
|
+
function getFunctionProperty(value, property) {
|
|
280
|
+
try {
|
|
281
|
+
const propertyValue = Reflect.get(value, property);
|
|
282
|
+
return typeof propertyValue === "function" ? propertyValue : void 0;
|
|
283
|
+
} catch {
|
|
284
|
+
return void 0;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
//#endregion
|
|
289
|
+
export { afterAll, afterEach, aroundAll, aroundEach, assert, beforeAll, beforeEach, bench, chai, concurrent, createExpect, createIt, createTest, createVitest, src_default as default, describe, each, expect, expectTypeOf, fails, for_ as for, inject, it, onTestFailed, onTestFinished, only, sequential, should, skip, suite, test, todo, vi, vitest };
|
|
290
|
+
//# sourceMappingURL=mod.js.map
|
package/dist/mod.js.map
ADDED
|
@@ -0,0 +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,Q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
"version": "2.3.0-dev.0",
|
|
4
|
+
"description": "Vitest integration for LogTape failure log reporting",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"logging",
|
|
7
|
+
"log",
|
|
8
|
+
"logger",
|
|
9
|
+
"logtape",
|
|
10
|
+
"testing",
|
|
11
|
+
"test",
|
|
12
|
+
"vitest"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "Hong Minhee",
|
|
17
|
+
"email": "hong@minhee.org",
|
|
18
|
+
"url": "https://hongminhee.org/"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://logtape.org/",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/dahlia/logtape.git",
|
|
24
|
+
"directory": "packages/testing-vitest/"
|
|
25
|
+
},
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/dahlia/logtape/issues"
|
|
28
|
+
},
|
|
29
|
+
"funding": [
|
|
30
|
+
"https://github.com/sponsors/dahlia"
|
|
31
|
+
],
|
|
32
|
+
"type": "module",
|
|
33
|
+
"module": "./dist/mod.js",
|
|
34
|
+
"types": "./dist/mod.d.ts",
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./dist/mod.d.ts",
|
|
38
|
+
"import": "./dist/mod.js"
|
|
39
|
+
},
|
|
40
|
+
"./autoload": {
|
|
41
|
+
"types": "./dist/autoload.d.ts",
|
|
42
|
+
"import": "./dist/autoload.js"
|
|
43
|
+
},
|
|
44
|
+
"./package.json": "./package.json"
|
|
45
|
+
},
|
|
46
|
+
"sideEffects": [
|
|
47
|
+
"./dist/autoload.js"
|
|
48
|
+
],
|
|
49
|
+
"files": [
|
|
50
|
+
"dist/"
|
|
51
|
+
],
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@logtape/testing": "^2.3.0"
|
|
54
|
+
},
|
|
55
|
+
"peerDependencies": {
|
|
56
|
+
"vitest": "^4.1.6",
|
|
57
|
+
"@logtape/logtape": "^2.3.0"
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"tsdown": "^0.12.7",
|
|
61
|
+
"typescript": "^5.8.3",
|
|
62
|
+
"vitest": "^4.1.6",
|
|
63
|
+
"@logtape/logtape": "^2.3.0"
|
|
64
|
+
},
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "tsdown",
|
|
67
|
+
"prepublish": "tsdown",
|
|
68
|
+
"test": "tsdown && node --experimental-transform-types --test",
|
|
69
|
+
"test:bun": "tsdown && bun test",
|
|
70
|
+
"test:deno": "deno test --allow-read --allow-write --allow-env --allow-run=pnpm",
|
|
71
|
+
"test-all": "tsdown && node --experimental-transform-types --test && bun test && deno test --allow-read --allow-write --allow-env --allow-run=pnpm"
|
|
72
|
+
}
|
|
73
|
+
}
|