vitest 5.1.0 → 5.1.2
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/dist/browser.d.ts +6 -5
- package/dist/browser.js +7 -7
- package/dist/chunks/{base.Cof-UHJf.js → base.DCg6Jh4N.js} +12 -12
- package/dist/chunks/{browser.d.C7tWgUvw.d.ts → browser.d.B-QwH_F6.d.ts} +3 -3
- package/dist/chunks/{cac.BYbt0aJp.js → cac.DnNTZKhD.js} +15 -10
- package/dist/chunks/{cli-api.COfZo8lK.js → cli-api.9v9AxcPO.js} +444 -161
- package/dist/chunks/{config.d.B3YV4t0O.d.ts → config.d.BpJq6tRA.d.ts} +7 -1
- package/dist/chunks/{console.CQZ877Hi.js → console.DdxlsSsm.js} +4 -4
- package/dist/chunks/{creator.DHWmytIK.js → creator.B-BIoERb.js} +13 -11
- package/dist/chunks/{display.BlTmubjj.js → display.Cj2h2zsY.js} +1 -1
- package/dist/chunks/{doctor.B-oPbwps.js → doctor.DBFXC86z.js} +1 -1
- package/dist/chunks/{environment.d.BFQtFKdZ.d.ts → environment.d.rlpAM-ON.d.ts} +1 -1
- package/dist/chunks/{globals.ZKtKSkEf.js → globals.Cz5RAf6U.js} +10 -10
- package/dist/chunks/{index.Di8au7q4.js → index.6pLw0FLK.js} +220 -91
- package/dist/chunks/{index.w_oBZ9N8.js → index.BSqmIH9v.js} +3 -3
- package/dist/chunks/{index.Bi0NXYPf.js → index.C7Nn66Gy.js} +21 -9
- package/dist/chunks/{index.DmDMHCg8.js → index.CAmut2NG.js} +25 -1
- package/dist/chunks/{index.CZzC1gGg.js → index.D5jWOaqm.js} +35 -22
- package/dist/chunks/{index.D0heQG4v.js → index.Or9psEGe.js} +1 -1
- package/dist/chunks/{init-forks.BaDXQSD8.js → init-forks.q4IoGYZe.js} +7 -1
- package/dist/chunks/{init-threads.ZX_Vov0z.js → init-threads.Bf1Frg9S.js} +1 -1
- package/dist/chunks/{init.CO4AB7HZ.js → init.dGO4K2C0.js} +16 -8
- package/dist/chunks/{inspector.CvyFGlXm.js → inspector.D6o1NPo1.js} +12 -1
- package/dist/chunks/{modules.BJuCwlRJ.js → moduleSourceMap.Dp1WduWi.js} +31 -1
- package/dist/chunks/{native.upB-V0CK.js → native.D5q1ylZC.js} +2 -1
- package/dist/chunks/{nativeModuleMocker.Dh5azSB4.js → nativeModuleMocker.ihb3q7Cg.js} +4 -2
- package/dist/chunks/{plugin.d.LRFSN46m.d.ts → plugin.d.Bx2wJglX.d.ts} +58 -75
- package/dist/chunks/{plugins.DPQHVT0p.js → plugins.BPruPOR8.js} +1 -1
- package/dist/chunks/{rawSnapshot.DqSiqIEx.js → rawSnapshot.DvoRLRNr.js} +2 -2
- package/dist/chunks/{rpc.Uhkwr2NM.js → rpc.CNYWPa97.js} +3 -19
- package/dist/chunks/{rpc.d.3FOhdFx8.d.ts → rpc.d.DHfuwqP0.d.ts} +2 -2
- package/dist/chunks/{run.CjdgFZiW.js → run.zBhXlcZQ.js} +113 -49
- package/dist/chunks/{setup-common.CqAQCXzx.js → setup-common.kEGtNVHG.js} +3 -3
- package/dist/chunks/{source-map.DakdQc29.js → source-map.DPHGMWvM.js} +3 -1
- package/dist/chunks/{source-map.d.BkG8YK_3.d.ts → source-map.d.xB6_75fl.d.ts} +2 -1
- package/dist/chunks/{spy.DDMXghXv.js → spy.BO0hTE3G.js} +76 -53
- package/dist/chunks/{task-utils.d.D-gFPNFi.d.ts → task-utils.d.DgSjIb7r.d.ts} +1 -1
- package/dist/chunks/{utils.BBk_icFG.js → utils.sAsh2ClK.js} +2 -6
- package/dist/chunks/{vm.b4MbCAJQ.js → vm.DNr3Eju_.js} +4 -4
- package/dist/chunks/{worker.d.CyJRpyfZ.d.ts → worker.d.BigfbIsH.d.ts} +3 -3
- package/dist/cli.js +1 -1
- package/dist/config.d.ts +8 -8
- package/dist/index.d.ts +10 -10
- package/dist/index.js +10 -10
- package/dist/module-evaluator.d.ts +3 -3
- package/dist/module-evaluator.js +1 -1
- package/dist/node.d.ts +11 -10
- package/dist/node.js +18 -15
- package/dist/runtime.d.ts +5 -4
- package/dist/runtime.js +5 -3
- package/dist/spy.js +1 -1
- package/dist/worker.d.ts +4 -4
- package/dist/worker.js +19 -18
- package/dist/workers/forks.js +20 -19
- package/dist/workers/runVmTests.js +14 -14
- package/dist/workers/threads.js +20 -19
- package/dist/workers/vmForks.js +14 -13
- package/dist/workers/vmThreads.js +14 -13
- package/dist/workers/watchdog.js +20 -0
- package/package.json +21 -21
- /package/dist/chunks/{index.BoyTG_B7.js → dist.BoyTG_B7.js} +0 -0
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
import * as fs from 'node:fs';
|
|
2
2
|
import fs__default, { promises, existsSync, writeFileSync, mkdirSync, readFileSync, statSync, readdirSync } from 'node:fs';
|
|
3
3
|
import { r as resolveCoverageProviderModule, g as getCoverageFilesDirectory, C as CoverageProviderMap } from './coverage.jGCktcGP.js';
|
|
4
|
-
import { o as parse, s as stringify, k as isFileServingAllowed, q as getSpecificationDocblock, t as resolveStaticMocks, u as getStaticMocks, f as createDebugger, v as
|
|
4
|
+
import { o as parse, s as stringify, k as isFileServingAllowed, q as getSpecificationDocblock, t as resolveStaticMocks, u as getStaticMocks, f as createDebugger, v as resolveCoverageReporters, w as createIndexLocationsMap, x as getOutputFile, y as groupBy, z as generateCodeFrame, A as printStack, R as RangeLocationFilterProvidedError, I as IncludeTaskLocationDisabledError, C as LocationFilterFileNotFoundError, D as GitCommandError, G as GitNotFoundError, E as VitestResolver, M as ModuleTransformService, l as resolveConfig$1, H as createClusterServer, S as ServerModuleRunner, J as attachProjectsFromEntries, K as TestProject, N as resolveAndAttachProjects, O as RandomSequencer, b as FilesNotFoundError, Q as createPool, U as astCollectTests, W as createFailedFileTask, X as matchesProjectFilter, Y as nanoid, L as Logger, V as VitestPackageInstaller, P as PluginHarness, Z as stdout, p as prompt } from './index.6pLw0FLK.js';
|
|
5
5
|
import { readFile, writeFile, rename, stat, unlink, rm, mkdir, readdir, copyFile } from 'node:fs/promises';
|
|
6
6
|
import os__default, { tmpdir, hostname } from 'node:os';
|
|
7
7
|
import { j as join, b as basename, d as dirname, i as isAbsolute, r as resolve, D as noop, e as createDefer, c as cleanUrl, a as relative, s as slash, F as sanitizeFilePath, t as toArray, x as ordinal, G as deepMerge, p as isPrimitive, k as extname, n as normalize$1, u as deepClone } from './pathe.M-eThtNZ.zq3TM4NT.js';
|
|
8
|
-
import { T as TraceMap, o as originalPositionFor, p as parseStacktrace, e as parseErrorStacktrace, b as serializeValue } from './source-map.
|
|
9
|
-
import { v as version } from './cac.
|
|
8
|
+
import { T as TraceMap, o as originalPositionFor, p as parseStacktrace, e as parseErrorStacktrace, b as serializeValue } from './source-map.DPHGMWvM.js';
|
|
9
|
+
import { v as version } from './cac.DnNTZKhD.js';
|
|
10
10
|
import { performance as performance$1 } from 'node:perf_hooks';
|
|
11
|
-
import { c as createBirpc } from './index.
|
|
12
|
-
import require$$0$
|
|
11
|
+
import { c as createBirpc } from './index.CAmut2NG.js';
|
|
12
|
+
import require$$0$4 from 'events';
|
|
13
13
|
import require$$1$1 from 'https';
|
|
14
|
-
import require$$
|
|
14
|
+
import require$$0 from 'http';
|
|
15
15
|
import require$$3 from 'net';
|
|
16
|
-
import require$$4 from '
|
|
16
|
+
import require$$4 from 'querystring';
|
|
17
|
+
import require$$5 from 'tls';
|
|
17
18
|
import require$$1 from 'crypto';
|
|
18
|
-
import require$$0$
|
|
19
|
-
import require$$
|
|
20
|
-
import require$$0 from 'zlib';
|
|
21
|
-
import require$$0$
|
|
19
|
+
import require$$0$3 from 'stream';
|
|
20
|
+
import require$$8 from 'url';
|
|
21
|
+
import require$$0$1 from 'zlib';
|
|
22
|
+
import require$$0$2 from 'buffer';
|
|
22
23
|
import require$$2 from 'util';
|
|
23
|
-
import { g as getDefaultExportFromCjs } from './index.
|
|
24
|
+
import { g as getDefaultExportFromCjs } from './index.Or9psEGe.js';
|
|
24
25
|
import { A as API_PATH, d as defaultBrowserPort } from './constants.DLYM6cZY.js';
|
|
25
|
-
import { i as isBuiltin } from './
|
|
26
|
-
import crypto, { createHash } from 'node:crypto';
|
|
26
|
+
import { i as isBuiltin, s as splitSourceMap, b as appendSourceMap } from './moduleSourceMap.Dp1WduWi.js';
|
|
27
|
+
import crypto, { hash, createHash } from 'node:crypto';
|
|
27
28
|
import { distDir } from '../path.js';
|
|
28
|
-
import {
|
|
29
|
+
import { B as limitConcurrency, C as createTagsFilter } from './run.zBhXlcZQ.js';
|
|
29
30
|
import { N as NativeModuleRunner } from './nativeModuleRunner.9xPIMzi7.js';
|
|
30
31
|
import { getTestName, hasFailed, hasFailedSnapshot, getTests, getSuites, getTasks, getFullName, createFileTask, generateFileHash, interpretTaskModes, convertTasksToEvents } from '../task-utils.js';
|
|
31
32
|
import { Traces } from '../traces.js';
|
|
32
33
|
import { $ } from './tinyrainbow.Do8I1XRG.js';
|
|
33
34
|
import { searchForWorkspaceRoot } from 'vite';
|
|
34
|
-
import { w as withLabel, F as F_TREE_NODE_MIDDLE, a as F_TREE_NODE_END, f as formatTimeString, t as taskFail, s as separator, b as F_CHECK, c as F_POINTER, d as F_DOWN_RIGHT, e as formatProjectName, g as getStateSymbol, n as noun, p as padSummaryTitle, r as renderSnapshotSummary, h as getStateString$1, i as formatTime, j as
|
|
35
|
+
import { w as withLabel, F as F_TREE_NODE_MIDDLE, a as F_TREE_NODE_END, f as formatTimeString, t as taskFail, s as separator, b as F_CHECK, c as F_POINTER, d as F_DOWN_RIGHT, e as formatProjectName, g as getStateSymbol, n as noun, p as padSummaryTitle, r as renderSnapshotSummary, h as getStateString$1, i as formatTime, j as errorBanner, k as divider, l as F_RIGHT, m as getCols } from './utils.sAsh2ClK.js';
|
|
35
36
|
import module$1 from 'node:module';
|
|
36
37
|
import path, { resolve as resolve$1, normalize } from 'node:path';
|
|
37
38
|
import { fileURLToPath } from 'node:url';
|
|
@@ -44,7 +45,7 @@ import { isCI } from 'std-env';
|
|
|
44
45
|
import assert from 'node:assert';
|
|
45
46
|
import { x, NonZeroExitError } from 'tinyexec';
|
|
46
47
|
import readline from 'node:readline';
|
|
47
|
-
import { a as saveInlineSnapshots, e as evaluateSnapshotFile, s as saveSnapshotFile, b as saveRawSnapshots } from './rawSnapshot.
|
|
48
|
+
import { a as saveInlineSnapshots, e as evaluateSnapshotFile, s as saveSnapshotFile, b as saveRawSnapshots } from './rawSnapshot.DvoRLRNr.js';
|
|
48
49
|
|
|
49
50
|
async function saveSnapshotUpdates(snapshots) {
|
|
50
51
|
const updatesByFile = /* @__PURE__ */ new Map();
|
|
@@ -168,6 +169,8 @@ function requireBufferUtil () {
|
|
|
168
169
|
if (hasRequiredBufferUtil) return bufferUtil.exports;
|
|
169
170
|
hasRequiredBufferUtil = 1;
|
|
170
171
|
|
|
172
|
+
const { websocketMask, websocketUnmask } = require$$0;
|
|
173
|
+
|
|
171
174
|
const { EMPTY_BUFFER } = requireConstants();
|
|
172
175
|
|
|
173
176
|
const FastBuffer = Buffer[Symbol.species];
|
|
@@ -279,8 +282,17 @@ function requireBufferUtil () {
|
|
|
279
282
|
unmask: _unmask
|
|
280
283
|
};
|
|
281
284
|
|
|
282
|
-
|
|
283
|
-
|
|
285
|
+
if (websocketMask) {
|
|
286
|
+
bufferUtil.exports.mask = function (source, mask, output, offset, length) {
|
|
287
|
+
if (length < 24) _mask(source, mask, output, offset, length);
|
|
288
|
+
else websocketMask(source, mask, output, offset, length);
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
bufferUtil.exports.unmask = function (buffer, mask) {
|
|
292
|
+
if (buffer.length < 24) _unmask(buffer, mask);
|
|
293
|
+
else websocketUnmask(buffer, mask);
|
|
294
|
+
};
|
|
295
|
+
} /* istanbul ignore else */ else if (!process.env.WS_NO_BUFFER_UTIL) {
|
|
284
296
|
try {
|
|
285
297
|
const bufferUtil$1 = require('bufferutil');
|
|
286
298
|
|
|
@@ -370,7 +382,7 @@ function requirePermessageDeflate () {
|
|
|
370
382
|
if (hasRequiredPermessageDeflate) return permessageDeflate;
|
|
371
383
|
hasRequiredPermessageDeflate = 1;
|
|
372
384
|
|
|
373
|
-
const zlib = require$$0;
|
|
385
|
+
const zlib = require$$0$1;
|
|
374
386
|
|
|
375
387
|
const bufferUtil = requireBufferUtil();
|
|
376
388
|
const Limiter = requireLimiter();
|
|
@@ -909,7 +921,7 @@ function requireValidation () {
|
|
|
909
921
|
if (hasRequiredValidation) return validation.exports;
|
|
910
922
|
hasRequiredValidation = 1;
|
|
911
923
|
|
|
912
|
-
const { isUtf8 } = require$$0$
|
|
924
|
+
const { isUtf8 } = require$$0$2;
|
|
913
925
|
|
|
914
926
|
const { hasBlob } = requireConstants();
|
|
915
927
|
|
|
@@ -1069,7 +1081,7 @@ function requireReceiver () {
|
|
|
1069
1081
|
if (hasRequiredReceiver) return receiver;
|
|
1070
1082
|
hasRequiredReceiver = 1;
|
|
1071
1083
|
|
|
1072
|
-
const { Writable } = require$$0$
|
|
1084
|
+
const { Writable } = require$$0$3;
|
|
1073
1085
|
|
|
1074
1086
|
const PerMessageDeflate = requirePermessageDeflate();
|
|
1075
1087
|
const {
|
|
@@ -1565,6 +1577,14 @@ function requireReceiver () {
|
|
|
1565
1577
|
}
|
|
1566
1578
|
}
|
|
1567
1579
|
|
|
1580
|
+
//
|
|
1581
|
+
// The mask is a view into the buffer the stream delivered, which is commonly
|
|
1582
|
+
// 64 KiB, and it is not needed once the payload above has been unmasked.
|
|
1583
|
+
// Leaving it set would pin that whole buffer until the next frame arrives,
|
|
1584
|
+
// which on an idle connection can be indefinitely.
|
|
1585
|
+
//
|
|
1586
|
+
this._mask = undefined;
|
|
1587
|
+
|
|
1568
1588
|
if (this._opcode > 0x07) {
|
|
1569
1589
|
this.controlMessage(data, cb);
|
|
1570
1590
|
return;
|
|
@@ -1822,7 +1842,7 @@ function requireSender () {
|
|
|
1822
1842
|
if (hasRequiredSender) return sender;
|
|
1823
1843
|
hasRequiredSender = 1;
|
|
1824
1844
|
|
|
1825
|
-
const { Duplex } = require$$0$
|
|
1845
|
+
const { Duplex } = require$$0$3;
|
|
1826
1846
|
const { randomFillSync } = require$$1;
|
|
1827
1847
|
const {
|
|
1828
1848
|
types: { isUint8Array }
|
|
@@ -1973,7 +1993,9 @@ function requireSender () {
|
|
|
1973
1993
|
target.writeUIntBE(dataLength, 4, 6);
|
|
1974
1994
|
}
|
|
1975
1995
|
|
|
1976
|
-
if (!options.mask)
|
|
1996
|
+
if (!options.mask) {
|
|
1997
|
+
return dataLength ? [target, data] : [target];
|
|
1998
|
+
}
|
|
1977
1999
|
|
|
1978
2000
|
target[1] |= 0x80;
|
|
1979
2001
|
target[offset - 4] = mask[0];
|
|
@@ -1981,6 +2003,7 @@ function requireSender () {
|
|
|
1981
2003
|
target[offset - 2] = mask[2];
|
|
1982
2004
|
target[offset - 1] = mask[3];
|
|
1983
2005
|
|
|
2006
|
+
if (!dataLength) return [target];
|
|
1984
2007
|
if (skipMasking) return [target, data];
|
|
1985
2008
|
|
|
1986
2009
|
if (merge) {
|
|
@@ -2948,14 +2971,15 @@ function requireWebsocket () {
|
|
|
2948
2971
|
if (hasRequiredWebsocket) return websocket;
|
|
2949
2972
|
hasRequiredWebsocket = 1;
|
|
2950
2973
|
|
|
2951
|
-
const EventEmitter = require$$0$
|
|
2974
|
+
const EventEmitter = require$$0$4;
|
|
2952
2975
|
const https = require$$1$1;
|
|
2953
|
-
const http = require$$
|
|
2976
|
+
const http = require$$0;
|
|
2954
2977
|
const net = require$$3;
|
|
2955
|
-
const
|
|
2978
|
+
const querystring = require$$4;
|
|
2979
|
+
const tls = require$$5;
|
|
2956
2980
|
const { randomBytes, createHash } = require$$1;
|
|
2957
|
-
const { Duplex, Readable } = require$$0$
|
|
2958
|
-
const { URL } = require$$
|
|
2981
|
+
const { Duplex, Readable } = require$$0$3;
|
|
2982
|
+
const { URL } = require$$8;
|
|
2959
2983
|
|
|
2960
2984
|
const PerMessageDeflate = requirePermessageDeflate();
|
|
2961
2985
|
const Receiver = requireReceiver();
|
|
@@ -3044,12 +3068,19 @@ function requireWebsocket () {
|
|
|
3044
3068
|
}
|
|
3045
3069
|
}
|
|
3046
3070
|
|
|
3047
|
-
initAsClient(this, address, protocols, options);
|
|
3071
|
+
options = initAsClient(this, address, protocols, options);
|
|
3048
3072
|
} else {
|
|
3049
|
-
this._autoPong = options.autoPong;
|
|
3050
|
-
this._closeTimeout = options.closeTimeout;
|
|
3051
3073
|
this._isServer = true;
|
|
3052
3074
|
}
|
|
3075
|
+
|
|
3076
|
+
if (options.autoPong) {
|
|
3077
|
+
this._autoPong = true;
|
|
3078
|
+
this._autoPongComplete = () => autoPongComplete(this);
|
|
3079
|
+
this._pendingAutoPongs = 0;
|
|
3080
|
+
this._maxPendingAutoPongs = options.maxPendingAutoPongs | 0;
|
|
3081
|
+
}
|
|
3082
|
+
|
|
3083
|
+
this._closeTimeout = options.closeTimeout;
|
|
3053
3084
|
}
|
|
3054
3085
|
|
|
3055
3086
|
/**
|
|
@@ -3611,6 +3642,8 @@ function requireWebsocket () {
|
|
|
3611
3642
|
* fragments
|
|
3612
3643
|
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
|
3613
3644
|
* size
|
|
3645
|
+
* @param {Number} [options.maxPendingAutoPongs=60] The maximum number of
|
|
3646
|
+
* pending automatic pongs
|
|
3614
3647
|
* @param {Number} [options.maxRedirects=10] The maximum number of redirects
|
|
3615
3648
|
* allowed
|
|
3616
3649
|
* @param {String} [options.origin] Value of the `Origin` or
|
|
@@ -3621,6 +3654,7 @@ function requireWebsocket () {
|
|
|
3621
3654
|
* `Sec-WebSocket-Version` header
|
|
3622
3655
|
* @param {Boolean} [options.skipUTF8Validation=false] Specifies whether or
|
|
3623
3656
|
* not to skip UTF-8 validation for text and close messages
|
|
3657
|
+
* @return {Object} The resolved options object used for initialization
|
|
3624
3658
|
* @private
|
|
3625
3659
|
*/
|
|
3626
3660
|
function initAsClient(websocket, address, protocols, options) {
|
|
@@ -3632,6 +3666,7 @@ function requireWebsocket () {
|
|
|
3632
3666
|
maxBufferedChunks: 256 * 1024,
|
|
3633
3667
|
maxFragments: 16 * 1024,
|
|
3634
3668
|
maxPayload: 100 * 1024 * 1024,
|
|
3669
|
+
maxPendingAutoPongs: 60,
|
|
3635
3670
|
skipUTF8Validation: false,
|
|
3636
3671
|
perMessageDeflate: true,
|
|
3637
3672
|
followRedirects: false,
|
|
@@ -3648,9 +3683,6 @@ function requireWebsocket () {
|
|
|
3648
3683
|
port: undefined
|
|
3649
3684
|
};
|
|
3650
3685
|
|
|
3651
|
-
websocket._autoPong = opts.autoPong;
|
|
3652
|
-
websocket._closeTimeout = opts.closeTimeout;
|
|
3653
|
-
|
|
3654
3686
|
if (!protocolVersions.includes(opts.protocolVersion)) {
|
|
3655
3687
|
throw new RangeError(
|
|
3656
3688
|
`Unsupported protocol version: ${opts.protocolVersion} ` +
|
|
@@ -3670,10 +3702,9 @@ function requireWebsocket () {
|
|
|
3670
3702
|
}
|
|
3671
3703
|
}
|
|
3672
3704
|
|
|
3673
|
-
if (parsedUrl.protocol === 'http:') {
|
|
3674
|
-
parsedUrl
|
|
3675
|
-
|
|
3676
|
-
parsedUrl.protocol = 'wss:';
|
|
3705
|
+
if (parsedUrl.protocol === 'http:' || parsedUrl.protocol === 'https:') {
|
|
3706
|
+
parsedUrl = new URL(parsedUrl);
|
|
3707
|
+
parsedUrl.protocol = parsedUrl.protocol === 'http:' ? 'ws:' : 'wss:';
|
|
3677
3708
|
}
|
|
3678
3709
|
|
|
3679
3710
|
websocket._url = parsedUrl.href;
|
|
@@ -3761,14 +3792,22 @@ function requireWebsocket () {
|
|
|
3761
3792
|
}
|
|
3762
3793
|
}
|
|
3763
3794
|
if (parsedUrl.username || parsedUrl.password) {
|
|
3764
|
-
|
|
3795
|
+
const username = querystring.unescape(parsedUrl.username);
|
|
3796
|
+
const password = querystring.unescape(parsedUrl.password);
|
|
3797
|
+
|
|
3798
|
+
opts.auth = `${username}:${password}`;
|
|
3765
3799
|
}
|
|
3766
3800
|
|
|
3767
3801
|
if (isIpcUrl) {
|
|
3768
|
-
const
|
|
3802
|
+
const i = opts.path.indexOf(':');
|
|
3769
3803
|
|
|
3770
|
-
|
|
3771
|
-
|
|
3804
|
+
if (i === -1) {
|
|
3805
|
+
opts.socketPath = opts.path;
|
|
3806
|
+
opts.path = '';
|
|
3807
|
+
} else {
|
|
3808
|
+
opts.socketPath = opts.path.slice(0, i);
|
|
3809
|
+
opts.path = opts.path.slice(i + 1);
|
|
3810
|
+
}
|
|
3772
3811
|
}
|
|
3773
3812
|
|
|
3774
3813
|
let req;
|
|
@@ -4001,6 +4040,8 @@ function requireWebsocket () {
|
|
|
4001
4040
|
} else {
|
|
4002
4041
|
req.end();
|
|
4003
4042
|
}
|
|
4043
|
+
|
|
4044
|
+
return opts;
|
|
4004
4045
|
}
|
|
4005
4046
|
|
|
4006
4047
|
/**
|
|
@@ -4129,9 +4170,20 @@ function requireWebsocket () {
|
|
|
4129
4170
|
const websocket = this[kWebSocket];
|
|
4130
4171
|
|
|
4131
4172
|
websocket._closeFrameReceived = true;
|
|
4132
|
-
websocket._closeMessage = reason;
|
|
4133
4173
|
websocket._closeCode = code;
|
|
4134
4174
|
|
|
4175
|
+
//
|
|
4176
|
+
// The reason is a view into the buffer the socket delivered. Copy it so that
|
|
4177
|
+
// the `WebSocket` does not keep that buffer alive. The copy is not pooled
|
|
4178
|
+
// because a pooled one would keep the pool alive in the same way.
|
|
4179
|
+
//
|
|
4180
|
+
if (reason.length === 0) {
|
|
4181
|
+
websocket._closeMessage = EMPTY_BUFFER;
|
|
4182
|
+
} else {
|
|
4183
|
+
websocket._closeMessage = Buffer.allocUnsafeSlow(reason.length);
|
|
4184
|
+
websocket._closeMessage.set(reason);
|
|
4185
|
+
}
|
|
4186
|
+
|
|
4135
4187
|
if (websocket._socket[kWebSocket] === undefined) return;
|
|
4136
4188
|
|
|
4137
4189
|
websocket._socket.removeListener('data', socketOnData);
|
|
@@ -4208,10 +4260,31 @@ function requireWebsocket () {
|
|
|
4208
4260
|
function receiverOnPing(data) {
|
|
4209
4261
|
const websocket = this[kWebSocket];
|
|
4210
4262
|
|
|
4211
|
-
if (websocket._autoPong
|
|
4263
|
+
if (websocket._autoPong && websocket.readyState === WebSocket.OPEN) {
|
|
4264
|
+
if (
|
|
4265
|
+
websocket._maxPendingAutoPongs > 0 &&
|
|
4266
|
+
websocket._pendingAutoPongs >= websocket._maxPendingAutoPongs
|
|
4267
|
+
) {
|
|
4268
|
+
websocket.terminate();
|
|
4269
|
+
} else {
|
|
4270
|
+
websocket._pendingAutoPongs++;
|
|
4271
|
+
websocket.pong(data, !this._isServer, websocket._autoPongComplete);
|
|
4272
|
+
}
|
|
4273
|
+
}
|
|
4274
|
+
|
|
4212
4275
|
websocket.emit('ping', data);
|
|
4213
4276
|
}
|
|
4214
4277
|
|
|
4278
|
+
/**
|
|
4279
|
+
* The callback for automatic pong responses.
|
|
4280
|
+
*
|
|
4281
|
+
* @param {WebSocket} websocket The WebSocket instance
|
|
4282
|
+
* @private
|
|
4283
|
+
*/
|
|
4284
|
+
function autoPongComplete(websocket) {
|
|
4285
|
+
websocket._pendingAutoPongs--;
|
|
4286
|
+
}
|
|
4287
|
+
|
|
4215
4288
|
/**
|
|
4216
4289
|
* The listener of the `Receiver` `'pong'` event.
|
|
4217
4290
|
*
|
|
@@ -4378,7 +4451,7 @@ function requireStream () {
|
|
|
4378
4451
|
hasRequiredStream = 1;
|
|
4379
4452
|
|
|
4380
4453
|
requireWebsocket();
|
|
4381
|
-
const { Duplex } = require$$0$
|
|
4454
|
+
const { Duplex } = require$$0$3;
|
|
4382
4455
|
|
|
4383
4456
|
/**
|
|
4384
4457
|
* Emits the `'close'` event on a stream.
|
|
@@ -4631,9 +4704,9 @@ function requireWebsocketServer () {
|
|
|
4631
4704
|
if (hasRequiredWebsocketServer) return websocketServer;
|
|
4632
4705
|
hasRequiredWebsocketServer = 1;
|
|
4633
4706
|
|
|
4634
|
-
const EventEmitter = require$$0$
|
|
4635
|
-
const http = require$$
|
|
4636
|
-
const { Duplex } = require$$0$
|
|
4707
|
+
const EventEmitter = require$$0$4;
|
|
4708
|
+
const http = require$$0;
|
|
4709
|
+
const { Duplex } = require$$0$3;
|
|
4637
4710
|
const { createHash } = require$$1;
|
|
4638
4711
|
|
|
4639
4712
|
const extension = requireExtension();
|
|
@@ -4678,6 +4751,8 @@ function requireWebsocketServer () {
|
|
|
4678
4751
|
* fragments
|
|
4679
4752
|
* @param {Number} [options.maxPayload=104857600] The maximum allowed message
|
|
4680
4753
|
* size
|
|
4754
|
+
* @param {Number} [options.maxPendingAutoPongs=60] The maximum number of
|
|
4755
|
+
* pending automatic pongs
|
|
4681
4756
|
* @param {Boolean} [options.noServer=false] Enable no server mode
|
|
4682
4757
|
* @param {String} [options.path] Accept only connections matching this path
|
|
4683
4758
|
* @param {(Boolean|Object)} [options.perMessageDeflate=false] Enable/disable
|
|
@@ -4701,6 +4776,7 @@ function requireWebsocketServer () {
|
|
|
4701
4776
|
maxBufferedChunks: 256 * 1024,
|
|
4702
4777
|
maxFragments: 16 * 1024,
|
|
4703
4778
|
maxPayload: 100 * 1024 * 1024,
|
|
4779
|
+
maxPendingAutoPongs: 60,
|
|
4704
4780
|
skipUTF8Validation: false,
|
|
4705
4781
|
perMessageDeflate: false,
|
|
4706
4782
|
handleProtocols: null,
|
|
@@ -5938,6 +6014,7 @@ const debugMemory = createDebugger("vitest:cache:memory");
|
|
|
5938
6014
|
const cacheComment = "\n//# vitestCache=";
|
|
5939
6015
|
const cacheCommentLength = 17;
|
|
5940
6016
|
const METADATA_FILE = "_metadata.json";
|
|
6017
|
+
const MANIFEST_SECTIONS = ["modules", "externalized"];
|
|
5941
6018
|
// Default location of the module cache. It lives inside `node_modules` at the
|
|
5942
6019
|
// workspace root so it's shared by every project and is naturally invalidated
|
|
5943
6020
|
// whenever dependencies are reinstalled.
|
|
@@ -5955,7 +6032,7 @@ class FileSystemModuleCache {
|
|
|
5955
6032
|
*/
|
|
5956
6033
|
rootCache;
|
|
5957
6034
|
metadataFilePath;
|
|
5958
|
-
version = "1.0.0-beta.
|
|
6035
|
+
version = "1.0.0-beta.10";
|
|
5959
6036
|
fsCacheRoots = /* @__PURE__ */ new WeakMap();
|
|
5960
6037
|
fsEnvironmentHashMap = /* @__PURE__ */ new WeakMap();
|
|
5961
6038
|
fsCacheKeyGenerators = /* @__PURE__ */ new WeakMap();
|
|
@@ -5963,6 +6040,8 @@ class FileSystemModuleCache {
|
|
|
5963
6040
|
// this exists only to avoid the perf. cost of reading a file and generating a hash again
|
|
5964
6041
|
// surprisingly, on some machines this has negligible effect
|
|
5965
6042
|
fsCacheKeys = /* @__PURE__ */ new WeakMap();
|
|
6043
|
+
manifests = /* @__PURE__ */ new Map();
|
|
6044
|
+
manifestEntries = /* @__PURE__ */ new WeakMap();
|
|
5966
6045
|
constructor(vitest) {
|
|
5967
6046
|
this.vitest = vitest;
|
|
5968
6047
|
this.rootCache = vitest.config.fsModuleCachePath || join(searchForWorkspaceRoot(vitest.viteConfig.root), "node_modules", DEFAULT_CACHE_DIRNAME);
|
|
@@ -5997,7 +6076,8 @@ class FileSystemModuleCache {
|
|
|
5997
6076
|
if (log) this.vitest.logger.log(`[cache] cleared fs module cache at ${uniquePaths.join(", ")}`);
|
|
5998
6077
|
}
|
|
5999
6078
|
readCachedFileConcurrently(cachedFilePath) {
|
|
6000
|
-
if (!parallelFsCacheRead.has(cachedFilePath)) parallelFsCacheRead.set(cachedFilePath, readFile(cachedFilePath, "utf-8").then((
|
|
6079
|
+
if (!parallelFsCacheRead.has(cachedFilePath)) parallelFsCacheRead.set(cachedFilePath, readFile(cachedFilePath, "utf-8").then((content) => {
|
|
6080
|
+
const { code, sourceMap } = splitSourceMap(content);
|
|
6001
6081
|
const matchIndex = code.lastIndexOf(cacheComment);
|
|
6002
6082
|
if (matchIndex === -1) {
|
|
6003
6083
|
debugFs?.(`${$.red("[empty]")} ${cachedFilePath} exists, but doesn't have a ${cacheComment} comment, transforming by vite instead`);
|
|
@@ -6005,26 +6085,28 @@ class FileSystemModuleCache {
|
|
|
6005
6085
|
}
|
|
6006
6086
|
return {
|
|
6007
6087
|
code,
|
|
6088
|
+
sourceMap,
|
|
6008
6089
|
meta: this.fromBase64(code.slice(matchIndex + cacheCommentLength))
|
|
6009
6090
|
};
|
|
6091
|
+
}, (error) => {
|
|
6092
|
+
// another process can remove the cache at any time
|
|
6093
|
+
if (error?.code !== "ENOENT") throw error;
|
|
6094
|
+
debugFs?.(`${$.red("[empty]")} ${cachedFilePath} doesn't exist, transforming by vite first`);
|
|
6010
6095
|
}).finally(() => {
|
|
6011
6096
|
parallelFsCacheRead.delete(cachedFilePath);
|
|
6012
6097
|
}));
|
|
6013
6098
|
return parallelFsCacheRead.get(cachedFilePath);
|
|
6014
6099
|
}
|
|
6015
6100
|
async getCachedModule(cachedFilePath) {
|
|
6016
|
-
if (!existsSync(cachedFilePath)) {
|
|
6017
|
-
debugFs?.(`${$.red("[empty]")} ${cachedFilePath} doesn't exist, transforming by vite first`);
|
|
6018
|
-
return;
|
|
6019
|
-
}
|
|
6020
6101
|
const fileResult = await this.readCachedFileConcurrently(cachedFilePath);
|
|
6021
6102
|
if (!fileResult) return;
|
|
6022
|
-
const { code, meta } = fileResult;
|
|
6103
|
+
const { code, sourceMap, meta } = fileResult;
|
|
6023
6104
|
debugFs?.(`${$.green("[read]")} ${meta.id} is cached in ${cachedFilePath}`);
|
|
6024
6105
|
return {
|
|
6025
6106
|
id: meta.id,
|
|
6026
6107
|
file: meta.file,
|
|
6027
6108
|
code,
|
|
6109
|
+
sourceMap,
|
|
6028
6110
|
imports: meta.imports,
|
|
6029
6111
|
mappings: meta.mappings,
|
|
6030
6112
|
moduleType: meta.moduleType,
|
|
@@ -6052,7 +6134,7 @@ class FileSystemModuleCache {
|
|
|
6052
6134
|
hasCoverageData: coverageData !== void 0
|
|
6053
6135
|
};
|
|
6054
6136
|
debugFs?.(`${$.yellow("[write]")} ${fetchResult.id} is cached in ${cachedFilePath}`);
|
|
6055
|
-
await Promise.all([result.hasCoverageData && atomicWriteFile(getCoverageDataPath(cachedFilePath), JSON.stringify(coverageData)), atomicWriteFile(cachedFilePath, `${fetchResult.code}${cacheComment}${this.toBase64(result)}
|
|
6137
|
+
await Promise.all([result.hasCoverageData && atomicWriteFile(getCoverageDataPath(cachedFilePath), JSON.stringify(coverageData)), atomicWriteFile(cachedFilePath, appendSourceMap(`${fetchResult.code}${cacheComment}${this.toBase64(result)}`, fetchResult.sourceMap))]);
|
|
6056
6138
|
}
|
|
6057
6139
|
}
|
|
6058
6140
|
getCoverageData(environment, id) {
|
|
@@ -6066,6 +6148,13 @@ class FileSystemModuleCache {
|
|
|
6066
6148
|
restoreCoverageData(environment, id, data) {
|
|
6067
6149
|
this.vitest.coverageProvider?.restoreModuleCacheData?.(environment, id, data);
|
|
6068
6150
|
}
|
|
6151
|
+
// Vite watches the files outside of the root when it loads them, a cached module skips that
|
|
6152
|
+
watchFile(file) {
|
|
6153
|
+
const server = this.vitest.vite;
|
|
6154
|
+
// plugins can import modules in `configureServer` before the root server is attached
|
|
6155
|
+
if (!server) return;
|
|
6156
|
+
if (!file.startsWith(`${server.config.root}/`) && existsSync(file)) server.watcher.add(file);
|
|
6157
|
+
}
|
|
6069
6158
|
toBase64(obj) {
|
|
6070
6159
|
const json = stringify(obj);
|
|
6071
6160
|
return Buffer.from(json).toString("base64");
|
|
@@ -6170,6 +6259,96 @@ class FileSystemModuleCache {
|
|
|
6170
6259
|
this.saveMemoryCache(environment, id, fsResultPath);
|
|
6171
6260
|
return fsResultPath;
|
|
6172
6261
|
}
|
|
6262
|
+
recordManifestModule(vitestConfig, environment, url, cachePath) {
|
|
6263
|
+
this.getManifestEntries(vitestConfig, environment)?.modules.set(url, cachePath);
|
|
6264
|
+
}
|
|
6265
|
+
recordManifestExternal(vitestConfig, environment, url, externalized) {
|
|
6266
|
+
this.getManifestEntries(vitestConfig, environment)?.externalized.set(url, externalized);
|
|
6267
|
+
}
|
|
6268
|
+
getManifestEntries(vitestConfig, environment) {
|
|
6269
|
+
let entries = this.manifestEntries.get(environment);
|
|
6270
|
+
if (entries) return entries;
|
|
6271
|
+
const cacheRoot = this.getCacheRoot(vitestConfig);
|
|
6272
|
+
if (cacheRoot == null) return;
|
|
6273
|
+
const manifest = this.getManifest(vitestConfig, cacheRoot);
|
|
6274
|
+
entries = manifest.environments.get(environment.name);
|
|
6275
|
+
if (!entries) {
|
|
6276
|
+
entries = {
|
|
6277
|
+
modules: /* @__PURE__ */ new Map(),
|
|
6278
|
+
externalized: /* @__PURE__ */ new Map()
|
|
6279
|
+
};
|
|
6280
|
+
manifest.environments.set(environment.name, entries);
|
|
6281
|
+
}
|
|
6282
|
+
this.manifestEntries.set(environment, entries);
|
|
6283
|
+
return entries;
|
|
6284
|
+
}
|
|
6285
|
+
getManifest(vitestConfig, cacheRoot) {
|
|
6286
|
+
// several projects and Vitest processes can share the cache directory
|
|
6287
|
+
const label = (vitestConfig.name || basename(vitestConfig.root)).replace(/[^\w@-]+/g, "_").slice(0, 50);
|
|
6288
|
+
const key = hash("sha1", `${vitestConfig.root}\0${vitestConfig.name}`, "hex").slice(0, 8);
|
|
6289
|
+
const path = join(cacheRoot, `_manifest-${label}-${key}.json`);
|
|
6290
|
+
let manifest = this.manifests.get(path);
|
|
6291
|
+
if (!manifest) {
|
|
6292
|
+
manifest = {
|
|
6293
|
+
path,
|
|
6294
|
+
name: vitestConfig.name,
|
|
6295
|
+
root: vitestConfig.root,
|
|
6296
|
+
environments: /* @__PURE__ */ new Map()
|
|
6297
|
+
};
|
|
6298
|
+
this.manifests.set(path, manifest);
|
|
6299
|
+
}
|
|
6300
|
+
return manifest;
|
|
6301
|
+
}
|
|
6302
|
+
async writeManifests() {
|
|
6303
|
+
await Promise.all(Array.from(this.manifests.values(), (manifest) => this.writeManifest(manifest)));
|
|
6304
|
+
}
|
|
6305
|
+
async writeManifest(manifest) {
|
|
6306
|
+
if (Array.from(manifest.environments.values()).every((entries) => !entries.modules.size && !entries.externalized.size)) return;
|
|
6307
|
+
const loaded = manifest.content;
|
|
6308
|
+
const content = loaded ?? await readManifestContent(manifest.path);
|
|
6309
|
+
manifest.content = content;
|
|
6310
|
+
const changes = [];
|
|
6311
|
+
for (const [environment, entries] of manifest.environments) for (const section of MANIFEST_SECTIONS) {
|
|
6312
|
+
const values = content[section][environment];
|
|
6313
|
+
for (const [url, recordedValue] of entries[section]) {
|
|
6314
|
+
const value = section === "modules" ? recordedValue.slice(recordedValue.lastIndexOf("/") + 1) : recordedValue;
|
|
6315
|
+
if (values?.[url] !== value) changes.push([
|
|
6316
|
+
section,
|
|
6317
|
+
environment,
|
|
6318
|
+
url,
|
|
6319
|
+
value
|
|
6320
|
+
]);
|
|
6321
|
+
}
|
|
6322
|
+
entries[section].clear();
|
|
6323
|
+
}
|
|
6324
|
+
if (!changes.length) return;
|
|
6325
|
+
let target = content;
|
|
6326
|
+
if (loaded) {
|
|
6327
|
+
// another process can update the manifest after this one loaded it
|
|
6328
|
+
target = await readManifestContent(manifest.path);
|
|
6329
|
+
for (const section of MANIFEST_SECTIONS) for (const environment in content[section]) target[section][environment] = {
|
|
6330
|
+
...content[section][environment],
|
|
6331
|
+
...target[section][environment]
|
|
6332
|
+
};
|
|
6333
|
+
}
|
|
6334
|
+
for (const [section, environment, url, value] of changes) {
|
|
6335
|
+
(target[section][environment] ??= {})[url] = value;
|
|
6336
|
+
// a module can switch between being inlined and externalized
|
|
6337
|
+
delete target[section === "modules" ? "externalized" : "modules"][environment]?.[url];
|
|
6338
|
+
}
|
|
6339
|
+
manifest.content = target;
|
|
6340
|
+
try {
|
|
6341
|
+
const data = {
|
|
6342
|
+
name: manifest.name,
|
|
6343
|
+
root: manifest.root,
|
|
6344
|
+
...target
|
|
6345
|
+
};
|
|
6346
|
+
await atomicWriteFile(manifest.path, JSON.stringify(data, null, 2));
|
|
6347
|
+
} catch (error) {
|
|
6348
|
+
manifest.content = void 0;
|
|
6349
|
+
debugFs?.(`failed to write fs cache manifest ${manifest.path}: ${error}`);
|
|
6350
|
+
}
|
|
6351
|
+
}
|
|
6173
6352
|
saveMemoryCache(environment, id, cache) {
|
|
6174
6353
|
let environmentKeys = this.fsCacheKeys.get(environment);
|
|
6175
6354
|
if (!environmentKeys) {
|
|
@@ -6223,6 +6402,20 @@ class FileSystemModuleCache {
|
|
|
6223
6402
|
debugFs?.(`fs cache was cleared because lockfile has changed`);
|
|
6224
6403
|
}
|
|
6225
6404
|
}
|
|
6405
|
+
async function readManifestContent(path) {
|
|
6406
|
+
try {
|
|
6407
|
+
const manifest = JSON.parse(await readFile(path, "utf-8"));
|
|
6408
|
+
return {
|
|
6409
|
+
modules: manifest.modules ?? {},
|
|
6410
|
+
externalized: manifest.externalized ?? {}
|
|
6411
|
+
};
|
|
6412
|
+
} catch {
|
|
6413
|
+
return {
|
|
6414
|
+
modules: {},
|
|
6415
|
+
externalized: {}
|
|
6416
|
+
};
|
|
6417
|
+
}
|
|
6418
|
+
}
|
|
6226
6419
|
/**
|
|
6227
6420
|
* Performs an atomic write operation using the write-then-rename pattern.
|
|
6228
6421
|
*
|
|
@@ -6818,7 +7011,11 @@ class VitestCache {
|
|
|
6818
7011
|
}
|
|
6819
7012
|
/** @internal */
|
|
6820
7013
|
async _update(specifications, startTime) {
|
|
6821
|
-
await Promise.all([
|
|
7014
|
+
await Promise.all([
|
|
7015
|
+
this._results.update(specifications, startTime),
|
|
7016
|
+
this._dependencies.update(specifications, startTime),
|
|
7017
|
+
this._modules.writeManifests()
|
|
7018
|
+
]);
|
|
6822
7019
|
}
|
|
6823
7020
|
/** @internal */
|
|
6824
7021
|
async _clear() {
|
|
@@ -7353,6 +7550,7 @@ Update your dependencies and make sure the versions match.`));
|
|
|
7353
7550
|
const code = await promises.readFile(filename, "utf-8");
|
|
7354
7551
|
return {
|
|
7355
7552
|
// `transform` mode will inject source maps comment at the end
|
|
7553
|
+
// Node 26 removed the 'transform' mode, older versions still support it
|
|
7356
7554
|
code: module$1.stripTypeScriptTypes(code, { mode: isTransform ? "transform" : "strip" }),
|
|
7357
7555
|
map: null
|
|
7358
7556
|
};
|
|
@@ -7365,7 +7563,7 @@ Update your dependencies and make sure the versions match.`));
|
|
|
7365
7563
|
return async (filename) => {
|
|
7366
7564
|
let lastError;
|
|
7367
7565
|
for (const project of projects) {
|
|
7368
|
-
const root = project.config.root
|
|
7566
|
+
const root = project.config.root.endsWith("/") ? project.config.root : `${project.config.root}/`;
|
|
7369
7567
|
if (!filename.startsWith(root) && !filename.startsWith(`/${root}`) && project !== rootProject) continue;
|
|
7370
7568
|
try {
|
|
7371
7569
|
const environment = project.config.environment;
|
|
@@ -8210,6 +8408,53 @@ function padBenchRow(row, widths) {
|
|
|
8210
8408
|
return row.map((v, i) => i === 0 ? v.padEnd(widths[i]) : v.padStart(widths[i]));
|
|
8211
8409
|
}
|
|
8212
8410
|
|
|
8411
|
+
function groupTaskErrors(tasks) {
|
|
8412
|
+
const groups = [];
|
|
8413
|
+
for (const task of tasks)
|
|
8414
|
+
// Merge identical errors
|
|
8415
|
+
for (const { error, attempt } of getErrorsWithAttempt(task)) {
|
|
8416
|
+
let previous;
|
|
8417
|
+
if (error.stack) previous = groups.find((item) => {
|
|
8418
|
+
if (item.error.stack !== error.stack || item.error.diff !== error.diff) return false;
|
|
8419
|
+
const itemTask = item.sources[0].task;
|
|
8420
|
+
const currentProjectName = task?.projectName || task.file?.projectName || "";
|
|
8421
|
+
const projectName = itemTask?.projectName || itemTask.file?.projectName || "";
|
|
8422
|
+
const currentAnnotations = task.type === "test" && task.annotations;
|
|
8423
|
+
const itemAnnotations = itemTask.type === "test" && itemTask.annotations;
|
|
8424
|
+
return projectName === currentProjectName && deepEqual(currentAnnotations, itemAnnotations);
|
|
8425
|
+
});
|
|
8426
|
+
if (previous) previous.sources.push({
|
|
8427
|
+
task,
|
|
8428
|
+
attempt
|
|
8429
|
+
});
|
|
8430
|
+
else groups.push({
|
|
8431
|
+
error,
|
|
8432
|
+
sources: [{
|
|
8433
|
+
task,
|
|
8434
|
+
attempt
|
|
8435
|
+
}]
|
|
8436
|
+
});
|
|
8437
|
+
}
|
|
8438
|
+
return groups;
|
|
8439
|
+
}
|
|
8440
|
+
function getErrorsWithAttempt(task) {
|
|
8441
|
+
const attempts = task.result?.attempts;
|
|
8442
|
+
if (!attempts?.length) return (task.result?.errors ?? []).map((error) => ({ error }));
|
|
8443
|
+
return attempts.flatMap((attempt) => (attempt.errors ?? []).map((error) => ({
|
|
8444
|
+
error,
|
|
8445
|
+
attempt
|
|
8446
|
+
})));
|
|
8447
|
+
}
|
|
8448
|
+
function deepEqual(a, b) {
|
|
8449
|
+
if (a === b) return true;
|
|
8450
|
+
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
|
|
8451
|
+
const keysA = Object.keys(a);
|
|
8452
|
+
const keysB = Object.keys(b);
|
|
8453
|
+
if (keysA.length !== keysB.length) return false;
|
|
8454
|
+
for (const key of keysA) if (!Object.hasOwn(b, key) || !deepEqual(a[key], b[key])) return false;
|
|
8455
|
+
return true;
|
|
8456
|
+
}
|
|
8457
|
+
|
|
8213
8458
|
function getTraceAttemptKey(trace) {
|
|
8214
8459
|
return `${trace.repeats}:${trace.retry}`;
|
|
8215
8460
|
}
|
|
@@ -9015,17 +9260,18 @@ class BaseReporter {
|
|
|
9015
9260
|
const tests = getTests(files);
|
|
9016
9261
|
const failedSuites = suites.filter((i) => i.result?.errors);
|
|
9017
9262
|
const failedTests = tests.filter((i) => i.result?.state === "fail");
|
|
9018
|
-
const
|
|
9019
|
-
|
|
9263
|
+
const suiteErrors = groupTaskErrors(failedSuites);
|
|
9264
|
+
const testErrors = groupTaskErrors(failedTests);
|
|
9265
|
+
const failedTotal = suiteErrors.length + testErrors.length;
|
|
9020
9266
|
let current = 1;
|
|
9021
9267
|
const errorDivider = () => this.error(`${$.red($.dim(divider(`[${current++}/${failedTotal}]`, void 0, 1)))}\n`);
|
|
9022
9268
|
if (failedSuites.length) {
|
|
9023
9269
|
this.error(`\n${errorBanner(`Failed Suites ${failedSuites.length}`)}\n`);
|
|
9024
|
-
this.printTaskErrors(
|
|
9270
|
+
this.printTaskErrors(suiteErrors, errorDivider);
|
|
9025
9271
|
}
|
|
9026
9272
|
if (failedTests.length) {
|
|
9027
9273
|
this.error(`\n${errorBanner(`Failed Tests ${failedTests.length}`)}\n`);
|
|
9028
|
-
this.printTaskErrors(
|
|
9274
|
+
this.printTaskErrors(testErrors, errorDivider);
|
|
9029
9275
|
}
|
|
9030
9276
|
if (errors.length) {
|
|
9031
9277
|
this.ctx.logger.printUnhandledErrors(errors);
|
|
@@ -9118,34 +9364,8 @@ class BaseReporter {
|
|
|
9118
9364
|
}
|
|
9119
9365
|
}
|
|
9120
9366
|
}
|
|
9121
|
-
printTaskErrors(
|
|
9122
|
-
const
|
|
9123
|
-
for (const task of tasks)
|
|
9124
|
-
// Merge identical errors
|
|
9125
|
-
for (const { error, attempt } of getErrorsWithAttempt(task)) {
|
|
9126
|
-
let previous;
|
|
9127
|
-
if (error.stack) previous = errorsQueue.find((item) => {
|
|
9128
|
-
if (item.error.stack !== error.stack || item.error.diff !== error.diff) return false;
|
|
9129
|
-
const itemTask = item.sources[0].task;
|
|
9130
|
-
const currentProjectName = task?.projectName || task.file?.projectName || "";
|
|
9131
|
-
const projectName = itemTask?.projectName || itemTask.file?.projectName || "";
|
|
9132
|
-
const currentAnnotations = task.type === "test" && task.annotations;
|
|
9133
|
-
const itemAnnotations = itemTask.type === "test" && itemTask.annotations;
|
|
9134
|
-
return projectName === currentProjectName && deepEqual(currentAnnotations, itemAnnotations);
|
|
9135
|
-
});
|
|
9136
|
-
if (previous) previous.sources.push({
|
|
9137
|
-
task,
|
|
9138
|
-
attempt
|
|
9139
|
-
});
|
|
9140
|
-
else errorsQueue.push({
|
|
9141
|
-
error,
|
|
9142
|
-
sources: [{
|
|
9143
|
-
task,
|
|
9144
|
-
attempt
|
|
9145
|
-
}]
|
|
9146
|
-
});
|
|
9147
|
-
}
|
|
9148
|
-
for (const { error, sources } of errorsQueue) {
|
|
9367
|
+
printTaskErrors(groups, errorDivider) {
|
|
9368
|
+
for (const { error, sources } of groups) {
|
|
9149
9369
|
const tasks = sources.map(({ task }) => task);
|
|
9150
9370
|
const attemptsByTask = /* @__PURE__ */ new Map();
|
|
9151
9371
|
for (const { task, attempt } of sources) attemptsByTask.set(task, [...attemptsByTask.get(task) ?? [], attempt]);
|
|
@@ -9193,29 +9413,12 @@ function formatAttempt({ repeatIndex, retryIndex }) {
|
|
|
9193
9413
|
if (repeat && retry) return `${retry} of ${repeat}`;
|
|
9194
9414
|
return repeat || retry || "initial run";
|
|
9195
9415
|
}
|
|
9196
|
-
function getErrorsWithAttempt(task) {
|
|
9197
|
-
const attempts = task.result?.attempts;
|
|
9198
|
-
if (!attempts?.length) return (task.result?.errors ?? []).map((error) => ({ error }));
|
|
9199
|
-
return attempts.flatMap((attempt) => (attempt.errors ?? []).map((error) => ({
|
|
9200
|
-
error,
|
|
9201
|
-
attempt
|
|
9202
|
-
})));
|
|
9203
|
-
}
|
|
9204
9416
|
function getFailureScreenshotPaths(task, attempt) {
|
|
9205
9417
|
if (task.type !== "test") return [];
|
|
9206
9418
|
const paths = [];
|
|
9207
9419
|
for (const artifact of task.artifacts) if (artifact.type === "internal:failureScreenshot" && artifact.attachments.length && artifact.retryIndex === attempt.retryIndex && artifact.repeatIndex === attempt.repeatIndex) paths.push(artifact.attachments[0].originalPath);
|
|
9208
9420
|
return paths;
|
|
9209
9421
|
}
|
|
9210
|
-
function deepEqual(a, b) {
|
|
9211
|
-
if (a === b) return true;
|
|
9212
|
-
if (typeof a !== "object" || typeof b !== "object" || a === null || b === null) return false;
|
|
9213
|
-
const keysA = Object.keys(a);
|
|
9214
|
-
const keysB = Object.keys(b);
|
|
9215
|
-
if (keysA.length !== keysB.length) return false;
|
|
9216
|
-
for (const key of keysA) if (!Object.hasOwn(b, key) || !deepEqual(a[key], b[key])) return false;
|
|
9217
|
-
return true;
|
|
9218
|
-
}
|
|
9219
9422
|
function sum(items, cb) {
|
|
9220
9423
|
return items.reduce((total, next) => {
|
|
9221
9424
|
return total + Math.max(cb(next) || 0, 0);
|
|
@@ -10082,8 +10285,9 @@ class JsonReporter {
|
|
|
10082
10285
|
const numTotalTestSuites = suites.length;
|
|
10083
10286
|
const tests = getTests(files);
|
|
10084
10287
|
const numTotalTests = tests.length;
|
|
10085
|
-
const
|
|
10086
|
-
const
|
|
10288
|
+
const unfinishedFiles = new Set(files.filter(isUnfinished));
|
|
10289
|
+
const numFailedTestSuites = suites.filter((s) => s.result?.state === "fail" || unfinishedFiles.has(s)).length;
|
|
10290
|
+
const numPendingTestSuites = suites.filter((s) => !unfinishedFiles.has(s) && (s.result?.state === "run" || s.result?.state === "queued" || s.mode === "todo")).length;
|
|
10087
10291
|
const numPassedTestSuites = numTotalTestSuites - numFailedTestSuites - numPendingTestSuites;
|
|
10088
10292
|
const numFailedTests = tests.filter((t) => t.result?.state === "fail").length;
|
|
10089
10293
|
const numPassedTests = tests.filter((t) => t.result?.state === "pass").length;
|
|
@@ -10131,7 +10335,7 @@ class JsonReporter {
|
|
|
10131
10335
|
assertionResults,
|
|
10132
10336
|
startTime,
|
|
10133
10337
|
endTime,
|
|
10134
|
-
status: file.result?.state === "fail" || hasFailedTests ? "failed" : "passed",
|
|
10338
|
+
status: unfinishedFiles.has(file) || file.result?.state === "fail" || hasFailedTests ? "failed" : "passed",
|
|
10135
10339
|
message: file.result?.errors?.[0]?.message ?? "",
|
|
10136
10340
|
name: file.filepath
|
|
10137
10341
|
});
|
|
@@ -10168,6 +10372,12 @@ class JsonReporter {
|
|
|
10168
10372
|
}
|
|
10169
10373
|
}
|
|
10170
10374
|
}
|
|
10375
|
+
// the file did not finish, for example because its worker crashed
|
|
10376
|
+
// (same as `pending` or `queued` in `TestModule.state()`)
|
|
10377
|
+
function isUnfinished(file) {
|
|
10378
|
+
const state = file.result?.state;
|
|
10379
|
+
return file.mode !== "skip" && file.mode !== "todo" && (state == null || state === "run" || state === "only" || state === "queued");
|
|
10380
|
+
}
|
|
10171
10381
|
|
|
10172
10382
|
class IndentedLogger {
|
|
10173
10383
|
baseLog;
|
|
@@ -11239,7 +11449,7 @@ class TestModule extends SuiteImplementation {
|
|
|
11239
11449
|
* Checks the running state of the test file.
|
|
11240
11450
|
*/
|
|
11241
11451
|
state() {
|
|
11242
|
-
if (this.task.
|
|
11452
|
+
if (this.task.mode === "queued" && !this.task.result) return "queued";
|
|
11243
11453
|
return getSuiteState(this.task);
|
|
11244
11454
|
}
|
|
11245
11455
|
/**
|
|
@@ -11390,7 +11600,7 @@ class StateManager {
|
|
|
11390
11600
|
collectFiles(project, files = []) {
|
|
11391
11601
|
files.forEach((file) => {
|
|
11392
11602
|
const existing = this.filesMap.get(file.filepath) || [];
|
|
11393
|
-
const currentFile = existing.find((i) => i.
|
|
11603
|
+
const currentFile = existing.find((i) => i.id === file.id);
|
|
11394
11604
|
// keep logs for the previous file because it should always be initiated before the collections phase
|
|
11395
11605
|
// which means that all logs are collected during the collection and not inside tests
|
|
11396
11606
|
if (currentFile) file.logs = currentFile.logs;
|
|
@@ -12131,15 +12341,16 @@ class Mime {
|
|
|
12131
12341
|
for (let [type, extensions] of Object.entries(typeMap)) {
|
|
12132
12342
|
type = type.toLowerCase();
|
|
12133
12343
|
extensions = extensions.map((ext) => ext.toLowerCase());
|
|
12134
|
-
|
|
12135
|
-
|
|
12344
|
+
let allExtensions = __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").get(type);
|
|
12345
|
+
if (!allExtensions) {
|
|
12346
|
+
allExtensions = new Set();
|
|
12347
|
+
__classPrivateFieldGet(this, _Mime_typeToExtensions, "f").set(type, allExtensions);
|
|
12136
12348
|
}
|
|
12137
|
-
const allExtensions = __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").get(type);
|
|
12138
12349
|
let first = true;
|
|
12139
12350
|
for (let extension of extensions) {
|
|
12140
12351
|
const starred = extension.startsWith('*');
|
|
12141
12352
|
extension = starred ? extension.slice(1) : extension;
|
|
12142
|
-
allExtensions
|
|
12353
|
+
allExtensions.add(extension);
|
|
12143
12354
|
if (first) {
|
|
12144
12355
|
__classPrivateFieldGet(this, _Mime_typeToExtension, "f").set(type, extension);
|
|
12145
12356
|
}
|
|
@@ -12176,16 +12387,14 @@ class Mime {
|
|
|
12176
12387
|
if (typeof type !== 'string')
|
|
12177
12388
|
return null;
|
|
12178
12389
|
type = type.split(';')[0].trim().toLowerCase();
|
|
12179
|
-
|
|
12390
|
+
const extensions = __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").get(type);
|
|
12391
|
+
return extensions ? new Set(extensions) : null;
|
|
12180
12392
|
}
|
|
12181
12393
|
_freeze() {
|
|
12182
12394
|
this.define = () => {
|
|
12183
12395
|
throw new Error('define() not allowed for built-in Mime objects. See https://github.com/broofa/mime/blob/main/README.md#custom-mime-instances');
|
|
12184
12396
|
};
|
|
12185
12397
|
Object.freeze(this);
|
|
12186
|
-
for (const extensions of __classPrivateFieldGet(this, _Mime_typeToExtensions, "f").values()) {
|
|
12187
|
-
Object.freeze(extensions);
|
|
12188
|
-
}
|
|
12189
12398
|
return this;
|
|
12190
12399
|
}
|
|
12191
12400
|
_getTestState() {
|
|
@@ -12201,10 +12410,17 @@ var mime = new Mime(types)._freeze();
|
|
|
12201
12410
|
|
|
12202
12411
|
class TestRun {
|
|
12203
12412
|
vitest;
|
|
12413
|
+
externalSourceMaps = /* @__PURE__ */ new Map();
|
|
12414
|
+
// the first project that attached each file in this run
|
|
12415
|
+
attachmentProjects = /* @__PURE__ */ new Map();
|
|
12416
|
+
warnedProjectPairs = /* @__PURE__ */ new Set();
|
|
12204
12417
|
constructor(vitest) {
|
|
12205
12418
|
this.vitest = vitest;
|
|
12206
12419
|
}
|
|
12207
12420
|
async start(specifications) {
|
|
12421
|
+
this.externalSourceMaps.clear();
|
|
12422
|
+
this.attachmentProjects.clear();
|
|
12423
|
+
this.warnedProjectPairs.clear();
|
|
12208
12424
|
const filepaths = specifications.map((spec) => spec.moduleId);
|
|
12209
12425
|
this.vitest.state.collectPaths(filepaths);
|
|
12210
12426
|
await this.vitest.report("onTestRunStart", [...specifications]);
|
|
@@ -12240,14 +12456,16 @@ class TestRun {
|
|
|
12240
12456
|
return artifact;
|
|
12241
12457
|
}
|
|
12242
12458
|
if (Array.isArray(artifact.attachments)) await Promise.all(artifact.attachments.map((attachment) => this.resolveTestAttachment(testCase, attachment)));
|
|
12243
|
-
//
|
|
12244
|
-
//
|
|
12245
|
-
if (artifact.type === "internal:browserTrace"
|
|
12459
|
+
// trace locations of browser tests need the browser server's source maps here,
|
|
12460
|
+
// while node trace stacks are already mapped in the worker except for external modules
|
|
12461
|
+
if (artifact.type === "internal:browserTrace") {
|
|
12246
12462
|
const { entries } = artifact.data;
|
|
12463
|
+
const project = testCase.project;
|
|
12464
|
+
const isBrowser = testCase.task.file.pool === "browser";
|
|
12247
12465
|
for (const entry of entries) if (entry.stack && !entry.location) {
|
|
12248
|
-
const [stack] = parseStacktrace(entry.stack, {
|
|
12466
|
+
const [stack] = isBrowser ? project.browser?.parseStacktrace(entry.stack, { firstOnly: true }) || [] : parseStacktrace(entry.stack, {
|
|
12249
12467
|
firstOnly: true,
|
|
12250
|
-
getSourceMap: (file) => getExternalSourceMap(
|
|
12468
|
+
getSourceMap: (file) => this.getExternalSourceMap(project, file)
|
|
12251
12469
|
});
|
|
12252
12470
|
if (stack) entry.location = {
|
|
12253
12471
|
file: stack.file,
|
|
@@ -12280,45 +12498,51 @@ class TestRun {
|
|
|
12280
12498
|
}
|
|
12281
12499
|
async end(specifications, errors, coverage) {
|
|
12282
12500
|
if (coverage) await this.vitest.report("onCoverage", coverage);
|
|
12283
|
-
// specification won't have the File task if they were filtered by the --shard command
|
|
12284
12501
|
const modules = specifications.map((spec) => spec.testModule).filter((s) => s != null);
|
|
12285
12502
|
const state = this.vitest.isCancelling ? "interrupted" : // by this point, the run will be marked as failed if there are any errors,
|
|
12286
12503
|
// should it be done by testRun.end?
|
|
12287
12504
|
this.hasFailed(modules) ? "failed" : "passed";
|
|
12288
12505
|
if (state !== "passed") process.exitCode = 1;
|
|
12289
12506
|
await this.vitest.report("onTestRunEnd", modules, [...errors], state);
|
|
12290
|
-
for (const project in this.vitest.state.metadata) {
|
|
12291
|
-
const meta = this.vitest.state.metadata[project];
|
|
12292
|
-
if (!meta?.dumpDir) continue;
|
|
12293
|
-
const path = resolve(meta.dumpDir, "vitest-metadata.json");
|
|
12294
|
-
meta.outline = {
|
|
12295
|
-
externalized: Object.keys(meta.externalized).length,
|
|
12296
|
-
inlined: Object.keys(meta.tmps).length
|
|
12297
|
-
};
|
|
12298
|
-
await writeFile(path, JSON.stringify(meta, null, 2), "utf-8");
|
|
12299
|
-
this.vitest.logger.log(`Metadata written to ${path}`);
|
|
12300
|
-
}
|
|
12301
12507
|
}
|
|
12302
12508
|
hasFailed(modules) {
|
|
12303
12509
|
if (!modules.length) return !this.vitest.config.passWithNoTests;
|
|
12304
|
-
return modules.some((m) =>
|
|
12510
|
+
return modules.some((m) => {
|
|
12511
|
+
const state = m.state();
|
|
12512
|
+
return !m.ok() || state === "pending" || state === "queued";
|
|
12513
|
+
});
|
|
12305
12514
|
}
|
|
12306
12515
|
// make sure the error always has a "stacks" property
|
|
12307
12516
|
syncUpdateStacks(update) {
|
|
12308
12517
|
update.forEach(([taskId, result]) => {
|
|
12309
12518
|
const task = this.vitest.state.idMap.get(taskId);
|
|
12310
12519
|
const isBrowser = task && task.file.pool === "browser";
|
|
12311
|
-
|
|
12520
|
+
// the worker sends all errors of the task again in each update
|
|
12521
|
+
const previous = task?.result;
|
|
12522
|
+
result?.errors?.forEach((error, i) => {
|
|
12312
12523
|
if (isPrimitive(error)) return;
|
|
12524
|
+
const parsed = previous?.errors?.[i];
|
|
12525
|
+
if (error.stack && parsed?.stacks && parsed.stack === error.stack) {
|
|
12526
|
+
error.stacks = parsed.stacks;
|
|
12527
|
+
return;
|
|
12528
|
+
}
|
|
12313
12529
|
const project = this.vitest.getProjectByName(task.file.projectName || "");
|
|
12314
12530
|
if (isBrowser) error.stacks = project.browser?.parseErrorStacktrace(error, { frameFilter: project.config.onStackTrace }) || [];
|
|
12315
12531
|
else error.stacks = parseErrorStacktrace(error, {
|
|
12316
12532
|
frameFilter: project.config.onStackTrace,
|
|
12317
|
-
getSourceMap: (file) => getExternalSourceMap(project, file)
|
|
12533
|
+
getSourceMap: (file) => this.getExternalSourceMap(project, file)
|
|
12318
12534
|
});
|
|
12319
12535
|
});
|
|
12320
12536
|
});
|
|
12321
12537
|
}
|
|
12538
|
+
getExternalSourceMap(project, file) {
|
|
12539
|
+
if (project.vite.moduleGraph.getModuleById(file)?.transformResult) return;
|
|
12540
|
+
if (!this.externalSourceMaps.has(file)) {
|
|
12541
|
+
const map = existsSync(file) ? extractSourcemapFromFile(readFileSync(file, "utf-8"), file)?.map : void 0;
|
|
12542
|
+
this.externalSourceMaps.set(file, map);
|
|
12543
|
+
}
|
|
12544
|
+
return this.externalSourceMaps.get(file);
|
|
12545
|
+
}
|
|
12322
12546
|
async reportEvent(id, event, data) {
|
|
12323
12547
|
const task = this.vitest.state.idMap.get(id);
|
|
12324
12548
|
const entity = task && this.vitest.state.getReportedEntity(task);
|
|
@@ -12373,7 +12597,8 @@ class TestRun {
|
|
|
12373
12597
|
if (path && !path.startsWith("http://") && !path.startsWith("https://")) {
|
|
12374
12598
|
const currentPath = resolve(project.config.root, path);
|
|
12375
12599
|
const hash = createHash("sha1").update(currentPath).digest("hex");
|
|
12376
|
-
const
|
|
12600
|
+
const suffix = this.getProjectSuffix(project, currentPath);
|
|
12601
|
+
const newPath = resolve(project.config.attachmentsDir, `${filename ? `${sanitizeFilePath(filename)}-` : ""}${hash}${suffix}${extname(currentPath)}`);
|
|
12377
12602
|
if (!existsSync(project.config.attachmentsDir)) await mkdir(project.config.attachmentsDir, { recursive: true });
|
|
12378
12603
|
await copyFile(currentPath, newPath);
|
|
12379
12604
|
attachment.path = newPath;
|
|
@@ -12381,6 +12606,22 @@ class TestRun {
|
|
|
12381
12606
|
}
|
|
12382
12607
|
return attachment;
|
|
12383
12608
|
}
|
|
12609
|
+
// the copies of a file that other projects attach get the project name,
|
|
12610
|
+
// so each project keeps its own copy
|
|
12611
|
+
getProjectSuffix(project, path) {
|
|
12612
|
+
const firstProject = this.attachmentProjects.get(path);
|
|
12613
|
+
if (firstProject === void 0) {
|
|
12614
|
+
this.attachmentProjects.set(path, project.name);
|
|
12615
|
+
return "";
|
|
12616
|
+
}
|
|
12617
|
+
if (firstProject === project.name) return "";
|
|
12618
|
+
const pair = `${firstProject}\0${project.name}`;
|
|
12619
|
+
if (!this.warnedProjectPairs.has(pair)) {
|
|
12620
|
+
this.warnedProjectPairs.add(pair);
|
|
12621
|
+
this.vitest.logger.warn(withLabel("yellow", "Vitest", `The projects "${firstProject}" and "${project.name}" attach the same file "${relative(this.vitest.config.root, path)}", so they can overwrite each other's file. Save the file to a different path in each project.`));
|
|
12622
|
+
}
|
|
12623
|
+
return `-${sanitizeFilePath(project.name)}`;
|
|
12624
|
+
}
|
|
12384
12625
|
async reportChildren(children) {
|
|
12385
12626
|
for (const child of children) if (child.type === "test") {
|
|
12386
12627
|
await this.vitest.report("onTestCaseReady", child);
|
|
@@ -12392,12 +12633,6 @@ class TestRun {
|
|
|
12392
12633
|
}
|
|
12393
12634
|
}
|
|
12394
12635
|
}
|
|
12395
|
-
function getExternalSourceMap(project, file) {
|
|
12396
|
-
if (!project.vite.moduleGraph.getModuleById(file)?.transformResult && existsSync(file)) {
|
|
12397
|
-
const code = readFileSync(file, "utf-8");
|
|
12398
|
-
return extractSourcemapFromFile(code, file)?.map;
|
|
12399
|
-
}
|
|
12400
|
-
}
|
|
12401
12636
|
|
|
12402
12637
|
class GitVCSProvider {
|
|
12403
12638
|
root;
|
|
@@ -12788,6 +13023,7 @@ class Vitest {
|
|
|
12788
13023
|
*/
|
|
12789
13024
|
_rootBrowserParent;
|
|
12790
13025
|
/** @internal */ _browserSessions = new BrowserSessions();
|
|
13026
|
+
/** @internal */ _browserCacheStale = false;
|
|
12791
13027
|
/** @internal */ reporters = [];
|
|
12792
13028
|
/** @internal */ runner;
|
|
12793
13029
|
/** @internal */ _testRun;
|
|
@@ -12802,6 +13038,7 @@ class Vitest {
|
|
|
12802
13038
|
restartsCount = 0;
|
|
12803
13039
|
specifications;
|
|
12804
13040
|
pool;
|
|
13041
|
+
sequencer;
|
|
12805
13042
|
_coverageProvider;
|
|
12806
13043
|
/**
|
|
12807
13044
|
* @deprecated Do not rely on this property, it's always `test`. Scheduled to be removed in the next major.
|
|
@@ -12838,9 +13075,15 @@ class Vitest {
|
|
|
12838
13075
|
_setRootConfig(config) {
|
|
12839
13076
|
this.watcher.unregisterWatcher();
|
|
12840
13077
|
clearTimeout(this._rerunTimer);
|
|
13078
|
+
// the rerun timer is the only place that clears these sets. If a restart
|
|
13079
|
+
// cancels the timer, `handleFileChanged` ignores every later change of the
|
|
13080
|
+
// files that are still in the sets.
|
|
13081
|
+
this.watcher.changedTests.clear();
|
|
13082
|
+
this.watcher.invalidates.clear();
|
|
12841
13083
|
this.restartsCount += 1;
|
|
12842
13084
|
this.pool?.close?.();
|
|
12843
13085
|
this.pool = void 0;
|
|
13086
|
+
this.sequencer = void 0;
|
|
12844
13087
|
this.closingPromise = void 0;
|
|
12845
13088
|
this.projects = [];
|
|
12846
13089
|
this.runningPromise = void 0;
|
|
@@ -13215,7 +13458,7 @@ class Vitest {
|
|
|
13215
13458
|
return this._traces.$("vitest.collect", async (collectSpan) => {
|
|
13216
13459
|
const filenamePattern = filters && filters?.length > 0 ? filters : [];
|
|
13217
13460
|
collectSpan.setAttribute("vitest.collect.filters", filenamePattern);
|
|
13218
|
-
|
|
13461
|
+
let files = await this._traces.$("vitest.config.resolve_include_glob", async () => {
|
|
13219
13462
|
const specifications = await this.specifications.getRelevantTestSpecifications(filters);
|
|
13220
13463
|
collectSpan.setAttribute("vitest.collect.specifications", specifications.map((s) => {
|
|
13221
13464
|
const relativeModuleId = relative(s.project.config.root, s.moduleId);
|
|
@@ -13224,6 +13467,7 @@ class Vitest {
|
|
|
13224
13467
|
}));
|
|
13225
13468
|
return specifications;
|
|
13226
13469
|
});
|
|
13470
|
+
files = await this._shardSpecifications(files);
|
|
13227
13471
|
// if run with --changed, don't exit if no tests are found
|
|
13228
13472
|
if (!files.length) return {
|
|
13229
13473
|
testModules: [],
|
|
@@ -13277,13 +13521,7 @@ class Vitest {
|
|
|
13277
13521
|
}));
|
|
13278
13522
|
return specifications;
|
|
13279
13523
|
});
|
|
13280
|
-
|
|
13281
|
-
// This populates specification.testModule with parsed information
|
|
13282
|
-
await this.parseSpecifications(specifications);
|
|
13283
|
-
specifications = specifications.filter(({ testModule }) => {
|
|
13284
|
-
return !testModule || testModule.task.mode !== "skip";
|
|
13285
|
-
});
|
|
13286
|
-
}
|
|
13524
|
+
specifications = this.config.experimental.preParse ? await this.preParseSpecifications(specifications) : await this._shardSpecifications(specifications);
|
|
13287
13525
|
// if run with --changed or --last-failed, don't exit if no tests are found
|
|
13288
13526
|
if (!specifications.length) {
|
|
13289
13527
|
await this._traces.$("vitest.test_run", async () => {
|
|
@@ -13410,9 +13648,20 @@ class Vitest {
|
|
|
13410
13648
|
this.snapshot.clear();
|
|
13411
13649
|
this.state.clearErrors();
|
|
13412
13650
|
if (!this.isFirstRun && this._coverageOptions.cleanOnRerun) await this.coverageProvider?.clean();
|
|
13413
|
-
await this.initializeGlobalSetup(specs);
|
|
13414
13651
|
try {
|
|
13415
|
-
await this.
|
|
13652
|
+
await this.initializeGlobalSetup(specs);
|
|
13653
|
+
} catch (err) {
|
|
13654
|
+
// record the error before `finally` ends the run, otherwise
|
|
13655
|
+
// reporters see no modules and print "No test files found"
|
|
13656
|
+
this.state.catchError(err, "Unhandled Error");
|
|
13657
|
+
return {
|
|
13658
|
+
testModules: [],
|
|
13659
|
+
unhandledErrors: this.state.getUnhandledErrors()
|
|
13660
|
+
};
|
|
13661
|
+
}
|
|
13662
|
+
try {
|
|
13663
|
+
const sorted = await this.getSequencer().sort(specs);
|
|
13664
|
+
await this.pool.runTests(sorted, invalidates);
|
|
13416
13665
|
} catch (err) {
|
|
13417
13666
|
this.state.catchError(err, "Unhandled Error");
|
|
13418
13667
|
}
|
|
@@ -13481,6 +13730,23 @@ class Vitest {
|
|
|
13481
13730
|
return this.parseSpecifications(specifications, options);
|
|
13482
13731
|
}
|
|
13483
13732
|
async parseSpecifications(specifications, options) {
|
|
13733
|
+
return (await this.parseFiles(specifications, options)).map((file, index) => {
|
|
13734
|
+
this.state.collectFiles(specifications[index].project, [file]);
|
|
13735
|
+
return this.state.getReportedEntity(file);
|
|
13736
|
+
});
|
|
13737
|
+
}
|
|
13738
|
+
async preParseSpecifications(specifications) {
|
|
13739
|
+
const files = await this.parseFiles(specifications);
|
|
13740
|
+
const runnable = specifications.filter((_, index) => files[index].mode !== "skip");
|
|
13741
|
+
const sharded = await this._shardSpecifications(runnable);
|
|
13742
|
+
const inShard = new Set(sharded);
|
|
13743
|
+
specifications.forEach((specification, index) => {
|
|
13744
|
+
// files of other shards are not part of this run
|
|
13745
|
+
if (files[index].mode === "skip" || inShard.has(specification)) this.state.collectFiles(specification.project, [files[index]]);
|
|
13746
|
+
});
|
|
13747
|
+
return sharded;
|
|
13748
|
+
}
|
|
13749
|
+
async parseFiles(specifications, options) {
|
|
13484
13750
|
const concurrency = options?.concurrency ?? (typeof os__default.availableParallelism === "function" ? os__default.availableParallelism() : os__default.cpus().length);
|
|
13485
13751
|
const limit = limitConcurrency(concurrency);
|
|
13486
13752
|
// Phase 1: parse all files in parallel (without mode interpretation)
|
|
@@ -13498,9 +13764,8 @@ class Vitest {
|
|
|
13498
13764
|
for (const { file, specification } of results) {
|
|
13499
13765
|
const config = specification.project.config;
|
|
13500
13766
|
interpretTaskModes(file, config.testNamePattern, specification.testLines, specification.testIds, specification.testNames, tagsFilter, globalHasOnly, false, config.allowOnly);
|
|
13501
|
-
this.state.collectFiles(specification.project, [file]);
|
|
13502
13767
|
}
|
|
13503
|
-
return results.map(({ file }) =>
|
|
13768
|
+
return results.map(({ file }) => file);
|
|
13504
13769
|
}
|
|
13505
13770
|
async experimental_parseSpecification(specification) {
|
|
13506
13771
|
const file = await astCollectTests(specification.project, specification.moduleId).catch((error) => {
|
|
@@ -13535,7 +13800,8 @@ class Vitest {
|
|
|
13535
13800
|
this.state.clearErrors();
|
|
13536
13801
|
await this.initializeGlobalSetup(specifications);
|
|
13537
13802
|
try {
|
|
13538
|
-
await this.
|
|
13803
|
+
const sorted = await this.getSequencer().sort(specifications);
|
|
13804
|
+
await this.pool.collectTests(sorted, invalidates);
|
|
13539
13805
|
} catch (err) {
|
|
13540
13806
|
this.state.catchError(err, "Unhandled Error");
|
|
13541
13807
|
}
|
|
@@ -13566,6 +13832,20 @@ class Vitest {
|
|
|
13566
13832
|
await this.cancelPromise.finally(() => this.cancelPromise = void 0);
|
|
13567
13833
|
await this.runningPromise;
|
|
13568
13834
|
}
|
|
13835
|
+
getSequencer() {
|
|
13836
|
+
if (!this.sequencer) {
|
|
13837
|
+
const Sequencer = this.config.sequence.sequencer;
|
|
13838
|
+
this.sequencer = new Sequencer(this);
|
|
13839
|
+
}
|
|
13840
|
+
return this.sequencer;
|
|
13841
|
+
}
|
|
13842
|
+
/** @internal */
|
|
13843
|
+
async _shardSpecifications(specifications) {
|
|
13844
|
+
const shard = this.config.shard;
|
|
13845
|
+
if (!shard) return specifications;
|
|
13846
|
+
if (!this.config.passWithNoTests && shard.count > specifications.length) throw new Error(`--shard <count> must be a smaller than count of test files. Resolved ${specifications.length} test files for --shard=${shard.index}/${shard.count}.`);
|
|
13847
|
+
return this.getSequencer().shard(Array.from(specifications));
|
|
13848
|
+
}
|
|
13569
13849
|
async initializeGlobalSetup(paths) {
|
|
13570
13850
|
const projects = new Set(paths.map((spec) => spec.project));
|
|
13571
13851
|
const coreProject = this.getRootProject();
|
|
@@ -13728,6 +14008,9 @@ class Vitest {
|
|
|
13728
14008
|
*/
|
|
13729
14009
|
invalidateFile(filepath) {
|
|
13730
14010
|
this.specifications.invalidateDocblock(filepath);
|
|
14011
|
+
// during `vitest run` the browser takes modules from its HTTP cache without asking the
|
|
14012
|
+
// server, so the browser pool opens new contexts before the next run
|
|
14013
|
+
if (!this.config.watch) this._browserCacheStale = true;
|
|
13731
14014
|
this.projects.forEach(({ vite }) => {
|
|
13732
14015
|
Object.values(vite.environments).forEach((environment) => {
|
|
13733
14016
|
const { moduleGraph } = environment;
|