@depup/vitest 4.1.0-depup.1 → 4.1.2-depup.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/README.md +4 -4
- package/changes.json +26 -0
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +3 -3
- package/dist/chunks/{base.DM0-RqVb.js → base.BPik1OqN.js} +8 -8
- package/dist/chunks/{benchmark.D0SlKNbZ.js → benchmark.CX_oY03V.js} +1 -1
- package/dist/chunks/{browser.d.X3SXoOCV.d.ts → browser.d.BMOr_Kmk.d.ts} +1 -1
- package/dist/chunks/{cac.CWGDZnXT.js → cac.DRKYQDPl.js} +22 -10
- package/dist/chunks/{cli-api.DuT9iuvY.js → cli-api.Bxr1Nn49.js} +154 -40
- package/dist/chunks/{config.d.EJLVE3es.d.ts → config.d.Cz9kPrQs.d.ts} +1 -0
- package/dist/chunks/{coverage.D_JHT54q.js → coverage.CTzCuANN.js} +4 -1
- package/dist/chunks/{coverage.Bri33R1t.js → coverage.kqM80boz.js} +26 -11
- package/dist/chunks/{defaults.CdU2lD-q.js → defaults.9aQKnqFk.js} +13 -5
- package/dist/chunks/{globals.BXNGLnTL.js → globals.CVqIbOyt.js} +3 -3
- package/dist/chunks/{index.DXMFO5MJ.js → index.0GYC6HAu.js} +627 -586
- package/dist/chunks/{index.EY6TCHpo.js → index.DC7d2Pf8.js} +2 -2
- package/dist/chunks/{index.DlDSLQD3.js → index.DOa3dzoN.js} +2 -2
- package/dist/chunks/{index.DGNSnENe.js → index.nZ2xqFgD.js} +2 -2
- package/dist/chunks/{init-forks.DeArv0jT.js → init-forks.UV3ZQGQH.js} +1 -1
- package/dist/chunks/{init-threads.-2OUl4Nn.js → init-threads.D3eCsY76.js} +1 -1
- package/dist/chunks/{init.DICorXCo.js → init.D98-gwRW.js} +5 -3
- package/dist/chunks/{nativeModuleMocker.DndvSdL6.js → nativeModuleMocker.BRN2oBJd.js} +2 -2
- package/dist/chunks/{plugin.d.BuW-flqo.d.ts → plugin.d.BWbK_Jpw.d.ts} +1 -1
- package/dist/chunks/{reporters.d.DVUYHHhe.d.ts → reporters.d.B0uk8id2.d.ts} +54 -33
- package/dist/chunks/{setup-common.B41N_kPE.js → setup-common.2wZXQUjS.js} +2 -2
- package/dist/chunks/{startVitestModuleRunner.C3ZR-4J3.js → startVitestModuleRunner.bRl2_oI_.js} +19 -5
- package/dist/chunks/{test.CTcmp4Su.js → test.p_J6dB8a.js} +3 -2
- package/dist/chunks/{traces.CCmnQaNT.js → traces.DT5aQ62U.js} +1 -1
- package/dist/chunks/utils.DK8FXp4T.js +189 -0
- package/dist/chunks/{vm.Dh2rTtmP.js → vm.BvVhnZPV.js} +2 -2
- package/dist/chunks/{worker.d.B84sVRy0.d.ts → worker.d.BT5j8dyR.d.ts} +1 -1
- package/dist/cli.js +2 -20
- package/dist/config.cjs +13 -5
- package/dist/config.d.ts +8 -8
- package/dist/config.js +1 -1
- package/dist/coverage.d.ts +7 -7
- package/dist/coverage.js +3 -3
- package/dist/environments.js +1 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.js +3 -3
- package/dist/module-evaluator.js +2 -2
- package/dist/node.d.ts +7 -7
- package/dist/node.js +11 -11
- package/dist/reporters.d.ts +4 -4
- package/dist/reporters.js +6 -6
- package/dist/runners.d.ts +3 -2
- package/dist/runners.js +2 -2
- package/dist/runtime.js +3 -3
- package/dist/suite.js +1 -1
- package/dist/worker.d.ts +2 -2
- package/dist/worker.js +12 -11
- package/dist/workers/forks.js +13 -12
- package/dist/workers/runVmTests.js +6 -6
- package/dist/workers/threads.js +13 -12
- package/dist/workers/vmForks.js +7 -7
- package/dist/workers/vmThreads.js +7 -7
- package/optional-runtime-types.d.ts +6 -0
- package/package.json +36 -29
- package/dist/chunks/git.Bm2pzPAa.js +0 -71
- package/dist/chunks/index.CEzQDJGb.js +0 -231
package/dist/workers/threads.js
CHANGED
|
@@ -1,43 +1,44 @@
|
|
|
1
|
-
import { s as setupBaseEnvironment, r as runBaseTests } from '../chunks/base.
|
|
2
|
-
import { w as workerInit } from '../chunks/init-threads
|
|
1
|
+
import { s as setupBaseEnvironment, r as runBaseTests } from '../chunks/base.BPik1OqN.js';
|
|
2
|
+
import { w as workerInit } from '../chunks/init-threads.D3eCsY76.js';
|
|
3
3
|
import 'node:vm';
|
|
4
4
|
import '@vitest/spy';
|
|
5
|
-
import '../chunks/index.
|
|
5
|
+
import '../chunks/index.nZ2xqFgD.js';
|
|
6
6
|
import '@vitest/expect';
|
|
7
7
|
import 'node:async_hooks';
|
|
8
|
-
import '../chunks/setup-common.
|
|
9
|
-
import '../chunks/coverage.
|
|
8
|
+
import '../chunks/setup-common.2wZXQUjS.js';
|
|
9
|
+
import '../chunks/coverage.CTzCuANN.js';
|
|
10
10
|
import '@vitest/snapshot';
|
|
11
11
|
import '@vitest/utils/timers';
|
|
12
12
|
import '../chunks/utils.BX5Fg8C4.js';
|
|
13
13
|
import '../chunks/rpc.MzXet3jl.js';
|
|
14
14
|
import '../chunks/index.Chj8NDwU.js';
|
|
15
|
-
import '../chunks/test.
|
|
15
|
+
import '../chunks/test.p_J6dB8a.js';
|
|
16
16
|
import '@vitest/runner';
|
|
17
17
|
import '@vitest/utils/helpers';
|
|
18
|
-
import '../chunks/benchmark.
|
|
18
|
+
import '../chunks/benchmark.CX_oY03V.js';
|
|
19
19
|
import '@vitest/runner/utils';
|
|
20
20
|
import '@vitest/utils/error';
|
|
21
21
|
import 'pathe';
|
|
22
22
|
import '@vitest/utils/offset';
|
|
23
23
|
import '@vitest/utils/source-map';
|
|
24
24
|
import '../chunks/_commonjsHelpers.D26ty3Ew.js';
|
|
25
|
-
import '../chunks/init.
|
|
25
|
+
import '../chunks/init.D98-gwRW.js';
|
|
26
26
|
import 'node:fs';
|
|
27
27
|
import 'node:module';
|
|
28
28
|
import 'node:url';
|
|
29
29
|
import 'vite/module-runner';
|
|
30
|
-
import '../chunks/startVitestModuleRunner.
|
|
30
|
+
import '../chunks/startVitestModuleRunner.bRl2_oI_.js';
|
|
31
31
|
import '../chunks/modules.BJuCwlRJ.js';
|
|
32
32
|
import '../path.js';
|
|
33
33
|
import 'node:path';
|
|
34
34
|
import '../module-evaluator.js';
|
|
35
|
-
import '../chunks/traces.
|
|
35
|
+
import '../chunks/traces.DT5aQ62U.js';
|
|
36
36
|
import '@vitest/mocker';
|
|
37
37
|
import '@vitest/mocker/redirect';
|
|
38
|
-
import '../chunks/index.
|
|
38
|
+
import '../chunks/index.DC7d2Pf8.js';
|
|
39
39
|
import 'node:console';
|
|
40
40
|
import '@vitest/utils/serialize';
|
|
41
|
+
import 'tinyrainbow';
|
|
41
42
|
import '../chunks/inspector.CvyFGlXm.js';
|
|
42
43
|
import '../chunks/evaluatedModules.Dg1zASAC.js';
|
|
43
44
|
import '../chunks/nativeModuleRunner.BIakptoF.js';
|
|
@@ -51,7 +52,7 @@ import 'node:perf_hooks';
|
|
|
51
52
|
import 'node:timers';
|
|
52
53
|
import 'node:timers/promises';
|
|
53
54
|
import '@vitest/utils/constants';
|
|
54
|
-
import '../chunks/index.
|
|
55
|
+
import '../chunks/index.DOa3dzoN.js';
|
|
55
56
|
import 'expect-type';
|
|
56
57
|
import 'node:worker_threads';
|
|
57
58
|
|
package/dist/workers/vmForks.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { w as workerInit } from '../chunks/init-forks.
|
|
2
|
-
import { r as runVmTests, s as setupVmWorker } from '../chunks/vm.
|
|
3
|
-
import '../chunks/init.
|
|
1
|
+
import { w as workerInit } from '../chunks/init-forks.UV3ZQGQH.js';
|
|
2
|
+
import { r as runVmTests, s as setupVmWorker } from '../chunks/vm.BvVhnZPV.js';
|
|
3
|
+
import '../chunks/init.D98-gwRW.js';
|
|
4
4
|
import 'node:fs';
|
|
5
5
|
import 'node:module';
|
|
6
6
|
import 'node:url';
|
|
7
7
|
import 'pathe';
|
|
8
8
|
import 'vite/module-runner';
|
|
9
|
-
import '../chunks/startVitestModuleRunner.
|
|
9
|
+
import '../chunks/startVitestModuleRunner.bRl2_oI_.js';
|
|
10
10
|
import '@vitest/utils/helpers';
|
|
11
11
|
import '../chunks/modules.BJuCwlRJ.js';
|
|
12
12
|
import '../chunks/utils.BX5Fg8C4.js';
|
|
@@ -15,13 +15,14 @@ import '../path.js';
|
|
|
15
15
|
import 'node:path';
|
|
16
16
|
import '../module-evaluator.js';
|
|
17
17
|
import 'node:vm';
|
|
18
|
-
import '../chunks/traces.
|
|
18
|
+
import '../chunks/traces.DT5aQ62U.js';
|
|
19
19
|
import '@vitest/mocker';
|
|
20
20
|
import '@vitest/mocker/redirect';
|
|
21
|
-
import '../chunks/index.
|
|
21
|
+
import '../chunks/index.DC7d2Pf8.js';
|
|
22
22
|
import 'node:console';
|
|
23
23
|
import '@vitest/utils/serialize';
|
|
24
24
|
import '@vitest/utils/error';
|
|
25
|
+
import 'tinyrainbow';
|
|
25
26
|
import '../chunks/rpc.MzXet3jl.js';
|
|
26
27
|
import '../chunks/index.Chj8NDwU.js';
|
|
27
28
|
import '@vitest/utils/source-map';
|
|
@@ -29,7 +30,6 @@ import '../chunks/inspector.CvyFGlXm.js';
|
|
|
29
30
|
import '../chunks/evaluatedModules.Dg1zASAC.js';
|
|
30
31
|
import '../chunks/console.3WNpx0tS.js';
|
|
31
32
|
import 'node:stream';
|
|
32
|
-
import 'tinyrainbow';
|
|
33
33
|
import '@vitest/utils/resolver';
|
|
34
34
|
import '@vitest/utils/constants';
|
|
35
35
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { w as workerInit } from '../chunks/init-threads
|
|
2
|
-
import { s as setupVmWorker, r as runVmTests } from '../chunks/vm.
|
|
1
|
+
import { w as workerInit } from '../chunks/init-threads.D3eCsY76.js';
|
|
2
|
+
import { s as setupVmWorker, r as runVmTests } from '../chunks/vm.BvVhnZPV.js';
|
|
3
3
|
import 'node:worker_threads';
|
|
4
|
-
import '../chunks/init.
|
|
4
|
+
import '../chunks/init.D98-gwRW.js';
|
|
5
5
|
import 'node:fs';
|
|
6
6
|
import 'node:module';
|
|
7
7
|
import 'node:url';
|
|
8
8
|
import 'pathe';
|
|
9
9
|
import 'vite/module-runner';
|
|
10
|
-
import '../chunks/startVitestModuleRunner.
|
|
10
|
+
import '../chunks/startVitestModuleRunner.bRl2_oI_.js';
|
|
11
11
|
import '@vitest/utils/helpers';
|
|
12
12
|
import '../chunks/modules.BJuCwlRJ.js';
|
|
13
13
|
import '../chunks/utils.BX5Fg8C4.js';
|
|
@@ -16,13 +16,14 @@ import '../path.js';
|
|
|
16
16
|
import 'node:path';
|
|
17
17
|
import '../module-evaluator.js';
|
|
18
18
|
import 'node:vm';
|
|
19
|
-
import '../chunks/traces.
|
|
19
|
+
import '../chunks/traces.DT5aQ62U.js';
|
|
20
20
|
import '@vitest/mocker';
|
|
21
21
|
import '@vitest/mocker/redirect';
|
|
22
|
-
import '../chunks/index.
|
|
22
|
+
import '../chunks/index.DC7d2Pf8.js';
|
|
23
23
|
import 'node:console';
|
|
24
24
|
import '@vitest/utils/serialize';
|
|
25
25
|
import '@vitest/utils/error';
|
|
26
|
+
import 'tinyrainbow';
|
|
26
27
|
import '../chunks/rpc.MzXet3jl.js';
|
|
27
28
|
import '../chunks/index.Chj8NDwU.js';
|
|
28
29
|
import '@vitest/utils/source-map';
|
|
@@ -30,7 +31,6 @@ import '../chunks/inspector.CvyFGlXm.js';
|
|
|
30
31
|
import '../chunks/evaluatedModules.Dg1zASAC.js';
|
|
31
32
|
import '../chunks/console.3WNpx0tS.js';
|
|
32
33
|
import 'node:stream';
|
|
33
|
-
import 'tinyrainbow';
|
|
34
34
|
import '@vitest/utils/resolver';
|
|
35
35
|
import '@vitest/utils/constants';
|
|
36
36
|
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depup/vitest",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.1.
|
|
5
|
-
"description": "
|
|
4
|
+
"version": "4.1.2-depup.0",
|
|
5
|
+
"description": "Next generation testing framework powered by Vite (with updated dependencies)",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -16,10 +16,12 @@
|
|
|
16
16
|
"url": "https://github.com/vitest-dev/vitest/issues"
|
|
17
17
|
},
|
|
18
18
|
"keywords": [
|
|
19
|
-
"depup",
|
|
20
|
-
"dependency-bumped",
|
|
21
|
-
"updated-deps",
|
|
22
19
|
"vitest",
|
|
20
|
+
"depup",
|
|
21
|
+
"updated-dependencies",
|
|
22
|
+
"security",
|
|
23
|
+
"latest",
|
|
24
|
+
"patched",
|
|
23
25
|
"vite",
|
|
24
26
|
"test",
|
|
25
27
|
"jest"
|
|
@@ -51,6 +53,9 @@
|
|
|
51
53
|
"./optional-types.js": {
|
|
52
54
|
"types": "./optional-types.d.ts"
|
|
53
55
|
},
|
|
56
|
+
"./optional-runtime-types.js": {
|
|
57
|
+
"types": "./optional-runtime-types.d.ts"
|
|
58
|
+
},
|
|
54
59
|
"./src/*": "./src/*",
|
|
55
60
|
"./globals": {
|
|
56
61
|
"types": "./globals.d.ts"
|
|
@@ -123,7 +128,9 @@
|
|
|
123
128
|
"*.mjs",
|
|
124
129
|
"bin",
|
|
125
130
|
"browser",
|
|
126
|
-
"dist"
|
|
131
|
+
"dist",
|
|
132
|
+
"changes.json",
|
|
133
|
+
"README.md"
|
|
127
134
|
],
|
|
128
135
|
"engines": {
|
|
129
136
|
"node": "^20.0.0 || ^22.0.0 || >=24.0.0"
|
|
@@ -134,11 +141,11 @@
|
|
|
134
141
|
"@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0",
|
|
135
142
|
"happy-dom": "*",
|
|
136
143
|
"jsdom": "*",
|
|
137
|
-
"vite": "^6.0.0 || ^7.0.0 || ^8.0.0
|
|
138
|
-
"@vitest/browser-playwright": "4.1.
|
|
139
|
-
"@vitest/
|
|
140
|
-
"@vitest/browser-preview": "4.1.
|
|
141
|
-
"@vitest/
|
|
144
|
+
"vite": "^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
145
|
+
"@vitest/browser-playwright": "4.1.2",
|
|
146
|
+
"@vitest/ui": "4.1.2",
|
|
147
|
+
"@vitest/browser-preview": "4.1.2",
|
|
148
|
+
"@vitest/browser-webdriverio": "4.1.2"
|
|
142
149
|
},
|
|
143
150
|
"peerDependenciesMeta": {
|
|
144
151
|
"@edge-runtime/vm": {
|
|
@@ -178,21 +185,21 @@
|
|
|
178
185
|
"magic-string": "^0.30.21",
|
|
179
186
|
"obug": "^2.1.1",
|
|
180
187
|
"pathe": "^2.0.3",
|
|
181
|
-
"picomatch": "^4.0.
|
|
188
|
+
"picomatch": "^4.0.4",
|
|
182
189
|
"std-env": "^4.0.0-rc.1",
|
|
183
190
|
"tinybench": "^6.0.0",
|
|
184
191
|
"tinyexec": "^1.0.4",
|
|
185
192
|
"tinyglobby": "^0.2.15",
|
|
186
193
|
"tinyrainbow": "^3.1.0",
|
|
187
|
-
"vite": "^8.0.
|
|
194
|
+
"vite": "^8.0.3",
|
|
188
195
|
"why-is-node-running": "^3.2.2",
|
|
189
|
-
"@vitest/
|
|
190
|
-
"@vitest/
|
|
191
|
-
"@vitest/runner": "4.1.
|
|
192
|
-
"@vitest/
|
|
193
|
-
"@vitest/
|
|
194
|
-
"@vitest/spy": "4.1.
|
|
195
|
-
"@vitest/utils": "4.1.
|
|
196
|
+
"@vitest/mocker": "4.1.2",
|
|
197
|
+
"@vitest/pretty-format": "4.1.2",
|
|
198
|
+
"@vitest/runner": "4.1.2",
|
|
199
|
+
"@vitest/expect": "4.1.2",
|
|
200
|
+
"@vitest/snapshot": "4.1.2",
|
|
201
|
+
"@vitest/spy": "4.1.2",
|
|
202
|
+
"@vitest/utils": "4.1.2"
|
|
196
203
|
},
|
|
197
204
|
"devDependencies": {
|
|
198
205
|
"@antfu/install-pkg": "^1.1.0",
|
|
@@ -214,7 +221,7 @@
|
|
|
214
221
|
"birpc": "^4.0.0",
|
|
215
222
|
"cac": "^6.7.14",
|
|
216
223
|
"empathic": "^2.0.0",
|
|
217
|
-
"flatted": "3.4.
|
|
224
|
+
"flatted": "^3.4.2",
|
|
218
225
|
"happy-dom": "^20.8.3",
|
|
219
226
|
"jsdom": "^27.4.0",
|
|
220
227
|
"local-pkg": "^1.1.2",
|
|
@@ -230,6 +237,10 @@
|
|
|
230
237
|
},
|
|
231
238
|
"depup": {
|
|
232
239
|
"changes": {
|
|
240
|
+
"picomatch": {
|
|
241
|
+
"from": "^4.0.3",
|
|
242
|
+
"to": "^4.0.4"
|
|
243
|
+
},
|
|
233
244
|
"tinybench": {
|
|
234
245
|
"from": "^2.9.0",
|
|
235
246
|
"to": "^6.0.0"
|
|
@@ -238,13 +249,9 @@
|
|
|
238
249
|
"from": "^1.0.2",
|
|
239
250
|
"to": "^1.0.4"
|
|
240
251
|
},
|
|
241
|
-
"tinyrainbow": {
|
|
242
|
-
"from": "^3.0.3",
|
|
243
|
-
"to": "^3.1.0"
|
|
244
|
-
},
|
|
245
252
|
"vite": {
|
|
246
|
-
"from": "^6.0.0 || ^7.0.0 || ^8.0.0
|
|
247
|
-
"to": "^8.0.
|
|
253
|
+
"from": "^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
254
|
+
"to": "^8.0.3"
|
|
248
255
|
},
|
|
249
256
|
"why-is-node-running": {
|
|
250
257
|
"from": "^2.3.0",
|
|
@@ -253,8 +260,8 @@
|
|
|
253
260
|
},
|
|
254
261
|
"depsUpdated": 5,
|
|
255
262
|
"originalPackage": "vitest",
|
|
256
|
-
"originalVersion": "4.1.
|
|
257
|
-
"processedAt": "2026-03-
|
|
263
|
+
"originalVersion": "4.1.2",
|
|
264
|
+
"processedAt": "2026-03-26T16:32:12.362Z",
|
|
258
265
|
"smokeTest": "passed"
|
|
259
266
|
}
|
|
260
267
|
}
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { resolve } from 'pathe';
|
|
2
|
-
import { x } from 'tinyexec';
|
|
3
|
-
|
|
4
|
-
class VitestGit {
|
|
5
|
-
root;
|
|
6
|
-
constructor(cwd) {
|
|
7
|
-
this.cwd = cwd;
|
|
8
|
-
}
|
|
9
|
-
async resolveFilesWithGitCommand(args) {
|
|
10
|
-
let result;
|
|
11
|
-
try {
|
|
12
|
-
result = await x("git", args, { nodeOptions: { cwd: this.root } });
|
|
13
|
-
} catch (e) {
|
|
14
|
-
e.message = e.stderr;
|
|
15
|
-
throw e;
|
|
16
|
-
}
|
|
17
|
-
return result.stdout.split("\n").filter((s) => s !== "").map((changedPath) => resolve(this.root, changedPath));
|
|
18
|
-
}
|
|
19
|
-
async findChangedFiles(options) {
|
|
20
|
-
const root = await this.getRoot(this.cwd);
|
|
21
|
-
if (!root) return null;
|
|
22
|
-
this.root = root;
|
|
23
|
-
const changedSince = options.changedSince;
|
|
24
|
-
if (typeof changedSince === "string") {
|
|
25
|
-
const [committed, staged, unstaged] = await Promise.all([
|
|
26
|
-
this.getFilesSince(changedSince),
|
|
27
|
-
this.getStagedFiles(),
|
|
28
|
-
this.getUnstagedFiles()
|
|
29
|
-
]);
|
|
30
|
-
return [
|
|
31
|
-
...committed,
|
|
32
|
-
...staged,
|
|
33
|
-
...unstaged
|
|
34
|
-
];
|
|
35
|
-
}
|
|
36
|
-
const [staged, unstaged] = await Promise.all([this.getStagedFiles(), this.getUnstagedFiles()]);
|
|
37
|
-
return [...staged, ...unstaged];
|
|
38
|
-
}
|
|
39
|
-
getFilesSince(hash) {
|
|
40
|
-
return this.resolveFilesWithGitCommand([
|
|
41
|
-
"diff",
|
|
42
|
-
"--name-only",
|
|
43
|
-
`${hash}...HEAD`
|
|
44
|
-
]);
|
|
45
|
-
}
|
|
46
|
-
getStagedFiles() {
|
|
47
|
-
return this.resolveFilesWithGitCommand([
|
|
48
|
-
"diff",
|
|
49
|
-
"--cached",
|
|
50
|
-
"--name-only"
|
|
51
|
-
]);
|
|
52
|
-
}
|
|
53
|
-
getUnstagedFiles() {
|
|
54
|
-
return this.resolveFilesWithGitCommand([
|
|
55
|
-
"ls-files",
|
|
56
|
-
"--other",
|
|
57
|
-
"--modified",
|
|
58
|
-
"--exclude-standard"
|
|
59
|
-
]);
|
|
60
|
-
}
|
|
61
|
-
async getRoot(cwd) {
|
|
62
|
-
const args = ["rev-parse", "--show-cdup"];
|
|
63
|
-
try {
|
|
64
|
-
return resolve(cwd, (await x("git", args, { nodeOptions: { cwd } })).stdout.trim());
|
|
65
|
-
} catch {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export { VitestGit };
|
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import { getTasks, getFullName, getTests } from '@vitest/runner/utils';
|
|
3
|
-
import * as pathe from 'pathe';
|
|
4
|
-
import c from 'tinyrainbow';
|
|
5
|
-
import { g as getStateSymbol, t as truncateString, F as F_RIGHT, D as DefaultReporter, f as formatProjectName, s as separator } from './index.DXMFO5MJ.js';
|
|
6
|
-
import { stripVTControlCharacters } from 'node:util';
|
|
7
|
-
import { notNullish } from '@vitest/utils/helpers';
|
|
8
|
-
|
|
9
|
-
function createBenchmarkJsonReport(files) {
|
|
10
|
-
const report = { files: [] };
|
|
11
|
-
for (const file of files) {
|
|
12
|
-
const groups = [];
|
|
13
|
-
for (const task of getTasks(file)) if (task?.type === "suite") {
|
|
14
|
-
const benchmarks = [];
|
|
15
|
-
for (const t of task.tasks) {
|
|
16
|
-
const benchmark = t.meta.benchmark && t.result?.benchmark;
|
|
17
|
-
if (benchmark) benchmarks.push({
|
|
18
|
-
id: t.id,
|
|
19
|
-
...benchmark,
|
|
20
|
-
samples: []
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
if (benchmarks.length) groups.push({
|
|
24
|
-
fullName: getFullName(task, " > "),
|
|
25
|
-
benchmarks
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
report.files.push({
|
|
29
|
-
filepath: file.filepath,
|
|
30
|
-
groups
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
return report;
|
|
34
|
-
}
|
|
35
|
-
function flattenFormattedBenchmarkReport(report) {
|
|
36
|
-
const flat = {};
|
|
37
|
-
for (const file of report.files) for (const group of file.groups) for (const t of group.benchmarks) flat[t.id] = t;
|
|
38
|
-
return flat;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const outputMap = /* @__PURE__ */ new WeakMap();
|
|
42
|
-
function formatNumber(number) {
|
|
43
|
-
const res = String(number.toFixed(number < 100 ? 4 : 2)).split(".");
|
|
44
|
-
return res[0].replace(/(?=(?:\d{3})+$)\B/g, ",") + (res[1] ? `.${res[1]}` : "");
|
|
45
|
-
}
|
|
46
|
-
const tableHead = [
|
|
47
|
-
"name",
|
|
48
|
-
"hz",
|
|
49
|
-
"min",
|
|
50
|
-
"max",
|
|
51
|
-
"mean",
|
|
52
|
-
"p75",
|
|
53
|
-
"p99",
|
|
54
|
-
"p995",
|
|
55
|
-
"p999",
|
|
56
|
-
"rme",
|
|
57
|
-
"samples"
|
|
58
|
-
];
|
|
59
|
-
function renderBenchmarkItems(result) {
|
|
60
|
-
return [
|
|
61
|
-
result.name,
|
|
62
|
-
formatNumber(result.hz || 0),
|
|
63
|
-
formatNumber(result.min || 0),
|
|
64
|
-
formatNumber(result.max || 0),
|
|
65
|
-
formatNumber(result.mean || 0),
|
|
66
|
-
formatNumber(result.p75 || 0),
|
|
67
|
-
formatNumber(result.p99 || 0),
|
|
68
|
-
formatNumber(result.p995 || 0),
|
|
69
|
-
formatNumber(result.p999 || 0),
|
|
70
|
-
`±${(result.rme || 0).toFixed(2)}%`,
|
|
71
|
-
(result.sampleCount || 0).toString()
|
|
72
|
-
];
|
|
73
|
-
}
|
|
74
|
-
function computeColumnWidths(results) {
|
|
75
|
-
const rows = [tableHead, ...results.map((v) => renderBenchmarkItems(v))];
|
|
76
|
-
return Array.from(tableHead, (_, i) => Math.max(...rows.map((row) => stripVTControlCharacters(row[i]).length)));
|
|
77
|
-
}
|
|
78
|
-
function padRow(row, widths) {
|
|
79
|
-
return row.map((v, i) => i ? v.padStart(widths[i], " ") : v.padEnd(widths[i], " "));
|
|
80
|
-
}
|
|
81
|
-
function renderTableHead(widths) {
|
|
82
|
-
return " ".repeat(3) + padRow(tableHead, widths).map(c.bold).join(" ");
|
|
83
|
-
}
|
|
84
|
-
function renderBenchmark(result, widths) {
|
|
85
|
-
const padded = padRow(renderBenchmarkItems(result), widths);
|
|
86
|
-
return [
|
|
87
|
-
padded[0],
|
|
88
|
-
c.blue(padded[1]),
|
|
89
|
-
c.cyan(padded[2]),
|
|
90
|
-
c.cyan(padded[3]),
|
|
91
|
-
c.cyan(padded[4]),
|
|
92
|
-
c.cyan(padded[5]),
|
|
93
|
-
c.cyan(padded[6]),
|
|
94
|
-
c.cyan(padded[7]),
|
|
95
|
-
c.cyan(padded[8]),
|
|
96
|
-
c.dim(padded[9]),
|
|
97
|
-
c.dim(padded[10])
|
|
98
|
-
].join(" ");
|
|
99
|
-
}
|
|
100
|
-
function renderTable(options) {
|
|
101
|
-
const output = [];
|
|
102
|
-
const benchMap = {};
|
|
103
|
-
for (const task of options.tasks) if (task.meta.benchmark && task.result?.benchmark) benchMap[task.id] = {
|
|
104
|
-
current: task.result.benchmark,
|
|
105
|
-
baseline: options.compare?.[task.id]
|
|
106
|
-
};
|
|
107
|
-
const benchCount = Object.entries(benchMap).length;
|
|
108
|
-
const columnWidths = computeColumnWidths(Object.values(benchMap).flatMap((v) => [v.current, v.baseline]).filter(notNullish));
|
|
109
|
-
let idx = 0;
|
|
110
|
-
const padding = " ".repeat(1 );
|
|
111
|
-
for (const task of options.tasks) {
|
|
112
|
-
const duration = task.result?.duration;
|
|
113
|
-
const bench = benchMap[task.id];
|
|
114
|
-
let prefix = "";
|
|
115
|
-
if (idx === 0 && task.meta?.benchmark) prefix += `${renderTableHead(columnWidths)}\n${padding}`;
|
|
116
|
-
prefix += ` ${getStateSymbol(task)} `;
|
|
117
|
-
let suffix = "";
|
|
118
|
-
if (task.type === "suite") suffix += c.dim(` (${getTests(task).length})`);
|
|
119
|
-
if (task.mode === "skip" || task.mode === "todo") suffix += c.dim(c.gray(" [skipped]"));
|
|
120
|
-
if (duration != null) {
|
|
121
|
-
const color = duration > options.slowTestThreshold ? c.yellow : c.green;
|
|
122
|
-
suffix += color(` ${Math.round(duration)}${c.dim("ms")}`);
|
|
123
|
-
}
|
|
124
|
-
if (options.showHeap && task.result?.heap != null) suffix += c.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
|
|
125
|
-
if (bench) {
|
|
126
|
-
let body = renderBenchmark(bench.current, columnWidths);
|
|
127
|
-
if (options.compare && bench.baseline) {
|
|
128
|
-
if (bench.current.hz) {
|
|
129
|
-
const diff = bench.current.hz / bench.baseline.hz;
|
|
130
|
-
const diffFixed = diff.toFixed(2);
|
|
131
|
-
if (diffFixed === "1.0.0") body += c.gray(` [${diffFixed}x]`);
|
|
132
|
-
if (diff > 1) body += c.blue(` [${diffFixed}x] ⇑`);
|
|
133
|
-
else body += c.red(` [${diffFixed}x] ⇓`);
|
|
134
|
-
}
|
|
135
|
-
output.push(padding + prefix + body + suffix);
|
|
136
|
-
const bodyBaseline = renderBenchmark(bench.baseline, columnWidths);
|
|
137
|
-
output.push(`${padding} ${bodyBaseline} ${c.dim("(baseline)")}`);
|
|
138
|
-
} else {
|
|
139
|
-
if (bench.current.rank === 1 && benchCount > 1) body += c.bold(c.green(" fastest"));
|
|
140
|
-
if (bench.current.rank === benchCount && benchCount > 2) body += c.bold(c.gray(" slowest"));
|
|
141
|
-
output.push(padding + prefix + body + suffix);
|
|
142
|
-
}
|
|
143
|
-
} else output.push(padding + prefix + task.name + suffix);
|
|
144
|
-
if (task.result?.state !== "pass" && outputMap.get(task) != null) {
|
|
145
|
-
let data = outputMap.get(task);
|
|
146
|
-
if (typeof data === "string") {
|
|
147
|
-
data = stripVTControlCharacters(data.trim().split("\n").filter(Boolean).pop());
|
|
148
|
-
if (data === "") data = void 0;
|
|
149
|
-
}
|
|
150
|
-
if (data != null) {
|
|
151
|
-
const out = ` ${" ".repeat(options.level)}${F_RIGHT} ${data}`;
|
|
152
|
-
output.push(c.gray(truncateString(out, options.columns)));
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
idx++;
|
|
156
|
-
}
|
|
157
|
-
return output.filter(Boolean).join("\n");
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
class BenchmarkReporter extends DefaultReporter {
|
|
161
|
-
compare;
|
|
162
|
-
async onInit(ctx) {
|
|
163
|
-
super.onInit(ctx);
|
|
164
|
-
if (this.ctx.config.benchmark?.compare) {
|
|
165
|
-
const compareFile = pathe.resolve(this.ctx.config.root, this.ctx.config.benchmark?.compare);
|
|
166
|
-
try {
|
|
167
|
-
this.compare = flattenFormattedBenchmarkReport(JSON.parse(await fs.promises.readFile(compareFile, "utf-8")));
|
|
168
|
-
} catch (e) {
|
|
169
|
-
this.error(`Failed to read '${compareFile}'`, e);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
onTaskUpdate(packs) {
|
|
174
|
-
for (const pack of packs) {
|
|
175
|
-
const task = this.ctx.state.idMap.get(pack[0]);
|
|
176
|
-
if (task?.type === "suite" && task.result?.state !== "run") task.tasks.filter((task) => task.result?.benchmark).sort((benchA, benchB) => benchA.result.benchmark.mean - benchB.result.benchmark.mean).forEach((bench, idx) => {
|
|
177
|
-
bench.result.benchmark.rank = Number(idx) + 1;
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
onTestSuiteResult(testSuite) {
|
|
182
|
-
super.onTestSuiteResult(testSuite);
|
|
183
|
-
this.printSuiteTable(testSuite);
|
|
184
|
-
}
|
|
185
|
-
printTestModule(testModule) {
|
|
186
|
-
this.printSuiteTable(testModule);
|
|
187
|
-
}
|
|
188
|
-
printSuiteTable(testTask) {
|
|
189
|
-
const state = testTask.state();
|
|
190
|
-
if (state === "pending" || state === "queued") return;
|
|
191
|
-
const benches = testTask.task.tasks.filter((t) => t.meta.benchmark);
|
|
192
|
-
const duration = testTask.task.result?.duration || 0;
|
|
193
|
-
if (benches.length > 0 && benches.every((t) => t.result?.state !== "run" && t.result?.state !== "queued")) {
|
|
194
|
-
let title = `\n ${getStateSymbol(testTask.task)} ${formatProjectName(testTask.project)}${getFullName(testTask.task, separator)}`;
|
|
195
|
-
if (duration != null && duration > this.ctx.config.slowTestThreshold) title += c.yellow(` ${Math.round(duration)}${c.dim("ms")}`);
|
|
196
|
-
this.log(title);
|
|
197
|
-
this.log(renderTable({
|
|
198
|
-
tasks: benches,
|
|
199
|
-
level: 1,
|
|
200
|
-
columns: this.ctx.logger.getColumns(),
|
|
201
|
-
compare: this.compare,
|
|
202
|
-
showHeap: this.ctx.config.logHeapUsage,
|
|
203
|
-
slowTestThreshold: this.ctx.config.slowTestThreshold
|
|
204
|
-
}));
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
async onTestRunEnd(testModules, unhandledErrors, reason) {
|
|
208
|
-
super.onTestRunEnd(testModules, unhandledErrors, reason);
|
|
209
|
-
// write output for future comparison
|
|
210
|
-
let outputFile = this.ctx.config.benchmark?.outputJson;
|
|
211
|
-
if (outputFile) {
|
|
212
|
-
outputFile = pathe.resolve(this.ctx.config.root, outputFile);
|
|
213
|
-
const outputDirectory = pathe.dirname(outputFile);
|
|
214
|
-
if (!fs.existsSync(outputDirectory)) await fs.promises.mkdir(outputDirectory, { recursive: true });
|
|
215
|
-
const output = createBenchmarkJsonReport(testModules.map((t) => t.task.file));
|
|
216
|
-
await fs.promises.writeFile(outputFile, JSON.stringify(output, null, 2));
|
|
217
|
-
this.log(`Benchmark report written to ${outputFile}`);
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
class VerboseBenchmarkReporter extends BenchmarkReporter {
|
|
223
|
-
verbose = true;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
const BenchmarkReportsMap = {
|
|
227
|
-
default: BenchmarkReporter,
|
|
228
|
-
verbose: VerboseBenchmarkReporter
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
export { BenchmarkReporter as B, VerboseBenchmarkReporter as V, BenchmarkReportsMap as a };
|