vitest 2.0.3 → 2.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/dist/browser.d.ts +21 -42
- package/dist/browser.js +5 -5
- package/dist/{vendor/base.CC6UHsNs.js → chunks/base.CC5R_kgU.js} +3 -3
- package/dist/{vendor/base.CTYV4Gnz.js → chunks/base.DSsbfkDg.js} +5 -4
- package/dist/{vendor/benchmark.B6pblCp2.js → chunks/benchmark.DDmpNjj-.js} +1 -1
- package/dist/chunks/benchmark.puBFxyfE.d.ts +22 -0
- package/dist/{vendor/cac.DUiZvzF_.js → chunks/cac.DGgmCKmU.js} +18 -21
- package/dist/{vendor/cli-api.CsgSG1Ir.js → chunks/cli-api.OKfd3qJ0.js} +666 -487
- package/dist/chunks/config.DCnyCTbs.d.ts +203 -0
- package/dist/chunks/{runtime-console.C2L2zykk.js → console.Bgn7_A1x.js} +11 -14
- package/dist/{vendor/constants.CsnA4eRy.js → chunks/constants.CaAN7icJ.js} +1 -3
- package/dist/{vendor/coverage.BhYSDdTT.js → chunks/coverage.CqfT4xaf.js} +4 -7
- package/dist/chunks/{browser-creator.CyaOd8pl.js → creator.a3OfuIEW.js} +8 -8
- package/dist/{vendor/env.2ltrQNq0.js → chunks/env.BU041cs9.js} +2 -3
- package/dist/chunks/environment.0M5R1SX_.d.ts +173 -0
- package/dist/{vendor/execute.Dx503nGn.js → chunks/execute.Cjlr2CRw.js} +28 -20
- package/dist/chunks/globals.BliuJFNR.js +31 -0
- package/dist/{vendor/index.Hqvcg1pf.js → chunks/index.BfeNhc0N.js} +43 -43
- package/dist/{vendor/index.D6GZqexG.js → chunks/index.CM5UI-4O.js} +2 -2
- package/dist/{vendor/index.BJmtb_7W.js → chunks/index.DYufA6CZ.js} +2 -2
- package/dist/{vendor/index.BCwvoAaf.js → chunks/index.JbiJutJ_.js} +516 -258
- package/dist/{vendor/index.CROIsoiT.js → chunks/index.R1VjssW9.js} +11 -12
- package/dist/{vendor/index.D4nqnQWz.js → chunks/index.lVXYBqEP.js} +1 -18
- package/dist/{vendor/inspector.-FCQUzqR.js → chunks/inspector.70d6emsh.js} +4 -5
- package/dist/chunks/{environments-node.XE5FbRPQ.js → node.DS3zEPa7.js} +2 -2
- package/dist/{reporters-BECoY4-b.d.ts → chunks/reporters.C_zwCd4j.d.ts} +850 -1003
- package/dist/{vendor/rpc.BGx7q_k2.js → chunks/rpc.B7Mfb-Yf.js} +3 -5
- package/dist/{vendor/run-once.Db8Hgq9X.js → chunks/run-once.Sxe67Wng.js} +1 -1
- package/dist/chunks/{runtime-runBaseTests.hkIOeriM.js → runBaseTests.CyvqmuC9.js} +35 -27
- package/dist/{vendor/setup-common.yHaxjRhz.js → chunks/setup-common.CNzatKMx.js} +2 -2
- package/dist/{suite-BWgaIsVn.d.ts → chunks/suite.CcK46U-P.d.ts} +1 -1
- package/dist/{vendor/tasks.DhVtQBtW.js → chunks/tasks.BZnCS9aT.js} +2 -3
- package/dist/{vendor/utils.DkxLWvS1.js → chunks/utils.C3_cBsyn.js} +3 -4
- package/dist/{vendor/global.7bFbnyXl.js → chunks/utils.Ck2hJTRs.js} +1 -1
- package/dist/{vendor/utils.DyTe1Nxn.js → chunks/utils.DpP_sDwr.js} +8 -21
- package/dist/{vendor/vi.DXACdGTu.js → chunks/vi.fiQ7lMRF.js} +13 -18
- package/dist/{vendor/vm.D1T5Rxan.js → chunks/vm.DcSuuaHr.js} +40 -68
- package/dist/chunks/worker.C5iHKIaJ.d.ts +144 -0
- package/dist/chunks/worker.DKkAC4Qw.d.ts +8 -0
- package/dist/cli.js +3 -3
- package/dist/config.cjs +6 -9
- package/dist/config.d.ts +10 -8
- package/dist/config.js +6 -9
- package/dist/coverage.d.ts +10 -8
- package/dist/coverage.js +11 -7
- package/dist/environments.d.ts +3 -19
- package/dist/environments.js +1 -1
- package/dist/execute.d.ts +8 -17
- package/dist/execute.js +2 -2
- package/dist/index.d.ts +267 -34
- package/dist/index.js +12 -12
- package/dist/node.d.ts +15 -9
- package/dist/node.js +16 -19
- package/dist/reporters.d.ts +10 -8
- package/dist/reporters.js +12 -15
- package/dist/runners.d.ts +7 -19
- package/dist/runners.js +12 -13
- package/dist/snapshot.js +3 -3
- package/dist/suite.d.ts +2 -16
- package/dist/suite.js +4 -4
- package/dist/worker.js +7 -8
- package/dist/workers/forks.js +5 -5
- package/dist/workers/runVmTests.js +32 -23
- package/dist/workers/threads.js +5 -5
- package/dist/workers/vmForks.js +8 -8
- package/dist/workers/vmThreads.js +8 -8
- package/dist/workers.d.ts +13 -8
- package/dist/workers.js +13 -13
- package/package.json +15 -15
- package/dist/chunks/integrations-globals.CzYWb38r.js +0 -31
- /package/dist/{vendor → chunks}/_commonjsHelpers.BFTU3MAI.js +0 -0
- /package/dist/{vendor → chunks}/date.W2xKR2qe.js +0 -0
- /package/dist/chunks/{node-git.ZtkbKc8u.js → git.ZtkbKc8u.js} +0 -0
- /package/dist/{vendor → chunks}/index.BMmMjLIQ.js +0 -0
- /package/dist/{vendor → chunks}/index.BpSiYbpB.js +0 -0
- /package/dist/chunks/{install-pkg.DNUmWFkO.js → index.DNUmWFkO.js} +0 -0
- /package/dist/{vendor → chunks}/spy.Cf_4R5Oe.js +0 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import fs$8, { existsSync, promises as promises$1, statSync as statSync$1, realpathSync, readFileSync, mkdirSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { join, resolve, isAbsolute, relative, dirname, normalize, basename, toNamespacedPath } from 'pathe';
|
|
3
|
-
import { g as getCoverageProvider, C as CoverageProviderMap } from './coverage.
|
|
4
|
-
import { g as getEnvPackageName } from './index.D4nqnQWz.js';
|
|
3
|
+
import { g as getCoverageProvider, C as CoverageProviderMap } from './coverage.CqfT4xaf.js';
|
|
5
4
|
import { searchForWorkspaceRoot, version, createServer, mergeConfig } from 'vite';
|
|
6
|
-
import { f as findUp, p as prompt } from './index.
|
|
7
|
-
import { A as API_PATH, e as extraInlineDeps, d as defaultPort, a as defaultBrowserPort, b as defaultInspectPort, w as workspacesFiles, C as CONFIG_NAMES, c as configFiles } from './constants.
|
|
5
|
+
import { f as findUp, p as prompt } from './index.CM5UI-4O.js';
|
|
6
|
+
import { A as API_PATH, e as extraInlineDeps, d as defaultPort, a as defaultBrowserPort, b as defaultInspectPort, w as workspacesFiles, C as CONFIG_NAMES, c as configFiles } from './constants.CaAN7icJ.js';
|
|
8
7
|
import { MessageChannel, isMainThread } from 'node:worker_threads';
|
|
9
8
|
import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers.BFTU3MAI.js';
|
|
10
9
|
import require$$0 from 'os';
|
|
@@ -17,14 +16,14 @@ import require$$0$3 from 'fs';
|
|
|
17
16
|
import { ViteNodeRunner } from 'vite-node/client';
|
|
18
17
|
import { SnapshotManager } from '@vitest/snapshot/manager';
|
|
19
18
|
import { ViteNodeServer } from 'vite-node/server';
|
|
20
|
-
import { v as version$1 } from './cac.
|
|
19
|
+
import { v as version$1 } from './cac.DGgmCKmU.js';
|
|
21
20
|
import { hasFailed, createFileTask, getTasks, getTests, getNames } from '@vitest/runner/utils';
|
|
22
|
-
import { n as noop$1, b as isPrimitive, c as groupBy, A as AggregateErrorPonyfill, a as slash$1, t as toArray, d as deepMerge, e as nanoid, w as wildcardPatternToRegExp, f as stdout } from './base.
|
|
21
|
+
import { n as noop$1, b as isPrimitive, c as groupBy, A as AggregateErrorPonyfill, a as slash$1, t as toArray, d as deepMerge, e as nanoid, w as wildcardPatternToRegExp, f as stdout } from './base.DSsbfkDg.js';
|
|
23
22
|
import { createDefer, toArray as toArray$1, notNullish } from '@vitest/utils';
|
|
24
|
-
import { b as isWindows } from './env.
|
|
23
|
+
import { b as isWindows } from './env.BU041cs9.js';
|
|
25
24
|
import { rootDir, distDir } from '../path.js';
|
|
26
25
|
import { c as createBirpc } from './index.BpSiYbpB.js';
|
|
27
|
-
import { s as stringify, p as parse$3, w as wrapSerializableConfig,
|
|
26
|
+
import { s as stringify, p as parse$3, w as wrapSerializableConfig, j as Typechecker, R as ReportersMap, g as BenchmarkReportsMap, e as TestFile, f as TestSuite, d as TestCase, k as RandomSequencer, h as BaseSequencer, l as findNodeAround, m as generateCodeFrame, n as highlightCode, i as TestProject, L as Logger, o as BlobReporter, r as readBlobs } from './index.JbiJutJ_.js';
|
|
28
27
|
import require$$0$5 from 'zlib';
|
|
29
28
|
import require$$0$6 from 'buffer';
|
|
30
29
|
import require$$1 from 'crypto';
|
|
@@ -52,9 +51,9 @@ import { isCI, provider as provider$1 } from 'std-env';
|
|
|
52
51
|
import { normalizeRequestId, cleanUrl } from 'vite-node/utils';
|
|
53
52
|
import MagicString from 'magic-string';
|
|
54
53
|
import { esmWalker } from '@vitest/utils/ast';
|
|
55
|
-
import { a as removeUndefinedValues } from './index.
|
|
54
|
+
import { a as removeUndefinedValues } from './index.DYufA6CZ.js';
|
|
56
55
|
import readline from 'node:readline';
|
|
57
|
-
import { s as stripAnsi } from './utils.
|
|
56
|
+
import { s as stripAnsi } from './utils.DpP_sDwr.js';
|
|
58
57
|
|
|
59
58
|
async function getModuleGraph(ctx, projectName, id, browser = false) {
|
|
60
59
|
const graph = {};
|
|
@@ -62,10 +61,9 @@ async function getModuleGraph(ctx, projectName, id, browser = false) {
|
|
|
62
61
|
const inlined = /* @__PURE__ */ new Set();
|
|
63
62
|
const project = ctx.getProjectByName(projectName);
|
|
64
63
|
function clearId(id2) {
|
|
65
|
-
return
|
|
64
|
+
return id2?.replace(/\?v=\w+$/, "") || "";
|
|
66
65
|
}
|
|
67
66
|
async function get(mod, seen = /* @__PURE__ */ new Map()) {
|
|
68
|
-
var _a;
|
|
69
67
|
if (!mod || !mod.id) {
|
|
70
68
|
return;
|
|
71
69
|
}
|
|
@@ -77,7 +75,7 @@ async function getModuleGraph(ctx, projectName, id, browser = false) {
|
|
|
77
75
|
}
|
|
78
76
|
let id2 = clearId(mod.id);
|
|
79
77
|
seen.set(mod, id2);
|
|
80
|
-
const rewrote = browser ?
|
|
78
|
+
const rewrote = browser ? mod.file?.includes(project.browser.vite.config.cacheDir) ? mod.id : false : await project.vitenode.shouldExternalize(id2);
|
|
81
79
|
if (rewrote) {
|
|
82
80
|
id2 = rewrote;
|
|
83
81
|
externalized.add(id2);
|
|
@@ -3358,10 +3356,16 @@ var fg = /*@__PURE__*/getDefaultExportFromCjs(out);
|
|
|
3358
3356
|
|
|
3359
3357
|
var bufferUtil$1 = {exports: {}};
|
|
3360
3358
|
|
|
3359
|
+
const BINARY_TYPES$2 = ['nodebuffer', 'arraybuffer', 'fragments'];
|
|
3360
|
+
const hasBlob$1 = typeof Blob !== 'undefined';
|
|
3361
|
+
|
|
3362
|
+
if (hasBlob$1) BINARY_TYPES$2.push('blob');
|
|
3363
|
+
|
|
3361
3364
|
var constants = {
|
|
3362
|
-
BINARY_TYPES:
|
|
3365
|
+
BINARY_TYPES: BINARY_TYPES$2,
|
|
3363
3366
|
EMPTY_BUFFER: Buffer.alloc(0),
|
|
3364
3367
|
GUID: '258EAFA5-E914-47DA-95CA-C5AB0DC85B11',
|
|
3368
|
+
hasBlob: hasBlob$1,
|
|
3365
3369
|
kForOnEventAttribute: Symbol('kIsForOnEventAttribute'),
|
|
3366
3370
|
kListener: Symbol('kListener'),
|
|
3367
3371
|
kStatusCode: Symbol('status-code'),
|
|
@@ -4077,6 +4081,8 @@ var isValidUTF8_1;
|
|
|
4077
4081
|
|
|
4078
4082
|
const { isUtf8 } = require$$0$6;
|
|
4079
4083
|
|
|
4084
|
+
const { hasBlob } = constants;
|
|
4085
|
+
|
|
4080
4086
|
//
|
|
4081
4087
|
// Allowed token characters:
|
|
4082
4088
|
//
|
|
@@ -4182,7 +4188,27 @@ function _isValidUTF8(buf) {
|
|
|
4182
4188
|
return true;
|
|
4183
4189
|
}
|
|
4184
4190
|
|
|
4191
|
+
/**
|
|
4192
|
+
* Determines whether a value is a `Blob`.
|
|
4193
|
+
*
|
|
4194
|
+
* @param {*} value The value to be tested
|
|
4195
|
+
* @return {Boolean} `true` if `value` is a `Blob`, else `false`
|
|
4196
|
+
* @private
|
|
4197
|
+
*/
|
|
4198
|
+
function isBlob$2(value) {
|
|
4199
|
+
return (
|
|
4200
|
+
hasBlob &&
|
|
4201
|
+
typeof value === 'object' &&
|
|
4202
|
+
typeof value.arrayBuffer === 'function' &&
|
|
4203
|
+
typeof value.type === 'string' &&
|
|
4204
|
+
typeof value.stream === 'function' &&
|
|
4205
|
+
(value[Symbol.toStringTag] === 'Blob' ||
|
|
4206
|
+
value[Symbol.toStringTag] === 'File')
|
|
4207
|
+
);
|
|
4208
|
+
}
|
|
4209
|
+
|
|
4185
4210
|
validation.exports = {
|
|
4211
|
+
isBlob: isBlob$2,
|
|
4186
4212
|
isValidStatusCode: isValidStatusCode$2,
|
|
4187
4213
|
isValidUTF8: _isValidUTF8,
|
|
4188
4214
|
tokenChars: tokenChars$2
|
|
@@ -4213,7 +4239,7 @@ const {
|
|
|
4213
4239
|
BINARY_TYPES: BINARY_TYPES$1,
|
|
4214
4240
|
EMPTY_BUFFER: EMPTY_BUFFER$2,
|
|
4215
4241
|
kStatusCode: kStatusCode$1,
|
|
4216
|
-
kWebSocket: kWebSocket$
|
|
4242
|
+
kWebSocket: kWebSocket$3
|
|
4217
4243
|
} = constants;
|
|
4218
4244
|
const { concat, toArrayBuffer, unmask } = bufferUtilExports;
|
|
4219
4245
|
const { isValidStatusCode: isValidStatusCode$1, isValidUTF8 } = validationExports;
|
|
@@ -4262,7 +4288,7 @@ let Receiver$1 = class Receiver extends Writable {
|
|
|
4262
4288
|
this._isServer = !!options.isServer;
|
|
4263
4289
|
this._maxPayload = options.maxPayload | 0;
|
|
4264
4290
|
this._skipUTF8Validation = !!options.skipUTF8Validation;
|
|
4265
|
-
this[kWebSocket$
|
|
4291
|
+
this[kWebSocket$3] = undefined;
|
|
4266
4292
|
|
|
4267
4293
|
this._bufferedBytes = 0;
|
|
4268
4294
|
this._buffers = [];
|
|
@@ -4765,6 +4791,8 @@ let Receiver$1 = class Receiver extends Writable {
|
|
|
4765
4791
|
data = concat(fragments, messageLength);
|
|
4766
4792
|
} else if (this._binaryType === 'arraybuffer') {
|
|
4767
4793
|
data = toArrayBuffer(concat(fragments, messageLength));
|
|
4794
|
+
} else if (this._binaryType === 'blob') {
|
|
4795
|
+
data = new Blob(fragments);
|
|
4768
4796
|
} else {
|
|
4769
4797
|
data = fragments;
|
|
4770
4798
|
}
|
|
@@ -4913,8 +4941,8 @@ var receiver = Receiver$1;
|
|
|
4913
4941
|
const { randomFillSync } = require$$1;
|
|
4914
4942
|
|
|
4915
4943
|
const PerMessageDeflate$2 = permessageDeflate;
|
|
4916
|
-
const { EMPTY_BUFFER: EMPTY_BUFFER$1 } = constants;
|
|
4917
|
-
const { isValidStatusCode } = validationExports;
|
|
4944
|
+
const { EMPTY_BUFFER: EMPTY_BUFFER$1, kWebSocket: kWebSocket$2, NOOP: NOOP$1 } = constants;
|
|
4945
|
+
const { isBlob: isBlob$1, isValidStatusCode } = validationExports;
|
|
4918
4946
|
const { mask: applyMask, toBuffer: toBuffer$1 } = bufferUtilExports;
|
|
4919
4947
|
|
|
4920
4948
|
const kByteLength = Symbol('kByteLength');
|
|
@@ -4923,6 +4951,10 @@ const RANDOM_POOL_SIZE = 8 * 1024;
|
|
|
4923
4951
|
let randomPool;
|
|
4924
4952
|
let randomPoolPointer = RANDOM_POOL_SIZE;
|
|
4925
4953
|
|
|
4954
|
+
const DEFAULT = 0;
|
|
4955
|
+
const DEFLATING = 1;
|
|
4956
|
+
const GET_BLOB_DATA = 2;
|
|
4957
|
+
|
|
4926
4958
|
/**
|
|
4927
4959
|
* HyBi Sender implementation.
|
|
4928
4960
|
*/
|
|
@@ -4949,8 +4981,10 @@ let Sender$1 = class Sender {
|
|
|
4949
4981
|
this._compress = false;
|
|
4950
4982
|
|
|
4951
4983
|
this._bufferedBytes = 0;
|
|
4952
|
-
this._deflating = false;
|
|
4953
4984
|
this._queue = [];
|
|
4985
|
+
this._state = DEFAULT;
|
|
4986
|
+
this.onerror = NOOP$1;
|
|
4987
|
+
this[kWebSocket$2] = undefined;
|
|
4954
4988
|
}
|
|
4955
4989
|
|
|
4956
4990
|
/**
|
|
@@ -5117,7 +5151,7 @@ let Sender$1 = class Sender {
|
|
|
5117
5151
|
rsv1: false
|
|
5118
5152
|
};
|
|
5119
5153
|
|
|
5120
|
-
if (this.
|
|
5154
|
+
if (this._state !== DEFAULT) {
|
|
5121
5155
|
this.enqueue([this.dispatch, buf, false, options, cb]);
|
|
5122
5156
|
} else {
|
|
5123
5157
|
this.sendFrame(Sender.frame(buf, options), cb);
|
|
@@ -5139,6 +5173,9 @@ let Sender$1 = class Sender {
|
|
|
5139
5173
|
if (typeof data === 'string') {
|
|
5140
5174
|
byteLength = Buffer.byteLength(data);
|
|
5141
5175
|
readOnly = false;
|
|
5176
|
+
} else if (isBlob$1(data)) {
|
|
5177
|
+
byteLength = data.size;
|
|
5178
|
+
readOnly = false;
|
|
5142
5179
|
} else {
|
|
5143
5180
|
data = toBuffer$1(data);
|
|
5144
5181
|
byteLength = data.length;
|
|
@@ -5160,7 +5197,13 @@ let Sender$1 = class Sender {
|
|
|
5160
5197
|
rsv1: false
|
|
5161
5198
|
};
|
|
5162
5199
|
|
|
5163
|
-
if (
|
|
5200
|
+
if (isBlob$1(data)) {
|
|
5201
|
+
if (this._state !== DEFAULT) {
|
|
5202
|
+
this.enqueue([this.getBlobData, data, false, options, cb]);
|
|
5203
|
+
} else {
|
|
5204
|
+
this.getBlobData(data, false, options, cb);
|
|
5205
|
+
}
|
|
5206
|
+
} else if (this._state !== DEFAULT) {
|
|
5164
5207
|
this.enqueue([this.dispatch, data, false, options, cb]);
|
|
5165
5208
|
} else {
|
|
5166
5209
|
this.sendFrame(Sender.frame(data, options), cb);
|
|
@@ -5182,6 +5225,9 @@ let Sender$1 = class Sender {
|
|
|
5182
5225
|
if (typeof data === 'string') {
|
|
5183
5226
|
byteLength = Buffer.byteLength(data);
|
|
5184
5227
|
readOnly = false;
|
|
5228
|
+
} else if (isBlob$1(data)) {
|
|
5229
|
+
byteLength = data.size;
|
|
5230
|
+
readOnly = false;
|
|
5185
5231
|
} else {
|
|
5186
5232
|
data = toBuffer$1(data);
|
|
5187
5233
|
byteLength = data.length;
|
|
@@ -5203,7 +5249,13 @@ let Sender$1 = class Sender {
|
|
|
5203
5249
|
rsv1: false
|
|
5204
5250
|
};
|
|
5205
5251
|
|
|
5206
|
-
if (
|
|
5252
|
+
if (isBlob$1(data)) {
|
|
5253
|
+
if (this._state !== DEFAULT) {
|
|
5254
|
+
this.enqueue([this.getBlobData, data, false, options, cb]);
|
|
5255
|
+
} else {
|
|
5256
|
+
this.getBlobData(data, false, options, cb);
|
|
5257
|
+
}
|
|
5258
|
+
} else if (this._state !== DEFAULT) {
|
|
5207
5259
|
this.enqueue([this.dispatch, data, false, options, cb]);
|
|
5208
5260
|
} else {
|
|
5209
5261
|
this.sendFrame(Sender.frame(data, options), cb);
|
|
@@ -5237,6 +5289,9 @@ let Sender$1 = class Sender {
|
|
|
5237
5289
|
if (typeof data === 'string') {
|
|
5238
5290
|
byteLength = Buffer.byteLength(data);
|
|
5239
5291
|
readOnly = false;
|
|
5292
|
+
} else if (isBlob$1(data)) {
|
|
5293
|
+
byteLength = data.size;
|
|
5294
|
+
readOnly = false;
|
|
5240
5295
|
} else {
|
|
5241
5296
|
data = toBuffer$1(data);
|
|
5242
5297
|
byteLength = data.length;
|
|
@@ -5264,40 +5319,94 @@ let Sender$1 = class Sender {
|
|
|
5264
5319
|
|
|
5265
5320
|
if (options.fin) this._firstFragment = true;
|
|
5266
5321
|
|
|
5267
|
-
|
|
5268
|
-
|
|
5269
|
-
|
|
5270
|
-
|
|
5271
|
-
|
|
5272
|
-
|
|
5273
|
-
|
|
5274
|
-
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
};
|
|
5322
|
+
const opts = {
|
|
5323
|
+
[kByteLength]: byteLength,
|
|
5324
|
+
fin: options.fin,
|
|
5325
|
+
generateMask: this._generateMask,
|
|
5326
|
+
mask: options.mask,
|
|
5327
|
+
maskBuffer: this._maskBuffer,
|
|
5328
|
+
opcode,
|
|
5329
|
+
readOnly,
|
|
5330
|
+
rsv1
|
|
5331
|
+
};
|
|
5278
5332
|
|
|
5279
|
-
|
|
5280
|
-
|
|
5333
|
+
if (isBlob$1(data)) {
|
|
5334
|
+
if (this._state !== DEFAULT) {
|
|
5335
|
+
this.enqueue([this.getBlobData, data, this._compress, opts, cb]);
|
|
5281
5336
|
} else {
|
|
5282
|
-
this.
|
|
5337
|
+
this.getBlobData(data, this._compress, opts, cb);
|
|
5283
5338
|
}
|
|
5339
|
+
} else if (this._state !== DEFAULT) {
|
|
5340
|
+
this.enqueue([this.dispatch, data, this._compress, opts, cb]);
|
|
5284
5341
|
} else {
|
|
5285
|
-
this.
|
|
5286
|
-
Sender.frame(data, {
|
|
5287
|
-
[kByteLength]: byteLength,
|
|
5288
|
-
fin: options.fin,
|
|
5289
|
-
generateMask: this._generateMask,
|
|
5290
|
-
mask: options.mask,
|
|
5291
|
-
maskBuffer: this._maskBuffer,
|
|
5292
|
-
opcode,
|
|
5293
|
-
readOnly,
|
|
5294
|
-
rsv1: false
|
|
5295
|
-
}),
|
|
5296
|
-
cb
|
|
5297
|
-
);
|
|
5342
|
+
this.dispatch(data, this._compress, opts, cb);
|
|
5298
5343
|
}
|
|
5299
5344
|
}
|
|
5300
5345
|
|
|
5346
|
+
/**
|
|
5347
|
+
* Gets the contents of a blob as binary data.
|
|
5348
|
+
*
|
|
5349
|
+
* @param {Blob} blob The blob
|
|
5350
|
+
* @param {Boolean} [compress=false] Specifies whether or not to compress
|
|
5351
|
+
* the data
|
|
5352
|
+
* @param {Object} options Options object
|
|
5353
|
+
* @param {Boolean} [options.fin=false] Specifies whether or not to set the
|
|
5354
|
+
* FIN bit
|
|
5355
|
+
* @param {Function} [options.generateMask] The function used to generate the
|
|
5356
|
+
* masking key
|
|
5357
|
+
* @param {Boolean} [options.mask=false] Specifies whether or not to mask
|
|
5358
|
+
* `data`
|
|
5359
|
+
* @param {Buffer} [options.maskBuffer] The buffer used to store the masking
|
|
5360
|
+
* key
|
|
5361
|
+
* @param {Number} options.opcode The opcode
|
|
5362
|
+
* @param {Boolean} [options.readOnly=false] Specifies whether `data` can be
|
|
5363
|
+
* modified
|
|
5364
|
+
* @param {Boolean} [options.rsv1=false] Specifies whether or not to set the
|
|
5365
|
+
* RSV1 bit
|
|
5366
|
+
* @param {Function} [cb] Callback
|
|
5367
|
+
* @private
|
|
5368
|
+
*/
|
|
5369
|
+
getBlobData(blob, compress, options, cb) {
|
|
5370
|
+
this._bufferedBytes += options[kByteLength];
|
|
5371
|
+
this._state = GET_BLOB_DATA;
|
|
5372
|
+
|
|
5373
|
+
blob
|
|
5374
|
+
.arrayBuffer()
|
|
5375
|
+
.then((arrayBuffer) => {
|
|
5376
|
+
if (this._socket.destroyed) {
|
|
5377
|
+
const err = new Error(
|
|
5378
|
+
'The socket was closed while the blob was being read'
|
|
5379
|
+
);
|
|
5380
|
+
|
|
5381
|
+
//
|
|
5382
|
+
// `callCallbacks` is called in the next tick to ensure that errors
|
|
5383
|
+
// that might be thrown in the callbacks behave like errors thrown
|
|
5384
|
+
// outside the promise chain.
|
|
5385
|
+
//
|
|
5386
|
+
process.nextTick(callCallbacks, this, err, cb);
|
|
5387
|
+
return;
|
|
5388
|
+
}
|
|
5389
|
+
|
|
5390
|
+
this._bufferedBytes -= options[kByteLength];
|
|
5391
|
+
const data = toBuffer$1(arrayBuffer);
|
|
5392
|
+
|
|
5393
|
+
if (!compress) {
|
|
5394
|
+
this._state = DEFAULT;
|
|
5395
|
+
this.sendFrame(Sender.frame(data, options), cb);
|
|
5396
|
+
this.dequeue();
|
|
5397
|
+
} else {
|
|
5398
|
+
this.dispatch(data, compress, options, cb);
|
|
5399
|
+
}
|
|
5400
|
+
})
|
|
5401
|
+
.catch((err) => {
|
|
5402
|
+
//
|
|
5403
|
+
// `onError` is called in the next tick for the same reason that
|
|
5404
|
+
// `callCallbacks` above is.
|
|
5405
|
+
//
|
|
5406
|
+
process.nextTick(onError, this, err, cb);
|
|
5407
|
+
});
|
|
5408
|
+
}
|
|
5409
|
+
|
|
5301
5410
|
/**
|
|
5302
5411
|
* Dispatches a message.
|
|
5303
5412
|
*
|
|
@@ -5330,27 +5439,19 @@ let Sender$1 = class Sender {
|
|
|
5330
5439
|
const perMessageDeflate = this._extensions[PerMessageDeflate$2.extensionName];
|
|
5331
5440
|
|
|
5332
5441
|
this._bufferedBytes += options[kByteLength];
|
|
5333
|
-
this.
|
|
5442
|
+
this._state = DEFLATING;
|
|
5334
5443
|
perMessageDeflate.compress(data, options.fin, (_, buf) => {
|
|
5335
5444
|
if (this._socket.destroyed) {
|
|
5336
5445
|
const err = new Error(
|
|
5337
5446
|
'The socket was closed while data was being compressed'
|
|
5338
5447
|
);
|
|
5339
5448
|
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
for (let i = 0; i < this._queue.length; i++) {
|
|
5343
|
-
const params = this._queue[i];
|
|
5344
|
-
const callback = params[params.length - 1];
|
|
5345
|
-
|
|
5346
|
-
if (typeof callback === 'function') callback(err);
|
|
5347
|
-
}
|
|
5348
|
-
|
|
5449
|
+
callCallbacks(this, err, cb);
|
|
5349
5450
|
return;
|
|
5350
5451
|
}
|
|
5351
5452
|
|
|
5352
5453
|
this._bufferedBytes -= options[kByteLength];
|
|
5353
|
-
this.
|
|
5454
|
+
this._state = DEFAULT;
|
|
5354
5455
|
options.readOnly = false;
|
|
5355
5456
|
this.sendFrame(Sender.frame(buf, options), cb);
|
|
5356
5457
|
this.dequeue();
|
|
@@ -5363,7 +5464,7 @@ let Sender$1 = class Sender {
|
|
|
5363
5464
|
* @private
|
|
5364
5465
|
*/
|
|
5365
5466
|
dequeue() {
|
|
5366
|
-
while (
|
|
5467
|
+
while (this._state === DEFAULT && this._queue.length) {
|
|
5367
5468
|
const params = this._queue.shift();
|
|
5368
5469
|
|
|
5369
5470
|
this._bufferedBytes -= params[3][kByteLength];
|
|
@@ -5403,6 +5504,38 @@ let Sender$1 = class Sender {
|
|
|
5403
5504
|
|
|
5404
5505
|
var sender = Sender$1;
|
|
5405
5506
|
|
|
5507
|
+
/**
|
|
5508
|
+
* Calls queued callbacks with an error.
|
|
5509
|
+
*
|
|
5510
|
+
* @param {Sender} sender The `Sender` instance
|
|
5511
|
+
* @param {Error} err The error to call the callbacks with
|
|
5512
|
+
* @param {Function} [cb] The first callback
|
|
5513
|
+
* @private
|
|
5514
|
+
*/
|
|
5515
|
+
function callCallbacks(sender, err, cb) {
|
|
5516
|
+
if (typeof cb === 'function') cb(err);
|
|
5517
|
+
|
|
5518
|
+
for (let i = 0; i < sender._queue.length; i++) {
|
|
5519
|
+
const params = sender._queue[i];
|
|
5520
|
+
const callback = params[params.length - 1];
|
|
5521
|
+
|
|
5522
|
+
if (typeof callback === 'function') callback(err);
|
|
5523
|
+
}
|
|
5524
|
+
}
|
|
5525
|
+
|
|
5526
|
+
/**
|
|
5527
|
+
* Handles a `Sender` error.
|
|
5528
|
+
*
|
|
5529
|
+
* @param {Sender} sender The `Sender` instance
|
|
5530
|
+
* @param {Error} err The error
|
|
5531
|
+
* @param {Function} [cb] The first pending callback
|
|
5532
|
+
* @private
|
|
5533
|
+
*/
|
|
5534
|
+
function onError(sender, err, cb) {
|
|
5535
|
+
callCallbacks(sender, err, cb);
|
|
5536
|
+
sender.onerror(err);
|
|
5537
|
+
}
|
|
5538
|
+
|
|
5406
5539
|
const { kForOnEventAttribute: kForOnEventAttribute$1, kListener: kListener$1 } = constants;
|
|
5407
5540
|
|
|
5408
5541
|
const kCode = Symbol('kCode');
|
|
@@ -5909,6 +6042,8 @@ const { URL: URL$1 } = require$$7;
|
|
|
5909
6042
|
const PerMessageDeflate$1 = permessageDeflate;
|
|
5910
6043
|
const Receiver = receiver;
|
|
5911
6044
|
const Sender = sender;
|
|
6045
|
+
const { isBlob } = validationExports;
|
|
6046
|
+
|
|
5912
6047
|
const {
|
|
5913
6048
|
BINARY_TYPES,
|
|
5914
6049
|
EMPTY_BUFFER,
|
|
@@ -5953,6 +6088,7 @@ let WebSocket$1 = class WebSocket extends EventEmitter$1 {
|
|
|
5953
6088
|
this._closeFrameSent = false;
|
|
5954
6089
|
this._closeMessage = EMPTY_BUFFER;
|
|
5955
6090
|
this._closeTimer = null;
|
|
6091
|
+
this._errorEmitted = false;
|
|
5956
6092
|
this._extensions = {};
|
|
5957
6093
|
this._paused = false;
|
|
5958
6094
|
this._protocol = '';
|
|
@@ -5985,9 +6121,8 @@ let WebSocket$1 = class WebSocket extends EventEmitter$1 {
|
|
|
5985
6121
|
}
|
|
5986
6122
|
|
|
5987
6123
|
/**
|
|
5988
|
-
*
|
|
5989
|
-
*
|
|
5990
|
-
* type).
|
|
6124
|
+
* For historical reasons, the custom "nodebuffer" type is used by the default
|
|
6125
|
+
* instead of "blob".
|
|
5991
6126
|
*
|
|
5992
6127
|
* @type {String}
|
|
5993
6128
|
*/
|
|
@@ -6108,11 +6243,14 @@ let WebSocket$1 = class WebSocket extends EventEmitter$1 {
|
|
|
6108
6243
|
skipUTF8Validation: options.skipUTF8Validation
|
|
6109
6244
|
});
|
|
6110
6245
|
|
|
6111
|
-
|
|
6246
|
+
const sender = new Sender(socket, this._extensions, options.generateMask);
|
|
6247
|
+
|
|
6112
6248
|
this._receiver = receiver;
|
|
6249
|
+
this._sender = sender;
|
|
6113
6250
|
this._socket = socket;
|
|
6114
6251
|
|
|
6115
6252
|
receiver[kWebSocket$1] = this;
|
|
6253
|
+
sender[kWebSocket$1] = this;
|
|
6116
6254
|
socket[kWebSocket$1] = this;
|
|
6117
6255
|
|
|
6118
6256
|
receiver.on('conclude', receiverOnConclude);
|
|
@@ -6122,6 +6260,8 @@ let WebSocket$1 = class WebSocket extends EventEmitter$1 {
|
|
|
6122
6260
|
receiver.on('ping', receiverOnPing);
|
|
6123
6261
|
receiver.on('pong', receiverOnPong);
|
|
6124
6262
|
|
|
6263
|
+
sender.onerror = senderOnError;
|
|
6264
|
+
|
|
6125
6265
|
//
|
|
6126
6266
|
// These methods may not be available if `socket` is just a `Duplex`.
|
|
6127
6267
|
//
|
|
@@ -6217,13 +6357,7 @@ let WebSocket$1 = class WebSocket extends EventEmitter$1 {
|
|
|
6217
6357
|
}
|
|
6218
6358
|
});
|
|
6219
6359
|
|
|
6220
|
-
|
|
6221
|
-
// Specify a timeout for the closing handshake to complete.
|
|
6222
|
-
//
|
|
6223
|
-
this._closeTimer = setTimeout(
|
|
6224
|
-
this._socket.destroy.bind(this._socket),
|
|
6225
|
-
closeTimeout
|
|
6226
|
-
);
|
|
6360
|
+
setCloseTimer(this);
|
|
6227
6361
|
}
|
|
6228
6362
|
|
|
6229
6363
|
/**
|
|
@@ -6927,6 +7061,11 @@ function initAsClient(websocket, address, protocols, options) {
|
|
|
6927
7061
|
*/
|
|
6928
7062
|
function emitErrorAndClose(websocket, err) {
|
|
6929
7063
|
websocket._readyState = WebSocket$1.CLOSING;
|
|
7064
|
+
//
|
|
7065
|
+
// The following assignment is practically useless and is done only for
|
|
7066
|
+
// consistency.
|
|
7067
|
+
//
|
|
7068
|
+
websocket._errorEmitted = true;
|
|
6930
7069
|
websocket.emit('error', err);
|
|
6931
7070
|
websocket.emitClose();
|
|
6932
7071
|
}
|
|
@@ -7007,7 +7146,7 @@ function abortHandshake$1(websocket, stream, message) {
|
|
|
7007
7146
|
*/
|
|
7008
7147
|
function sendAfterClose(websocket, data, cb) {
|
|
7009
7148
|
if (data) {
|
|
7010
|
-
const length = toBuffer(data).length;
|
|
7149
|
+
const length = isBlob(data) ? data.size : toBuffer(data).length;
|
|
7011
7150
|
|
|
7012
7151
|
//
|
|
7013
7152
|
// The `_bufferedAmount` property is used only when the peer is a client and
|
|
@@ -7083,7 +7222,10 @@ function receiverOnError(err) {
|
|
|
7083
7222
|
websocket.close(err[kStatusCode]);
|
|
7084
7223
|
}
|
|
7085
7224
|
|
|
7086
|
-
websocket.
|
|
7225
|
+
if (!websocket._errorEmitted) {
|
|
7226
|
+
websocket._errorEmitted = true;
|
|
7227
|
+
websocket.emit('error', err);
|
|
7228
|
+
}
|
|
7087
7229
|
}
|
|
7088
7230
|
|
|
7089
7231
|
/**
|
|
@@ -7139,6 +7281,47 @@ function resume(stream) {
|
|
|
7139
7281
|
stream.resume();
|
|
7140
7282
|
}
|
|
7141
7283
|
|
|
7284
|
+
/**
|
|
7285
|
+
* The `Sender` error event handler.
|
|
7286
|
+
*
|
|
7287
|
+
* @param {Error} The error
|
|
7288
|
+
* @private
|
|
7289
|
+
*/
|
|
7290
|
+
function senderOnError(err) {
|
|
7291
|
+
const websocket = this[kWebSocket$1];
|
|
7292
|
+
|
|
7293
|
+
if (websocket.readyState === WebSocket$1.CLOSED) return;
|
|
7294
|
+
if (websocket.readyState === WebSocket$1.OPEN) {
|
|
7295
|
+
websocket._readyState = WebSocket$1.CLOSING;
|
|
7296
|
+
setCloseTimer(websocket);
|
|
7297
|
+
}
|
|
7298
|
+
|
|
7299
|
+
//
|
|
7300
|
+
// `socket.end()` is used instead of `socket.destroy()` to allow the other
|
|
7301
|
+
// peer to finish sending queued data. There is no need to set a timer here
|
|
7302
|
+
// because `CLOSING` means that it is already set or not needed.
|
|
7303
|
+
//
|
|
7304
|
+
this._socket.end();
|
|
7305
|
+
|
|
7306
|
+
if (!websocket._errorEmitted) {
|
|
7307
|
+
websocket._errorEmitted = true;
|
|
7308
|
+
websocket.emit('error', err);
|
|
7309
|
+
}
|
|
7310
|
+
}
|
|
7311
|
+
|
|
7312
|
+
/**
|
|
7313
|
+
* Set a timer to destroy the underlying raw socket of a WebSocket.
|
|
7314
|
+
*
|
|
7315
|
+
* @param {WebSocket} websocket The WebSocket instance
|
|
7316
|
+
* @private
|
|
7317
|
+
*/
|
|
7318
|
+
function setCloseTimer(websocket) {
|
|
7319
|
+
websocket._closeTimer = setTimeout(
|
|
7320
|
+
websocket._socket.destroy.bind(websocket._socket),
|
|
7321
|
+
closeTimeout
|
|
7322
|
+
);
|
|
7323
|
+
}
|
|
7324
|
+
|
|
7142
7325
|
/**
|
|
7143
7326
|
* The listener of the socket `'close'` event.
|
|
7144
7327
|
*
|
|
@@ -7834,11 +8017,10 @@ function abortHandshakeOrEmitwsClientError(server, req, socket, code, message) {
|
|
|
7834
8017
|
var WebSocketServer$1 = /*@__PURE__*/getDefaultExportFromCjs(websocketServer);
|
|
7835
8018
|
|
|
7836
8019
|
function setup(ctx, _server) {
|
|
7837
|
-
var _a;
|
|
7838
8020
|
const wss = new WebSocketServer$1({ noServer: true });
|
|
7839
8021
|
const clients = /* @__PURE__ */ new Map();
|
|
7840
8022
|
const server = _server || ctx.server;
|
|
7841
|
-
|
|
8023
|
+
server.httpServer?.on("upgrade", (request, socket, head) => {
|
|
7842
8024
|
if (!request.url) {
|
|
7843
8025
|
return;
|
|
7844
8026
|
}
|
|
@@ -7854,10 +8036,6 @@ function setup(ctx, _server) {
|
|
|
7854
8036
|
function setupClient(ws) {
|
|
7855
8037
|
const rpc = createBirpc(
|
|
7856
8038
|
{
|
|
7857
|
-
async onCollected(files) {
|
|
7858
|
-
ctx.state.collectFiles(files);
|
|
7859
|
-
await ctx.report("onCollected", files);
|
|
7860
|
-
},
|
|
7861
8039
|
async onTaskUpdate(packs) {
|
|
7862
8040
|
ctx.state.updateTasks(packs);
|
|
7863
8041
|
await ctx.report("onTaskUpdate", packs);
|
|
@@ -7886,7 +8064,7 @@ function setup(ctx, _server) {
|
|
|
7886
8064
|
await ctx.rerunFiles(files);
|
|
7887
8065
|
},
|
|
7888
8066
|
getConfig() {
|
|
7889
|
-
return ctx.
|
|
8067
|
+
return ctx.getCoreWorkspaceProject().getSerializableConfig();
|
|
7890
8068
|
},
|
|
7891
8069
|
async getTransformResult(projectName, id, browser = false) {
|
|
7892
8070
|
const project = ctx.getProjectByName(projectName);
|
|
@@ -7957,8 +8135,7 @@ class WebSocketReporter {
|
|
|
7957
8135
|
return;
|
|
7958
8136
|
}
|
|
7959
8137
|
this.clients.forEach((client) => {
|
|
7960
|
-
|
|
7961
|
-
(_c = (_b = (_a = client.onCollected) == null ? void 0 : _a.call(client, files)) == null ? void 0 : _b.catch) == null ? void 0 : _c.call(_b, noop$1);
|
|
8138
|
+
client.onCollected?.(files)?.catch?.(noop$1);
|
|
7962
8139
|
});
|
|
7963
8140
|
}
|
|
7964
8141
|
onSpecsCollected(specs) {
|
|
@@ -7966,8 +8143,7 @@ class WebSocketReporter {
|
|
|
7966
8143
|
return;
|
|
7967
8144
|
}
|
|
7968
8145
|
this.clients.forEach((client) => {
|
|
7969
|
-
|
|
7970
|
-
(_c = (_b = (_a = client.onSpecsCollected) == null ? void 0 : _a.call(client, specs)) == null ? void 0 : _b.catch) == null ? void 0 : _c.call(_b, noop$1);
|
|
8146
|
+
client.onSpecsCollected?.(specs)?.catch?.(noop$1);
|
|
7971
8147
|
});
|
|
7972
8148
|
}
|
|
7973
8149
|
async onTaskUpdate(packs) {
|
|
@@ -7975,40 +8151,34 @@ class WebSocketReporter {
|
|
|
7975
8151
|
return;
|
|
7976
8152
|
}
|
|
7977
8153
|
packs.forEach(([taskId, result]) => {
|
|
7978
|
-
var _a;
|
|
7979
8154
|
const project = this.ctx.getProjectByTaskId(taskId);
|
|
7980
8155
|
const task = this.ctx.state.idMap.get(taskId);
|
|
7981
8156
|
const isBrowser = task && task.file.pool === "browser";
|
|
7982
|
-
|
|
7983
|
-
var _a2;
|
|
8157
|
+
result?.errors?.forEach((error) => {
|
|
7984
8158
|
if (isPrimitive(error)) {
|
|
7985
8159
|
return;
|
|
7986
8160
|
}
|
|
7987
|
-
const stacks = isBrowser ?
|
|
8161
|
+
const stacks = isBrowser ? project.browser?.parseErrorStacktrace(error) : parseErrorStacktrace(error);
|
|
7988
8162
|
error.stacks = stacks;
|
|
7989
8163
|
});
|
|
7990
8164
|
});
|
|
7991
8165
|
this.clients.forEach((client) => {
|
|
7992
|
-
|
|
7993
|
-
(_c = (_b = (_a = client.onTaskUpdate) == null ? void 0 : _a.call(client, packs)) == null ? void 0 : _b.catch) == null ? void 0 : _c.call(_b, noop$1);
|
|
8166
|
+
client.onTaskUpdate?.(packs)?.catch?.(noop$1);
|
|
7994
8167
|
});
|
|
7995
8168
|
}
|
|
7996
8169
|
onFinished(files, errors) {
|
|
7997
8170
|
this.clients.forEach((client) => {
|
|
7998
|
-
|
|
7999
|
-
(_c = (_b = (_a = client.onFinished) == null ? void 0 : _a.call(client, files, errors)) == null ? void 0 : _b.catch) == null ? void 0 : _c.call(_b, noop$1);
|
|
8171
|
+
client.onFinished?.(files, errors)?.catch?.(noop$1);
|
|
8000
8172
|
});
|
|
8001
8173
|
}
|
|
8002
8174
|
onFinishedReportCoverage() {
|
|
8003
8175
|
this.clients.forEach((client) => {
|
|
8004
|
-
|
|
8005
|
-
(_c = (_b = (_a = client.onFinishedReportCoverage) == null ? void 0 : _a.call(client)) == null ? void 0 : _b.catch) == null ? void 0 : _c.call(_b, noop$1);
|
|
8176
|
+
client.onFinishedReportCoverage?.()?.catch?.(noop$1);
|
|
8006
8177
|
});
|
|
8007
8178
|
}
|
|
8008
8179
|
onUserConsoleLog(log) {
|
|
8009
8180
|
this.clients.forEach((client) => {
|
|
8010
|
-
|
|
8011
|
-
(_c = (_b = (_a = client.onUserConsoleLog) == null ? void 0 : _a.call(client, log)) == null ? void 0 : _b.catch) == null ? void 0 : _c.call(_b, noop$1);
|
|
8181
|
+
client.onUserConsoleLog?.(log)?.catch?.(noop$1);
|
|
8012
8182
|
});
|
|
8013
8183
|
}
|
|
8014
8184
|
}
|
|
@@ -8032,9 +8202,8 @@ function getTransformMode(patterns, filename) {
|
|
|
8032
8202
|
async function groupFilesByEnv(files) {
|
|
8033
8203
|
const filesWithEnv = await Promise.all(
|
|
8034
8204
|
files.map(async ([project, file]) => {
|
|
8035
|
-
var _a, _b;
|
|
8036
8205
|
const code = await promises$1.readFile(file, "utf-8");
|
|
8037
|
-
let env =
|
|
8206
|
+
let env = code.match(/@(?:vitest|jest)-environment\s+([\w-]+)\b/)?.[1];
|
|
8038
8207
|
if (!env) {
|
|
8039
8208
|
for (const [glob, target] of project.config.environmentMatchGlobs || []) {
|
|
8040
8209
|
if (mm.isMatch(file, glob, { cwd: project.config.root })) {
|
|
@@ -8043,14 +8212,16 @@ async function groupFilesByEnv(files) {
|
|
|
8043
8212
|
}
|
|
8044
8213
|
}
|
|
8045
8214
|
}
|
|
8046
|
-
env
|
|
8215
|
+
env ||= project.config.environment || "node";
|
|
8047
8216
|
const transformMode = getTransformMode(
|
|
8048
8217
|
project.config.testTransformMode,
|
|
8049
8218
|
file
|
|
8050
8219
|
);
|
|
8051
|
-
|
|
8052
|
-
|
|
8053
|
-
|
|
8220
|
+
let envOptionsJson = code.match(/@(?:vitest|jest)-environment-options\s+(.+)/)?.[1];
|
|
8221
|
+
if (envOptionsJson?.endsWith("*/")) {
|
|
8222
|
+
envOptionsJson = envOptionsJson.slice(0, -2);
|
|
8223
|
+
}
|
|
8224
|
+
const envOptions = JSON.parse(envOptionsJson || "null");
|
|
8054
8225
|
const envKey = env === "happy-dom" ? "happyDOM" : env;
|
|
8055
8226
|
const environment = {
|
|
8056
8227
|
name: env,
|
|
@@ -8087,7 +8258,7 @@ function createMethodsRPC(project, options = {}) {
|
|
|
8087
8258
|
}
|
|
8088
8259
|
}
|
|
8089
8260
|
const r = await project.vitenode.transformRequest(id);
|
|
8090
|
-
return r
|
|
8261
|
+
return r?.map;
|
|
8091
8262
|
},
|
|
8092
8263
|
async fetch(id, transformMode) {
|
|
8093
8264
|
const result = await project.vitenode.fetchResult(id, transformMode);
|
|
@@ -8131,12 +8302,11 @@ function createMethodsRPC(project, options = {}) {
|
|
|
8131
8302
|
return ctx.report("onPathsCollected", paths);
|
|
8132
8303
|
},
|
|
8133
8304
|
onCollected(files) {
|
|
8134
|
-
ctx.state.collectFiles(files);
|
|
8305
|
+
ctx.state.collectFiles(project, files);
|
|
8135
8306
|
return ctx.report("onCollected", files);
|
|
8136
8307
|
},
|
|
8137
8308
|
onAfterSuiteRun(meta) {
|
|
8138
|
-
|
|
8139
|
-
(_a = ctx.coverageProvider) == null ? void 0 : _a.onAfterSuiteRun(meta);
|
|
8309
|
+
ctx.coverageProvider?.onAfterSuiteRun(meta);
|
|
8140
8310
|
},
|
|
8141
8311
|
onTaskUpdate(packs) {
|
|
8142
8312
|
ctx.state.updateTasks(packs);
|
|
@@ -8187,10 +8357,9 @@ function createChildProcessChannel$1(project) {
|
|
|
8187
8357
|
return { channel, cleanup };
|
|
8188
8358
|
}
|
|
8189
8359
|
function createForksPool(ctx, { execArgv, env }) {
|
|
8190
|
-
var _a;
|
|
8191
8360
|
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length;
|
|
8192
8361
|
const threadsCount = ctx.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
|
|
8193
|
-
const poolOptions =
|
|
8362
|
+
const poolOptions = ctx.config.poolOptions?.forks ?? {};
|
|
8194
8363
|
const maxThreads = poolOptions.maxForks ?? ctx.config.maxWorkers ?? threadsCount;
|
|
8195
8364
|
const minThreads = poolOptions.minForks ?? ctx.config.minWorkers ?? threadsCount;
|
|
8196
8365
|
const worker = resolve(ctx.distPath, "workers/forks.js");
|
|
@@ -8238,7 +8407,7 @@ function createForksPool(ctx, { execArgv, env }) {
|
|
|
8238
8407
|
`Failed to terminate worker while running ${files.join(", ")}.`
|
|
8239
8408
|
);
|
|
8240
8409
|
} else if (ctx.isCancelling && error instanceof Error && /The task has been cancelled/.test(error.message)) {
|
|
8241
|
-
ctx.state.cancelFiles(files,
|
|
8410
|
+
ctx.state.cancelFiles(files, project);
|
|
8242
8411
|
} else {
|
|
8243
8412
|
throw error;
|
|
8244
8413
|
}
|
|
@@ -8265,16 +8434,10 @@ function createForksPool(ctx, { execArgv, env }) {
|
|
|
8265
8434
|
workspaceMap.set(file, workspaceFiles);
|
|
8266
8435
|
}
|
|
8267
8436
|
const singleFork = specs.filter(
|
|
8268
|
-
([project]) =>
|
|
8269
|
-
var _a2, _b;
|
|
8270
|
-
return (_b = (_a2 = project.config.poolOptions) == null ? void 0 : _a2.forks) == null ? void 0 : _b.singleFork;
|
|
8271
|
-
}
|
|
8437
|
+
([project]) => project.config.poolOptions?.forks?.singleFork
|
|
8272
8438
|
);
|
|
8273
8439
|
const multipleForks = specs.filter(
|
|
8274
|
-
([project]) =>
|
|
8275
|
-
var _a2, _b;
|
|
8276
|
-
return !((_b = (_a2 = project.config.poolOptions) == null ? void 0 : _a2.forks) == null ? void 0 : _b.singleFork);
|
|
8277
|
-
}
|
|
8440
|
+
([project]) => !project.config.poolOptions?.forks?.singleFork
|
|
8278
8441
|
);
|
|
8279
8442
|
if (multipleForks.length) {
|
|
8280
8443
|
const filesByEnv = await groupFilesByEnv(multipleForks);
|
|
@@ -8334,7 +8497,7 @@ function createForksPool(ctx, { execArgv, env }) {
|
|
|
8334
8497
|
);
|
|
8335
8498
|
for (const env2 of envs) {
|
|
8336
8499
|
const files = filesByEnv[env2];
|
|
8337
|
-
if (!
|
|
8500
|
+
if (!files?.length) {
|
|
8338
8501
|
continue;
|
|
8339
8502
|
}
|
|
8340
8503
|
const filesByOptions = groupBy(
|
|
@@ -8384,10 +8547,9 @@ function createWorkerChannel$1(project) {
|
|
|
8384
8547
|
return { workerPort, port };
|
|
8385
8548
|
}
|
|
8386
8549
|
function createThreadsPool(ctx, { execArgv, env }) {
|
|
8387
|
-
var _a;
|
|
8388
8550
|
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length;
|
|
8389
8551
|
const threadsCount = ctx.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
|
|
8390
|
-
const poolOptions =
|
|
8552
|
+
const poolOptions = ctx.config.poolOptions?.threads ?? {};
|
|
8391
8553
|
const maxThreads = poolOptions.maxThreads ?? ctx.config.maxWorkers ?? threadsCount;
|
|
8392
8554
|
const minThreads = poolOptions.minThreads ?? ctx.config.minWorkers ?? threadsCount;
|
|
8393
8555
|
const worker = resolve(ctx.distPath, "workers/threads.js");
|
|
@@ -8441,7 +8603,7 @@ function createThreadsPool(ctx, { execArgv, env }) {
|
|
|
8441
8603
|
See https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker for troubleshooting.`
|
|
8442
8604
|
);
|
|
8443
8605
|
} else if (ctx.isCancelling && error instanceof Error && /The task has been cancelled/.test(error.message)) {
|
|
8444
|
-
ctx.state.cancelFiles(files,
|
|
8606
|
+
ctx.state.cancelFiles(files, project);
|
|
8445
8607
|
} else {
|
|
8446
8608
|
throw error;
|
|
8447
8609
|
}
|
|
@@ -8468,16 +8630,10 @@ See https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker for t
|
|
|
8468
8630
|
workspaceMap.set(file, workspaceFiles);
|
|
8469
8631
|
}
|
|
8470
8632
|
const singleThreads = specs.filter(
|
|
8471
|
-
([project]) =>
|
|
8472
|
-
var _a2, _b;
|
|
8473
|
-
return (_b = (_a2 = project.config.poolOptions) == null ? void 0 : _a2.threads) == null ? void 0 : _b.singleThread;
|
|
8474
|
-
}
|
|
8633
|
+
([project]) => project.config.poolOptions?.threads?.singleThread
|
|
8475
8634
|
);
|
|
8476
8635
|
const multipleThreads = specs.filter(
|
|
8477
|
-
([project]) =>
|
|
8478
|
-
var _a2, _b;
|
|
8479
|
-
return !((_b = (_a2 = project.config.poolOptions) == null ? void 0 : _a2.threads) == null ? void 0 : _b.singleThread);
|
|
8480
|
-
}
|
|
8636
|
+
([project]) => !project.config.poolOptions?.threads?.singleThread
|
|
8481
8637
|
);
|
|
8482
8638
|
if (multipleThreads.length) {
|
|
8483
8639
|
const filesByEnv = await groupFilesByEnv(multipleThreads);
|
|
@@ -8537,7 +8693,7 @@ See https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker for t
|
|
|
8537
8693
|
);
|
|
8538
8694
|
for (const env2 of envs) {
|
|
8539
8695
|
const files = filesByEnv[env2];
|
|
8540
|
-
if (!
|
|
8696
|
+
if (!files?.length) {
|
|
8541
8697
|
continue;
|
|
8542
8698
|
}
|
|
8543
8699
|
const filesByOptions = groupBy(
|
|
@@ -8572,12 +8728,11 @@ function getDefaultThreadsCount(config) {
|
|
|
8572
8728
|
return config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
|
|
8573
8729
|
}
|
|
8574
8730
|
function getWorkerMemoryLimit(config) {
|
|
8575
|
-
|
|
8576
|
-
const memoryLimit = (_b = (_a = config.poolOptions) == null ? void 0 : _a.vmThreads) == null ? void 0 : _b.memoryLimit;
|
|
8731
|
+
const memoryLimit = config.poolOptions?.vmThreads?.memoryLimit;
|
|
8577
8732
|
if (memoryLimit) {
|
|
8578
8733
|
return memoryLimit;
|
|
8579
8734
|
}
|
|
8580
|
-
return 1 / (
|
|
8735
|
+
return 1 / (config.poolOptions?.vmThreads?.maxThreads ?? getDefaultThreadsCount(config));
|
|
8581
8736
|
}
|
|
8582
8737
|
function stringToBytes(input, percentageReference) {
|
|
8583
8738
|
if (input === null || input === void 0) {
|
|
@@ -8653,10 +8808,9 @@ function createWorkerChannel(project) {
|
|
|
8653
8808
|
return { workerPort, port };
|
|
8654
8809
|
}
|
|
8655
8810
|
function createVmThreadsPool(ctx, { execArgv, env }) {
|
|
8656
|
-
var _a;
|
|
8657
8811
|
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length;
|
|
8658
8812
|
const threadsCount = ctx.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
|
|
8659
|
-
const poolOptions =
|
|
8813
|
+
const poolOptions = ctx.config.poolOptions?.vmThreads ?? {};
|
|
8660
8814
|
const maxThreads = poolOptions.maxThreads ?? ctx.config.maxWorkers ?? threadsCount;
|
|
8661
8815
|
const minThreads = poolOptions.minThreads ?? ctx.config.minWorkers ?? threadsCount;
|
|
8662
8816
|
const worker = resolve(ctx.distPath, "workers/vmThreads.js");
|
|
@@ -8714,7 +8868,7 @@ function createVmThreadsPool(ctx, { execArgv, env }) {
|
|
|
8714
8868
|
See https://vitest.dev/guide/common-errors.html#failed-to-terminate-worker for troubleshooting.`
|
|
8715
8869
|
);
|
|
8716
8870
|
} else if (ctx.isCancelling && error instanceof Error && /The task has been cancelled/.test(error.message)) {
|
|
8717
|
-
ctx.state.cancelFiles(files,
|
|
8871
|
+
ctx.state.cancelFiles(files, project);
|
|
8718
8872
|
} else {
|
|
8719
8873
|
throw error;
|
|
8720
8874
|
}
|
|
@@ -8779,7 +8933,6 @@ function createTypecheckPool(ctx) {
|
|
|
8779
8933
|
const promisesMap = /* @__PURE__ */ new WeakMap();
|
|
8780
8934
|
const rerunTriggered = /* @__PURE__ */ new WeakMap();
|
|
8781
8935
|
async function onParseEnd(project, { files, sourceErrors }) {
|
|
8782
|
-
var _a;
|
|
8783
8936
|
const checker = project.typechecker;
|
|
8784
8937
|
await ctx.report("onTaskUpdate", checker.getTestPacks());
|
|
8785
8938
|
if (!project.config.typecheck.ignoreSourceErrors) {
|
|
@@ -8793,7 +8946,7 @@ function createTypecheckPool(ctx) {
|
|
|
8793
8946
|
error.stack = "";
|
|
8794
8947
|
ctx.state.catchError(error, "Typecheck Error");
|
|
8795
8948
|
}
|
|
8796
|
-
|
|
8949
|
+
promisesMap.get(project)?.resolve();
|
|
8797
8950
|
rerunTriggered.set(project, false);
|
|
8798
8951
|
if (ctx.config.watch && !ctx.runningPromise) {
|
|
8799
8952
|
await ctx.report("onFinished", files, []);
|
|
@@ -8811,7 +8964,7 @@ function createTypecheckPool(ctx) {
|
|
|
8811
8964
|
project.typechecker = checker;
|
|
8812
8965
|
checker.setFiles(files);
|
|
8813
8966
|
checker.onParseStart(async () => {
|
|
8814
|
-
ctx.state.collectFiles(checker.getTestFiles());
|
|
8967
|
+
ctx.state.collectFiles(project, checker.getTestFiles());
|
|
8815
8968
|
await ctx.report("onCollected");
|
|
8816
8969
|
});
|
|
8817
8970
|
checker.onParseEnd((result) => onParseEnd(project, result));
|
|
@@ -8826,7 +8979,7 @@ function createTypecheckPool(ctx) {
|
|
|
8826
8979
|
);
|
|
8827
8980
|
}
|
|
8828
8981
|
await checker.collectTests();
|
|
8829
|
-
ctx.state.collectFiles(checker.getTestFiles());
|
|
8982
|
+
ctx.state.collectFiles(project, checker.getTestFiles());
|
|
8830
8983
|
await ctx.report("onTaskUpdate", checker.getTestPacks());
|
|
8831
8984
|
await ctx.report("onCollected");
|
|
8832
8985
|
});
|
|
@@ -8849,7 +9002,7 @@ function createTypecheckPool(ctx) {
|
|
|
8849
9002
|
const checker = await createWorkspaceTypechecker(project, files);
|
|
8850
9003
|
checker.setFiles(files);
|
|
8851
9004
|
await checker.collectTests();
|
|
8852
|
-
ctx.state.collectFiles(checker.getTestFiles());
|
|
9005
|
+
ctx.state.collectFiles(project, checker.getTestFiles());
|
|
8853
9006
|
await ctx.report("onCollected");
|
|
8854
9007
|
}
|
|
8855
9008
|
}
|
|
@@ -8874,7 +9027,7 @@ function createTypecheckPool(ctx) {
|
|
|
8874
9027
|
});
|
|
8875
9028
|
const triggered = await _p;
|
|
8876
9029
|
if (project.typechecker && !triggered) {
|
|
8877
|
-
ctx.state.collectFiles(project.typechecker.getTestFiles());
|
|
9030
|
+
ctx.state.collectFiles(project, project.typechecker.getTestFiles());
|
|
8878
9031
|
await ctx.report("onCollected");
|
|
8879
9032
|
await onParseEnd(project, project.typechecker.getResult());
|
|
8880
9033
|
continue;
|
|
@@ -8891,10 +9044,7 @@ function createTypecheckPool(ctx) {
|
|
|
8891
9044
|
collectTests,
|
|
8892
9045
|
async close() {
|
|
8893
9046
|
const promises = ctx.projects.map(
|
|
8894
|
-
(project) =>
|
|
8895
|
-
var _a;
|
|
8896
|
-
return (_a = project.typechecker) == null ? void 0 : _a.stop();
|
|
8897
|
-
}
|
|
9047
|
+
(project) => project.typechecker?.stop()
|
|
8898
9048
|
);
|
|
8899
9049
|
await Promise.all(promises);
|
|
8900
9050
|
}
|
|
@@ -8931,10 +9081,9 @@ function createChildProcessChannel(project) {
|
|
|
8931
9081
|
return { channel, cleanup };
|
|
8932
9082
|
}
|
|
8933
9083
|
function createVmForksPool(ctx, { execArgv, env }) {
|
|
8934
|
-
var _a;
|
|
8935
9084
|
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length;
|
|
8936
9085
|
const threadsCount = ctx.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
|
|
8937
|
-
const poolOptions =
|
|
9086
|
+
const poolOptions = ctx.config.poolOptions?.vmForks ?? {};
|
|
8938
9087
|
const maxThreads = poolOptions.maxForks ?? ctx.config.maxWorkers ?? threadsCount;
|
|
8939
9088
|
const minThreads = poolOptions.maxForks ?? ctx.config.minWorkers ?? threadsCount;
|
|
8940
9089
|
const worker = resolve(ctx.distPath, "workers/vmForks.js");
|
|
@@ -8986,7 +9135,7 @@ function createVmForksPool(ctx, { execArgv, env }) {
|
|
|
8986
9135
|
`Failed to terminate worker while running ${files.join(", ")}.`
|
|
8987
9136
|
);
|
|
8988
9137
|
} else if (ctx.isCancelling && error instanceof Error && /The task has been cancelled/.test(error.message)) {
|
|
8989
|
-
ctx.state.cancelFiles(files,
|
|
9138
|
+
ctx.state.cancelFiles(files, project);
|
|
8990
9139
|
} else {
|
|
8991
9140
|
throw error;
|
|
8992
9141
|
}
|
|
@@ -9136,12 +9285,12 @@ function createPool(ctx) {
|
|
|
9136
9285
|
);
|
|
9137
9286
|
}
|
|
9138
9287
|
const poolInstance = await pool.default(ctx, options);
|
|
9139
|
-
if (typeof
|
|
9288
|
+
if (typeof poolInstance?.name !== "string") {
|
|
9140
9289
|
throw new TypeError(
|
|
9141
9290
|
`Custom pool "${filepath}" should return an object with "name" property`
|
|
9142
9291
|
);
|
|
9143
9292
|
}
|
|
9144
|
-
if (typeof
|
|
9293
|
+
if (typeof poolInstance?.[method] !== "function") {
|
|
9145
9294
|
throw new TypeError(
|
|
9146
9295
|
`Custom pool "${filepath}" should return an object with "${method}" method`
|
|
9147
9296
|
);
|
|
@@ -9167,7 +9316,7 @@ function createPool(ctx) {
|
|
|
9167
9316
|
};
|
|
9168
9317
|
for (const spec of files) {
|
|
9169
9318
|
const pool = getFilePoolName(spec[0], spec[1]);
|
|
9170
|
-
filesByPool[pool]
|
|
9319
|
+
filesByPool[pool] ??= [];
|
|
9171
9320
|
filesByPool[pool].push(spec);
|
|
9172
9321
|
}
|
|
9173
9322
|
const Sequencer = ctx.config.sequence.sequencer;
|
|
@@ -9180,7 +9329,6 @@ function createPool(ctx) {
|
|
|
9180
9329
|
}
|
|
9181
9330
|
await Promise.all(
|
|
9182
9331
|
Object.entries(filesByPool).map(async (entry) => {
|
|
9183
|
-
var _a;
|
|
9184
9332
|
const [pool, files2] = entry;
|
|
9185
9333
|
if (!files2.length) {
|
|
9186
9334
|
return null;
|
|
@@ -9188,18 +9336,18 @@ function createPool(ctx) {
|
|
|
9188
9336
|
const specs = await sortSpecs(files2);
|
|
9189
9337
|
if (pool in factories) {
|
|
9190
9338
|
const factory = factories[pool];
|
|
9191
|
-
pools[pool]
|
|
9339
|
+
pools[pool] ??= factory();
|
|
9192
9340
|
return pools[pool][method](specs, invalidate);
|
|
9193
9341
|
}
|
|
9194
9342
|
if (pool === "browser") {
|
|
9195
|
-
pools[pool]
|
|
9343
|
+
pools[pool] ??= await (async () => {
|
|
9196
9344
|
const { createBrowserPool } = await import('@vitest/browser');
|
|
9197
9345
|
return createBrowserPool(ctx);
|
|
9198
|
-
})()
|
|
9346
|
+
})();
|
|
9199
9347
|
return pools[pool][method](specs, invalidate);
|
|
9200
9348
|
}
|
|
9201
9349
|
const poolHandler = await resolveCustomPool(pool);
|
|
9202
|
-
pools[
|
|
9350
|
+
pools[poolHandler.name] ??= poolHandler;
|
|
9203
9351
|
return poolHandler[method](specs, invalidate);
|
|
9204
9352
|
})
|
|
9205
9353
|
);
|
|
@@ -9209,10 +9357,7 @@ function createPool(ctx) {
|
|
|
9209
9357
|
runTests: (files, invalidates) => executeTests("runTests", files, invalidates),
|
|
9210
9358
|
collectTests: (files, invalidates) => executeTests("collectTests", files, invalidates),
|
|
9211
9359
|
async close() {
|
|
9212
|
-
await Promise.all(Object.values(pools).map((p) =>
|
|
9213
|
-
var _a;
|
|
9214
|
-
return (_a = p == null ? void 0 : p.close) == null ? void 0 : _a.call(p);
|
|
9215
|
-
}));
|
|
9360
|
+
await Promise.all(Object.values(pools).map((p) => p?.close?.()));
|
|
9216
9361
|
}
|
|
9217
9362
|
};
|
|
9218
9363
|
}
|
|
@@ -9296,6 +9441,7 @@ class StateManager {
|
|
|
9296
9441
|
taskFileMap = /* @__PURE__ */ new WeakMap();
|
|
9297
9442
|
errorsSet = /* @__PURE__ */ new Set();
|
|
9298
9443
|
processTimeoutCauses = /* @__PURE__ */ new Set();
|
|
9444
|
+
reportedTasksMap = /* @__PURE__ */ new WeakMap();
|
|
9299
9445
|
catchError(err, type) {
|
|
9300
9446
|
if (isAggregateError(err)) {
|
|
9301
9447
|
return err.errors.forEach((error) => this.catchError(error, type));
|
|
@@ -9310,7 +9456,7 @@ class StateManager {
|
|
|
9310
9456
|
const task = this.idMap.get(_err.taskId);
|
|
9311
9457
|
if (task) {
|
|
9312
9458
|
task.mode = "skip";
|
|
9313
|
-
task.result
|
|
9459
|
+
task.result ??= { state: "skip" };
|
|
9314
9460
|
task.result.state = "skip";
|
|
9315
9461
|
}
|
|
9316
9462
|
return;
|
|
@@ -9345,17 +9491,14 @@ class StateManager {
|
|
|
9345
9491
|
return Array.from(this.filesMap.keys());
|
|
9346
9492
|
}
|
|
9347
9493
|
getFailedFilepaths() {
|
|
9348
|
-
return this.getFiles().filter((i) =>
|
|
9349
|
-
var _a;
|
|
9350
|
-
return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
|
|
9351
|
-
}).map((i) => i.filepath);
|
|
9494
|
+
return this.getFiles().filter((i) => i.result?.state === "fail").map((i) => i.filepath);
|
|
9352
9495
|
}
|
|
9353
9496
|
collectPaths(paths = []) {
|
|
9354
9497
|
paths.forEach((path) => {
|
|
9355
9498
|
this.pathsSet.add(path);
|
|
9356
9499
|
});
|
|
9357
9500
|
}
|
|
9358
|
-
collectFiles(files = []) {
|
|
9501
|
+
collectFiles(project, files = []) {
|
|
9359
9502
|
files.forEach((file) => {
|
|
9360
9503
|
const existing = this.filesMap.get(file.filepath) || [];
|
|
9361
9504
|
const otherProject = existing.filter(
|
|
@@ -9369,12 +9512,10 @@ class StateManager {
|
|
|
9369
9512
|
}
|
|
9370
9513
|
otherProject.push(file);
|
|
9371
9514
|
this.filesMap.set(file.filepath, otherProject);
|
|
9372
|
-
this.updateId(file);
|
|
9515
|
+
this.updateId(file, project);
|
|
9373
9516
|
});
|
|
9374
9517
|
}
|
|
9375
|
-
|
|
9376
|
-
clearFiles(_project, paths = []) {
|
|
9377
|
-
const project = _project;
|
|
9518
|
+
clearFiles(project, paths = []) {
|
|
9378
9519
|
paths.forEach((path) => {
|
|
9379
9520
|
const files = this.filesMap.get(path);
|
|
9380
9521
|
const fileTask = createFileTask(
|
|
@@ -9383,6 +9524,7 @@ class StateManager {
|
|
|
9383
9524
|
project.config.name
|
|
9384
9525
|
);
|
|
9385
9526
|
fileTask.local = true;
|
|
9527
|
+
TestFile.register(fileTask, project);
|
|
9386
9528
|
this.idMap.set(fileTask.id, fileTask);
|
|
9387
9529
|
if (!files) {
|
|
9388
9530
|
this.filesMap.set(path, [fileTask]);
|
|
@@ -9398,24 +9540,34 @@ class StateManager {
|
|
|
9398
9540
|
}
|
|
9399
9541
|
});
|
|
9400
9542
|
}
|
|
9401
|
-
updateId(task) {
|
|
9543
|
+
updateId(task, project) {
|
|
9402
9544
|
if (this.idMap.get(task.id) === task) {
|
|
9403
9545
|
return;
|
|
9404
9546
|
}
|
|
9547
|
+
if (task.type === "suite" && "filepath" in task) {
|
|
9548
|
+
TestFile.register(task, project);
|
|
9549
|
+
} else if (task.type === "suite") {
|
|
9550
|
+
TestSuite.register(task, project);
|
|
9551
|
+
} else {
|
|
9552
|
+
TestCase.register(task, project);
|
|
9553
|
+
}
|
|
9405
9554
|
this.idMap.set(task.id, task);
|
|
9406
9555
|
if (task.type === "suite") {
|
|
9407
9556
|
task.tasks.forEach((task2) => {
|
|
9408
|
-
this.updateId(task2);
|
|
9557
|
+
this.updateId(task2, project);
|
|
9409
9558
|
});
|
|
9410
9559
|
}
|
|
9411
9560
|
}
|
|
9561
|
+
getReportedEntity(task) {
|
|
9562
|
+
return this.reportedTasksMap.get(task);
|
|
9563
|
+
}
|
|
9412
9564
|
updateTasks(packs) {
|
|
9413
9565
|
for (const [id, result, meta] of packs) {
|
|
9414
9566
|
const task = this.idMap.get(id);
|
|
9415
9567
|
if (task) {
|
|
9416
9568
|
task.result = result;
|
|
9417
9569
|
task.meta = meta;
|
|
9418
|
-
if (
|
|
9570
|
+
if (result?.state === "skip") {
|
|
9419
9571
|
task.mode = "skip";
|
|
9420
9572
|
}
|
|
9421
9573
|
}
|
|
@@ -9432,15 +9584,15 @@ class StateManager {
|
|
|
9432
9584
|
}
|
|
9433
9585
|
getCountOfFailedTests() {
|
|
9434
9586
|
return Array.from(this.idMap.values()).filter(
|
|
9435
|
-
(t) =>
|
|
9436
|
-
var _a;
|
|
9437
|
-
return ((_a = t.result) == null ? void 0 : _a.state) === "fail";
|
|
9438
|
-
}
|
|
9587
|
+
(t) => t.result?.state === "fail"
|
|
9439
9588
|
).length;
|
|
9440
9589
|
}
|
|
9441
|
-
cancelFiles(files,
|
|
9590
|
+
cancelFiles(files, project) {
|
|
9442
9591
|
this.collectFiles(
|
|
9443
|
-
|
|
9592
|
+
project,
|
|
9593
|
+
files.map(
|
|
9594
|
+
(filepath) => createFileTask(filepath, project.config.root, project.config.name)
|
|
9595
|
+
)
|
|
9444
9596
|
);
|
|
9445
9597
|
}
|
|
9446
9598
|
}
|
|
@@ -11552,7 +11704,6 @@ function resolvePackage(name, options = {}) {
|
|
|
11552
11704
|
}
|
|
11553
11705
|
}
|
|
11554
11706
|
|
|
11555
|
-
var _a, _b;
|
|
11556
11707
|
const defaultInclude = ["**/*.{test,spec}.?(c|m)[jt]s?(x)"];
|
|
11557
11708
|
const defaultExclude = [
|
|
11558
11709
|
"**/node_modules/**",
|
|
@@ -11607,7 +11758,6 @@ const coverageConfigDefaults = {
|
|
|
11607
11758
|
".mjs",
|
|
11608
11759
|
".ts",
|
|
11609
11760
|
".mts",
|
|
11610
|
-
".cts",
|
|
11611
11761
|
".tsx",
|
|
11612
11762
|
".jsx",
|
|
11613
11763
|
".vue",
|
|
@@ -11618,7 +11768,7 @@ const coverageConfigDefaults = {
|
|
|
11618
11768
|
ignoreEmptyLines: true,
|
|
11619
11769
|
processingConcurrency: Math.min(
|
|
11620
11770
|
20,
|
|
11621
|
-
|
|
11771
|
+
nodeos__default.availableParallelism?.() ?? nodeos__default.cpus().length
|
|
11622
11772
|
)
|
|
11623
11773
|
};
|
|
11624
11774
|
const fakeTimersDefaults = {
|
|
@@ -11644,6 +11794,8 @@ const config = {
|
|
|
11644
11794
|
clearMocks: false,
|
|
11645
11795
|
restoreMocks: false,
|
|
11646
11796
|
mockReset: false,
|
|
11797
|
+
unstubGlobals: false,
|
|
11798
|
+
unstubEnvs: false,
|
|
11647
11799
|
include: defaultInclude,
|
|
11648
11800
|
exclude: defaultExclude,
|
|
11649
11801
|
teardownTimeout: 1e4,
|
|
@@ -11674,8 +11826,7 @@ const config = {
|
|
|
11674
11826
|
const configDefaults = Object.freeze(config);
|
|
11675
11827
|
|
|
11676
11828
|
function getWorkersCountByPercentage(percent) {
|
|
11677
|
-
|
|
11678
|
-
const maxWorkersCount = ((_b = (_a = nodeos__default).availableParallelism) == null ? void 0 : _b.call(_a)) ?? nodeos__default.cpus().length;
|
|
11829
|
+
const maxWorkersCount = nodeos__default.availableParallelism?.() ?? nodeos__default.cpus().length;
|
|
11679
11830
|
const workersCountByPercentage = Math.round(Number.parseInt(percent) / 100 * maxWorkersCount);
|
|
11680
11831
|
return Math.max(1, Math.min(maxWorkersCount, workersCountByPercentage));
|
|
11681
11832
|
}
|
|
@@ -11873,9 +12024,8 @@ function resolveInlineWorkerOption(value) {
|
|
|
11873
12024
|
}
|
|
11874
12025
|
}
|
|
11875
12026
|
function resolveConfig(mode, options, viteConfig, logger) {
|
|
11876
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U;
|
|
11877
12027
|
if (options.dom) {
|
|
11878
|
-
if (
|
|
12028
|
+
if (viteConfig.test?.environment != null && viteConfig.test.environment !== "happy-dom") {
|
|
11879
12029
|
logger.console.warn(
|
|
11880
12030
|
c.yellow(
|
|
11881
12031
|
`${c.inverse(c.yellow(" Vitest "))} Your config.test.environment ("${viteConfig.test.environment}") conflicts with --dom flag ("happy-dom"), ignoring "${viteConfig.test.environment}"`
|
|
@@ -11895,7 +12045,7 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
11895
12045
|
...resolved.inspector,
|
|
11896
12046
|
...parseInspector(inspector),
|
|
11897
12047
|
enabled: !!inspector,
|
|
11898
|
-
waitForDebugger:
|
|
12048
|
+
waitForDebugger: options.inspector?.waitForDebugger ?? !!resolved.inspectBrk
|
|
11899
12049
|
};
|
|
11900
12050
|
if (viteConfig.base !== "/") {
|
|
11901
12051
|
resolved.base = viteConfig.base;
|
|
@@ -11930,15 +12080,15 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
11930
12080
|
if (resolved.minWorkers) {
|
|
11931
12081
|
resolved.minWorkers = resolveInlineWorkerOption(resolved.minWorkers);
|
|
11932
12082
|
}
|
|
11933
|
-
resolved.browser
|
|
11934
|
-
resolved.fileParallelism
|
|
12083
|
+
resolved.browser ??= {};
|
|
12084
|
+
resolved.fileParallelism ??= mode !== "benchmark";
|
|
11935
12085
|
if (!resolved.fileParallelism) {
|
|
11936
12086
|
resolved.maxWorkers = 1;
|
|
11937
12087
|
resolved.minWorkers = 1;
|
|
11938
12088
|
}
|
|
11939
12089
|
if (resolved.inspect || resolved.inspectBrk) {
|
|
11940
|
-
const isSingleThread = resolved.pool === "threads" &&
|
|
11941
|
-
const isSingleFork = resolved.pool === "forks" &&
|
|
12090
|
+
const isSingleThread = resolved.pool === "threads" && resolved.poolOptions?.threads?.singleThread;
|
|
12091
|
+
const isSingleFork = resolved.pool === "forks" && resolved.poolOptions?.forks?.singleFork;
|
|
11942
12092
|
if (resolved.fileParallelism && !isSingleThread && !isSingleFork) {
|
|
11943
12093
|
const inspectOption = `--inspect${resolved.inspectBrk ? "-brk" : ""}`;
|
|
11944
12094
|
throw new Error(
|
|
@@ -11968,9 +12118,9 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
11968
12118
|
resolved.root
|
|
11969
12119
|
);
|
|
11970
12120
|
}
|
|
11971
|
-
resolved.expect
|
|
11972
|
-
resolved.deps
|
|
11973
|
-
|
|
12121
|
+
resolved.expect ??= {};
|
|
12122
|
+
resolved.deps ??= {};
|
|
12123
|
+
resolved.deps.moduleDirectories ??= [];
|
|
11974
12124
|
resolved.deps.moduleDirectories = resolved.deps.moduleDirectories.map(
|
|
11975
12125
|
(dir) => {
|
|
11976
12126
|
if (!dir.startsWith("/")) {
|
|
@@ -11985,17 +12135,17 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
11985
12135
|
if (!resolved.deps.moduleDirectories.includes("/node_modules/")) {
|
|
11986
12136
|
resolved.deps.moduleDirectories.push("/node_modules/");
|
|
11987
12137
|
}
|
|
11988
|
-
|
|
11989
|
-
|
|
11990
|
-
|
|
11991
|
-
|
|
11992
|
-
|
|
11993
|
-
|
|
11994
|
-
|
|
11995
|
-
|
|
11996
|
-
|
|
11997
|
-
resolved.server
|
|
11998
|
-
|
|
12138
|
+
resolved.deps.optimizer ??= {};
|
|
12139
|
+
resolved.deps.optimizer.ssr ??= {};
|
|
12140
|
+
resolved.deps.optimizer.ssr.enabled ??= true;
|
|
12141
|
+
resolved.deps.optimizer.web ??= {};
|
|
12142
|
+
resolved.deps.optimizer.web.enabled ??= true;
|
|
12143
|
+
resolved.deps.web ??= {};
|
|
12144
|
+
resolved.deps.web.transformAssets ??= true;
|
|
12145
|
+
resolved.deps.web.transformCss ??= true;
|
|
12146
|
+
resolved.deps.web.transformGlobPattern ??= [];
|
|
12147
|
+
resolved.server ??= {};
|
|
12148
|
+
resolved.server.deps ??= {};
|
|
11999
12149
|
const deprecatedDepsOptions = ["inline", "external", "fallbackCJS"];
|
|
12000
12150
|
deprecatedDepsOptions.forEach((option) => {
|
|
12001
12151
|
if (resolved.deps[option] === void 0) {
|
|
@@ -12028,14 +12178,14 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
12028
12178
|
}
|
|
12029
12179
|
if (resolved.server.deps.inline !== true) {
|
|
12030
12180
|
const ssrOptions = viteConfig.ssr;
|
|
12031
|
-
if (
|
|
12181
|
+
if (ssrOptions?.noExternal === true && resolved.server.deps.inline == null) {
|
|
12032
12182
|
resolved.server.deps.inline = true;
|
|
12033
12183
|
} else {
|
|
12034
|
-
|
|
12184
|
+
resolved.server.deps.inline ??= [];
|
|
12035
12185
|
resolved.server.deps.inline.push(...extraInlineDeps);
|
|
12036
12186
|
}
|
|
12037
12187
|
}
|
|
12038
|
-
|
|
12188
|
+
resolved.server.deps.moduleDirectories ??= [];
|
|
12039
12189
|
resolved.server.deps.moduleDirectories.push(
|
|
12040
12190
|
...resolved.deps.moduleDirectories
|
|
12041
12191
|
);
|
|
@@ -12061,7 +12211,7 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
12061
12211
|
// resolved inside the worker
|
|
12062
12212
|
snapshotEnvironment: null
|
|
12063
12213
|
};
|
|
12064
|
-
resolved.snapshotSerializers
|
|
12214
|
+
resolved.snapshotSerializers ??= [];
|
|
12065
12215
|
resolved.snapshotSerializers = resolved.snapshotSerializers.map(
|
|
12066
12216
|
(file) => resolvePath(file, resolved.root)
|
|
12067
12217
|
);
|
|
@@ -12069,16 +12219,16 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
12069
12219
|
if (options.resolveSnapshotPath) {
|
|
12070
12220
|
delete resolved.resolveSnapshotPath;
|
|
12071
12221
|
}
|
|
12072
|
-
resolved.pool
|
|
12222
|
+
resolved.pool ??= "threads";
|
|
12073
12223
|
if (process.env.VITEST_MAX_THREADS) {
|
|
12074
12224
|
resolved.poolOptions = {
|
|
12075
12225
|
...resolved.poolOptions,
|
|
12076
12226
|
threads: {
|
|
12077
|
-
...
|
|
12227
|
+
...resolved.poolOptions?.threads,
|
|
12078
12228
|
maxThreads: Number.parseInt(process.env.VITEST_MAX_THREADS)
|
|
12079
12229
|
},
|
|
12080
12230
|
vmThreads: {
|
|
12081
|
-
...
|
|
12231
|
+
...resolved.poolOptions?.vmThreads,
|
|
12082
12232
|
maxThreads: Number.parseInt(process.env.VITEST_MAX_THREADS)
|
|
12083
12233
|
}
|
|
12084
12234
|
};
|
|
@@ -12087,11 +12237,11 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
12087
12237
|
resolved.poolOptions = {
|
|
12088
12238
|
...resolved.poolOptions,
|
|
12089
12239
|
threads: {
|
|
12090
|
-
...
|
|
12240
|
+
...resolved.poolOptions?.threads,
|
|
12091
12241
|
minThreads: Number.parseInt(process.env.VITEST_MIN_THREADS)
|
|
12092
12242
|
},
|
|
12093
12243
|
vmThreads: {
|
|
12094
|
-
...
|
|
12244
|
+
...resolved.poolOptions?.vmThreads,
|
|
12095
12245
|
minThreads: Number.parseInt(process.env.VITEST_MIN_THREADS)
|
|
12096
12246
|
}
|
|
12097
12247
|
};
|
|
@@ -12100,11 +12250,11 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
12100
12250
|
resolved.poolOptions = {
|
|
12101
12251
|
...resolved.poolOptions,
|
|
12102
12252
|
forks: {
|
|
12103
|
-
...
|
|
12253
|
+
...resolved.poolOptions?.forks,
|
|
12104
12254
|
maxForks: Number.parseInt(process.env.VITEST_MAX_FORKS)
|
|
12105
12255
|
},
|
|
12106
12256
|
vmForks: {
|
|
12107
|
-
...
|
|
12257
|
+
...resolved.poolOptions?.vmForks,
|
|
12108
12258
|
maxForks: Number.parseInt(process.env.VITEST_MAX_FORKS)
|
|
12109
12259
|
}
|
|
12110
12260
|
};
|
|
@@ -12113,11 +12263,11 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
12113
12263
|
resolved.poolOptions = {
|
|
12114
12264
|
...resolved.poolOptions,
|
|
12115
12265
|
forks: {
|
|
12116
|
-
...
|
|
12266
|
+
...resolved.poolOptions?.forks,
|
|
12117
12267
|
minForks: Number.parseInt(process.env.VITEST_MIN_FORKS)
|
|
12118
12268
|
},
|
|
12119
12269
|
vmForks: {
|
|
12120
|
-
...
|
|
12270
|
+
...resolved.poolOptions?.vmForks,
|
|
12121
12271
|
minForks: Number.parseInt(process.env.VITEST_MIN_FORKS)
|
|
12122
12272
|
}
|
|
12123
12273
|
};
|
|
@@ -12129,7 +12279,7 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
12129
12279
|
["vmThreads", "maxThreads"]
|
|
12130
12280
|
];
|
|
12131
12281
|
for (const [poolOptionKey, workerOptionKey] of poolThreadsOptions) {
|
|
12132
|
-
if (
|
|
12282
|
+
if (resolved.poolOptions?.[poolOptionKey]?.[workerOptionKey]) {
|
|
12133
12283
|
resolved.poolOptions[poolOptionKey][workerOptionKey] = resolveInlineWorkerOption(resolved.poolOptions[poolOptionKey][workerOptionKey]);
|
|
12134
12284
|
}
|
|
12135
12285
|
}
|
|
@@ -12140,7 +12290,7 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
12140
12290
|
["vmForks", "maxForks"]
|
|
12141
12291
|
];
|
|
12142
12292
|
for (const [poolOptionKey, workerOptionKey] of poolForksOptions) {
|
|
12143
|
-
if (
|
|
12293
|
+
if (resolved.poolOptions?.[poolOptionKey]?.[workerOptionKey]) {
|
|
12144
12294
|
resolved.poolOptions[poolOptionKey][workerOptionKey] = resolveInlineWorkerOption(resolved.poolOptions[poolOptionKey][workerOptionKey]);
|
|
12145
12295
|
}
|
|
12146
12296
|
}
|
|
@@ -12258,12 +12408,12 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
12258
12408
|
}
|
|
12259
12409
|
}
|
|
12260
12410
|
if (resolved.changed) {
|
|
12261
|
-
resolved.passWithNoTests
|
|
12411
|
+
resolved.passWithNoTests ??= true;
|
|
12262
12412
|
}
|
|
12263
|
-
resolved.css
|
|
12413
|
+
resolved.css ??= {};
|
|
12264
12414
|
if (typeof resolved.css === "object") {
|
|
12265
|
-
|
|
12266
|
-
|
|
12415
|
+
resolved.css.modules ??= {};
|
|
12416
|
+
resolved.css.modules.classNameStrategy ??= "stable";
|
|
12267
12417
|
}
|
|
12268
12418
|
if (resolved.cache !== false) {
|
|
12269
12419
|
let cacheDir = VitestCache.resolveCacheDir(
|
|
@@ -12287,18 +12437,18 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
12287
12437
|
}
|
|
12288
12438
|
resolved.cache = { dir: cacheDir };
|
|
12289
12439
|
}
|
|
12290
|
-
resolved.sequence
|
|
12440
|
+
resolved.sequence ??= {};
|
|
12291
12441
|
if (resolved.sequence.shuffle && typeof resolved.sequence.shuffle === "object") {
|
|
12292
12442
|
const { files, tests } = resolved.sequence.shuffle;
|
|
12293
|
-
|
|
12443
|
+
resolved.sequence.sequencer ??= files ? RandomSequencer : BaseSequencer;
|
|
12294
12444
|
resolved.sequence.shuffle = tests;
|
|
12295
12445
|
}
|
|
12296
|
-
if (!
|
|
12446
|
+
if (!resolved.sequence?.sequencer) {
|
|
12297
12447
|
resolved.sequence.sequencer = resolved.sequence.shuffle ? RandomSequencer : BaseSequencer;
|
|
12298
12448
|
}
|
|
12299
|
-
|
|
12449
|
+
resolved.sequence.hooks ??= "stack";
|
|
12300
12450
|
if (resolved.sequence.sequencer === RandomSequencer) {
|
|
12301
|
-
|
|
12451
|
+
resolved.sequence.seed ??= Date.now();
|
|
12302
12452
|
}
|
|
12303
12453
|
resolved.typecheck = {
|
|
12304
12454
|
...configDefaults.typecheck,
|
|
@@ -12307,8 +12457,8 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
12307
12457
|
resolved.environmentMatchGlobs = (resolved.environmentMatchGlobs || []).map(
|
|
12308
12458
|
(i) => [resolve(resolved.root, i[0]), i[1]]
|
|
12309
12459
|
);
|
|
12310
|
-
resolved.typecheck
|
|
12311
|
-
|
|
12460
|
+
resolved.typecheck ??= {};
|
|
12461
|
+
resolved.typecheck.enabled ??= false;
|
|
12312
12462
|
if (resolved.typecheck.enabled) {
|
|
12313
12463
|
logger.console.warn(
|
|
12314
12464
|
c.yellow(
|
|
@@ -12316,12 +12466,12 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
12316
12466
|
)
|
|
12317
12467
|
);
|
|
12318
12468
|
}
|
|
12319
|
-
resolved.browser
|
|
12320
|
-
|
|
12321
|
-
|
|
12322
|
-
|
|
12323
|
-
|
|
12324
|
-
|
|
12469
|
+
resolved.browser ??= {};
|
|
12470
|
+
resolved.browser.enabled ??= false;
|
|
12471
|
+
resolved.browser.headless ??= isCI;
|
|
12472
|
+
resolved.browser.isolate ??= true;
|
|
12473
|
+
resolved.browser.fileParallelism ??= options.fileParallelism ?? mode !== "benchmark";
|
|
12474
|
+
resolved.browser.ui ??= resolved.browser.headless === true ? false : !isCI;
|
|
12325
12475
|
if (resolved.browser.screenshotDirectory) {
|
|
12326
12476
|
resolved.browser.screenshotDirectory = resolve(
|
|
12327
12477
|
resolved.root,
|
|
@@ -12339,11 +12489,11 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
12339
12489
|
));
|
|
12340
12490
|
resolved.browser.screenshotFailures = false;
|
|
12341
12491
|
} else {
|
|
12342
|
-
|
|
12492
|
+
resolved.browser.screenshotFailures ??= !isPreview && !resolved.browser.ui;
|
|
12343
12493
|
}
|
|
12344
|
-
|
|
12345
|
-
|
|
12346
|
-
|
|
12494
|
+
resolved.browser.viewport ??= {};
|
|
12495
|
+
resolved.browser.viewport.width ??= 414;
|
|
12496
|
+
resolved.browser.viewport.height ??= 896;
|
|
12347
12497
|
if (resolved.browser.enabled && provider$1 === "stackblitz") {
|
|
12348
12498
|
resolved.browser.provider = "preview";
|
|
12349
12499
|
}
|
|
@@ -12355,10 +12505,10 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
12355
12505
|
};
|
|
12356
12506
|
if (resolved.browser.enabled) {
|
|
12357
12507
|
if (resolved.browser.ui) {
|
|
12358
|
-
resolved.includeTaskLocation
|
|
12508
|
+
resolved.includeTaskLocation ??= true;
|
|
12359
12509
|
}
|
|
12360
12510
|
} else if (resolved.ui) {
|
|
12361
|
-
resolved.includeTaskLocation
|
|
12511
|
+
resolved.includeTaskLocation ??= true;
|
|
12362
12512
|
}
|
|
12363
12513
|
const htmlReporter = toArray(resolved.reporters).some((reporter) => {
|
|
12364
12514
|
if (Array.isArray(reporter)) {
|
|
@@ -12367,16 +12517,15 @@ function resolveConfig(mode, options, viteConfig, logger) {
|
|
|
12367
12517
|
return false;
|
|
12368
12518
|
});
|
|
12369
12519
|
if (htmlReporter) {
|
|
12370
|
-
resolved.includeTaskLocation
|
|
12520
|
+
resolved.includeTaskLocation ??= true;
|
|
12371
12521
|
}
|
|
12372
|
-
resolved.testTransformMode
|
|
12373
|
-
resolved.testTimeout
|
|
12374
|
-
resolved.hookTimeout
|
|
12522
|
+
resolved.testTransformMode ??= {};
|
|
12523
|
+
resolved.testTimeout ??= resolved.browser.enabled ? 15e3 : 5e3;
|
|
12524
|
+
resolved.hookTimeout ??= resolved.browser.enabled ? 3e4 : 1e4;
|
|
12375
12525
|
return resolved;
|
|
12376
12526
|
}
|
|
12377
12527
|
function isBrowserEnabled(config) {
|
|
12378
|
-
|
|
12379
|
-
return Boolean((_a = config.browser) == null ? void 0 : _a.enabled);
|
|
12528
|
+
return Boolean(config.browser?.enabled);
|
|
12380
12529
|
}
|
|
12381
12530
|
|
|
12382
12531
|
function generateCssFilenameHash(filepath) {
|
|
@@ -12397,9 +12546,7 @@ function CoverageTransform(ctx) {
|
|
|
12397
12546
|
return {
|
|
12398
12547
|
name: "vitest:coverage-transform",
|
|
12399
12548
|
transform(srcCode, id) {
|
|
12400
|
-
|
|
12401
|
-
return (_b = (_a = ctx.coverageProvider) == null ? void 0 : _a.onFileTransform) == null ? void 0 : _b.call(
|
|
12402
|
-
_a,
|
|
12549
|
+
return ctx.coverageProvider?.onFileTransform?.(
|
|
12403
12550
|
srcCode,
|
|
12404
12551
|
normalizeRequestId(id),
|
|
12405
12552
|
this
|
|
@@ -12459,12 +12606,11 @@ function CSSEnablerPlugin(ctx) {
|
|
|
12459
12606
|
name: "vitest:css-empty-post",
|
|
12460
12607
|
enforce: "post",
|
|
12461
12608
|
transform(_, id) {
|
|
12462
|
-
var _a;
|
|
12463
12609
|
if (!isCSS(id) || shouldProcessCSS(id)) {
|
|
12464
12610
|
return;
|
|
12465
12611
|
}
|
|
12466
12612
|
if (isCSSModule(id) && !isInline(id)) {
|
|
12467
|
-
const scopeStrategy = typeof ctx.config.css !== "boolean" &&
|
|
12613
|
+
const scopeStrategy = typeof ctx.config.css !== "boolean" && ctx.config.css.modules?.classNameStrategy || "stable";
|
|
12468
12614
|
const proxyReturn = getCSSModuleProxyReturn(
|
|
12469
12615
|
scopeStrategy,
|
|
12470
12616
|
relative(ctx.config.root, id)
|
|
@@ -12969,7 +13115,7 @@ function SsrReplacerPlugin() {
|
|
|
12969
13115
|
const cleanCode = stripLiteral(code);
|
|
12970
13116
|
const envs = cleanCode.matchAll(/\bimport\.meta\.env\b/g);
|
|
12971
13117
|
for (const env of envs) {
|
|
12972
|
-
s
|
|
13118
|
+
s ||= new MagicString(code);
|
|
12973
13119
|
const startIndex = env.index;
|
|
12974
13120
|
const endIndex = startIndex + env[0].length;
|
|
12975
13121
|
s.overwrite(startIndex, endIndex, "__vite_ssr_import_meta__.env");
|
|
@@ -13032,7 +13178,6 @@ function getBetterEnd(code, node) {
|
|
|
13032
13178
|
const regexpHoistable = /\b(?:vi|vitest)\s*\.\s*(?:mock|unmock|hoisted|doMock|doUnmock)\(/;
|
|
13033
13179
|
const hashbangRE = /^#!.*\n/;
|
|
13034
13180
|
function hoistMocks(code, id, parse, colors) {
|
|
13035
|
-
var _a;
|
|
13036
13181
|
const needHoisting = regexpHoistable.test(code);
|
|
13037
13182
|
if (!needHoisting) {
|
|
13038
13183
|
return;
|
|
@@ -13046,7 +13191,7 @@ function hoistMocks(code, id, parse, colors) {
|
|
|
13046
13191
|
${err.message}`);
|
|
13047
13192
|
return;
|
|
13048
13193
|
}
|
|
13049
|
-
const hoistIndex =
|
|
13194
|
+
const hoistIndex = code.match(hashbangRE)?.[0].length ?? 0;
|
|
13050
13195
|
let hoistedVitestImports = "";
|
|
13051
13196
|
let uid = 0;
|
|
13052
13197
|
const idToImportMap = /* @__PURE__ */ new Map();
|
|
@@ -13117,35 +13262,32 @@ ${err.message}`);
|
|
|
13117
13262
|
};
|
|
13118
13263
|
}
|
|
13119
13264
|
function assertNotDefaultExport(node, error) {
|
|
13120
|
-
|
|
13121
|
-
const defaultExport = (_a2 = findNodeAround(
|
|
13265
|
+
const defaultExport = findNodeAround(
|
|
13122
13266
|
ast,
|
|
13123
13267
|
node.start,
|
|
13124
13268
|
"ExportDefaultDeclaration"
|
|
13125
|
-
)
|
|
13126
|
-
if (
|
|
13269
|
+
)?.node;
|
|
13270
|
+
if (defaultExport?.declaration === node || defaultExport?.declaration.type === "AwaitExpression" && defaultExport.declaration.argument === node) {
|
|
13127
13271
|
throw createSyntaxError(defaultExport, error);
|
|
13128
13272
|
}
|
|
13129
13273
|
}
|
|
13130
13274
|
function assertNotNamedExport(node, error) {
|
|
13131
|
-
|
|
13132
|
-
const nodeExported = (_a2 = findNodeAround(
|
|
13275
|
+
const nodeExported = findNodeAround(
|
|
13133
13276
|
ast,
|
|
13134
13277
|
node.start,
|
|
13135
13278
|
"ExportNamedDeclaration"
|
|
13136
|
-
)
|
|
13137
|
-
if (
|
|
13279
|
+
)?.node;
|
|
13280
|
+
if (nodeExported?.declaration === node) {
|
|
13138
13281
|
throw createSyntaxError(nodeExported, error);
|
|
13139
13282
|
}
|
|
13140
13283
|
}
|
|
13141
13284
|
function getVariableDeclaration(node) {
|
|
13142
|
-
|
|
13143
|
-
const declarationNode = (_a2 = findNodeAround(
|
|
13285
|
+
const declarationNode = findNodeAround(
|
|
13144
13286
|
ast,
|
|
13145
13287
|
node.start,
|
|
13146
13288
|
"VariableDeclaration"
|
|
13147
|
-
)
|
|
13148
|
-
const init =
|
|
13289
|
+
)?.node;
|
|
13290
|
+
const init = declarationNode?.declarations[0]?.init;
|
|
13149
13291
|
if (init && (init === node || init.type === "AwaitExpression" && init.argument === node)) {
|
|
13150
13292
|
return declarationNode;
|
|
13151
13293
|
}
|
|
@@ -13173,7 +13315,6 @@ ${err.message}`);
|
|
|
13173
13315
|
}
|
|
13174
13316
|
},
|
|
13175
13317
|
onCallExpression(node) {
|
|
13176
|
-
var _a2;
|
|
13177
13318
|
if (node.callee.type === "MemberExpression" && isIdentifier(node.callee.object) && (node.callee.object.name === "vi" || node.callee.object.name === "vitest") && isIdentifier(node.callee.property)) {
|
|
13178
13319
|
const methodName = node.callee.property.name;
|
|
13179
13320
|
if (methodName === "mock" || methodName === "unmock") {
|
|
@@ -13221,13 +13362,13 @@ ${err.message}`);
|
|
|
13221
13362
|
);
|
|
13222
13363
|
hoistedNodes.push(declarationNode);
|
|
13223
13364
|
} else {
|
|
13224
|
-
const awaitedExpression =
|
|
13365
|
+
const awaitedExpression = findNodeAround(
|
|
13225
13366
|
ast,
|
|
13226
13367
|
node.start,
|
|
13227
13368
|
"AwaitExpression"
|
|
13228
|
-
)
|
|
13369
|
+
)?.node;
|
|
13229
13370
|
hoistedNodes.push(
|
|
13230
|
-
|
|
13371
|
+
awaitedExpression?.argument === node ? awaitedExpression : node
|
|
13231
13372
|
);
|
|
13232
13373
|
}
|
|
13233
13374
|
}
|
|
@@ -13468,19 +13609,18 @@ function MocksPlugins() {
|
|
|
13468
13609
|
}
|
|
13469
13610
|
|
|
13470
13611
|
function resolveOptimizerConfig(_testOptions, viteOptions, testConfig) {
|
|
13471
|
-
var _a;
|
|
13472
13612
|
const testOptions = _testOptions || {};
|
|
13473
13613
|
const newConfig = {};
|
|
13474
13614
|
const [major, minor, fix] = version.split(".").map(Number);
|
|
13475
13615
|
const allowed = major >= 5 || major === 4 && minor >= 4 || major === 4 && minor === 3 && fix >= 2;
|
|
13476
|
-
if (!allowed &&
|
|
13616
|
+
if (!allowed && testOptions?.enabled === true) {
|
|
13477
13617
|
console.warn(
|
|
13478
13618
|
`Vitest: "deps.optimizer" is only available in Vite >= 4.3.2, current Vite version: ${version}`
|
|
13479
13619
|
);
|
|
13480
13620
|
} else {
|
|
13481
|
-
testOptions.enabled
|
|
13621
|
+
testOptions.enabled ??= false;
|
|
13482
13622
|
}
|
|
13483
|
-
if (!allowed ||
|
|
13623
|
+
if (!allowed || testOptions?.enabled !== true) {
|
|
13484
13624
|
newConfig.cacheDir = void 0;
|
|
13485
13625
|
newConfig.optimizeDeps = {
|
|
13486
13626
|
// experimental in Vite >2.9.2, entries remains to help with older versions
|
|
@@ -13489,20 +13629,20 @@ function resolveOptimizerConfig(_testOptions, viteOptions, testConfig) {
|
|
|
13489
13629
|
};
|
|
13490
13630
|
} else {
|
|
13491
13631
|
const root = testConfig.root ?? process.cwd();
|
|
13492
|
-
const cacheDir = testConfig.cache !== false ?
|
|
13493
|
-
const currentInclude = testOptions.include ||
|
|
13632
|
+
const cacheDir = testConfig.cache !== false ? testConfig.cache?.dir : void 0;
|
|
13633
|
+
const currentInclude = testOptions.include || viteOptions?.include || [];
|
|
13494
13634
|
const exclude = [
|
|
13495
13635
|
"vitest",
|
|
13496
13636
|
// Ideally, we shouldn't optimize react in test mode, otherwise we need to optimize _every_ dependency that uses react.
|
|
13497
13637
|
"react",
|
|
13498
13638
|
"vue",
|
|
13499
|
-
...testOptions.exclude ||
|
|
13639
|
+
...testOptions.exclude || viteOptions?.exclude || []
|
|
13500
13640
|
];
|
|
13501
13641
|
const runtime = currentInclude.filter(
|
|
13502
13642
|
(n) => n.endsWith("jsx-dev-runtime") || n.endsWith("jsx-runtime")
|
|
13503
13643
|
);
|
|
13504
13644
|
exclude.push(...runtime);
|
|
13505
|
-
const include = (testOptions.include ||
|
|
13645
|
+
const include = (testOptions.include || viteOptions?.include || []).filter(
|
|
13506
13646
|
(n) => !exclude.includes(n)
|
|
13507
13647
|
);
|
|
13508
13648
|
newConfig.cacheDir = cacheDir ?? VitestCache.resolveCacheDir(root, cacheDir, testConfig.name);
|
|
@@ -13598,21 +13738,20 @@ function VitestOptimizer() {
|
|
|
13598
13738
|
config: {
|
|
13599
13739
|
order: "post",
|
|
13600
13740
|
handler(viteConfig) {
|
|
13601
|
-
var _a, _b, _c, _d, _e;
|
|
13602
13741
|
const testConfig = viteConfig.test || {};
|
|
13603
13742
|
const webOptimizer = resolveOptimizerConfig(
|
|
13604
|
-
|
|
13743
|
+
testConfig.deps?.optimizer?.web,
|
|
13605
13744
|
viteConfig.optimizeDeps,
|
|
13606
13745
|
testConfig
|
|
13607
13746
|
);
|
|
13608
13747
|
const ssrOptimizer = resolveOptimizerConfig(
|
|
13609
|
-
|
|
13610
|
-
|
|
13748
|
+
testConfig.deps?.optimizer?.ssr,
|
|
13749
|
+
viteConfig.ssr?.optimizeDeps,
|
|
13611
13750
|
testConfig
|
|
13612
13751
|
);
|
|
13613
13752
|
viteConfig.cacheDir = webOptimizer.cacheDir || ssrOptimizer.cacheDir || viteConfig.cacheDir;
|
|
13614
13753
|
viteConfig.optimizeDeps = webOptimizer.optimizeDeps;
|
|
13615
|
-
viteConfig.ssr
|
|
13754
|
+
viteConfig.ssr ??= {};
|
|
13616
13755
|
viteConfig.ssr.optimizeDeps = ssrOptimizer.optimizeDeps;
|
|
13617
13756
|
}
|
|
13618
13757
|
}
|
|
@@ -13626,7 +13765,7 @@ function NormalizeURLPlugin() {
|
|
|
13626
13765
|
name: "vitest:normalize-url",
|
|
13627
13766
|
enforce: "post",
|
|
13628
13767
|
transform(code, id, options) {
|
|
13629
|
-
const ssr =
|
|
13768
|
+
const ssr = options?.ssr === true;
|
|
13630
13769
|
if (ssr || !code.includes("new URL") || !code.includes("import.meta.url")) {
|
|
13631
13770
|
return;
|
|
13632
13771
|
}
|
|
@@ -13656,7 +13795,6 @@ function WorkspaceVitestPlugin(project, options) {
|
|
|
13656
13795
|
this.meta.watchMode = false;
|
|
13657
13796
|
},
|
|
13658
13797
|
config(viteConfig) {
|
|
13659
|
-
var _a, _b, _c, _d;
|
|
13660
13798
|
const defines = deleteDefineConfig(viteConfig);
|
|
13661
13799
|
const testConfig = viteConfig.test || {};
|
|
13662
13800
|
const root = testConfig.root || viteConfig.root || options.root;
|
|
@@ -13686,7 +13824,7 @@ function WorkspaceVitestPlugin(project, options) {
|
|
|
13686
13824
|
},
|
|
13687
13825
|
esbuild: viteConfig.esbuild === false ? false : {
|
|
13688
13826
|
// Lowest target Vitest supports is Node18
|
|
13689
|
-
target:
|
|
13827
|
+
target: viteConfig.esbuild?.target || "node18",
|
|
13690
13828
|
sourcemap: "external",
|
|
13691
13829
|
// Enables using ignore hint for coverage providers with @preserve keyword
|
|
13692
13830
|
legalComments: "inline"
|
|
@@ -13711,10 +13849,10 @@ function WorkspaceVitestPlugin(project, options) {
|
|
|
13711
13849
|
}
|
|
13712
13850
|
};
|
|
13713
13851
|
config.test.defines = defines;
|
|
13714
|
-
const classNameStrategy = typeof testConfig.css !== "boolean" &&
|
|
13852
|
+
const classNameStrategy = typeof testConfig.css !== "boolean" && testConfig.css?.modules?.classNameStrategy || "stable";
|
|
13715
13853
|
if (classNameStrategy !== "scoped") {
|
|
13716
|
-
config.css
|
|
13717
|
-
|
|
13854
|
+
config.css ??= {};
|
|
13855
|
+
config.css.modules ??= {};
|
|
13718
13856
|
if (config.css.modules) {
|
|
13719
13857
|
config.css.modules.generateScopedName = (name2, filename) => {
|
|
13720
13858
|
const root2 = project.config.root;
|
|
@@ -13796,8 +13934,127 @@ async function loadGlobalSetupFile(file, runner) {
|
|
|
13796
13934
|
}
|
|
13797
13935
|
}
|
|
13798
13936
|
|
|
13937
|
+
function serializeConfig(config, coreConfig, viteConfig) {
|
|
13938
|
+
const optimizer = config.deps?.optimizer;
|
|
13939
|
+
const poolOptions = config.poolOptions;
|
|
13940
|
+
const isolate = viteConfig?.test?.isolate;
|
|
13941
|
+
return {
|
|
13942
|
+
// TODO: remove functions from environmentOptions
|
|
13943
|
+
environmentOptions: config.environmentOptions,
|
|
13944
|
+
mode: config.mode,
|
|
13945
|
+
isolate: config.isolate,
|
|
13946
|
+
base: config.base,
|
|
13947
|
+
logHeapUsage: config.logHeapUsage,
|
|
13948
|
+
runner: config.runner,
|
|
13949
|
+
bail: config.bail,
|
|
13950
|
+
defines: config.defines,
|
|
13951
|
+
chaiConfig: config.chaiConfig,
|
|
13952
|
+
setupFiles: config.setupFiles,
|
|
13953
|
+
allowOnly: config.allowOnly,
|
|
13954
|
+
testTimeout: config.testTimeout,
|
|
13955
|
+
testNamePattern: config.testNamePattern,
|
|
13956
|
+
hookTimeout: config.hookTimeout,
|
|
13957
|
+
clearMocks: config.clearMocks,
|
|
13958
|
+
mockReset: config.mockReset,
|
|
13959
|
+
restoreMocks: config.restoreMocks,
|
|
13960
|
+
unstubEnvs: config.unstubEnvs,
|
|
13961
|
+
unstubGlobals: config.unstubGlobals,
|
|
13962
|
+
maxConcurrency: config.maxConcurrency,
|
|
13963
|
+
pool: config.pool,
|
|
13964
|
+
expect: config.expect,
|
|
13965
|
+
snapshotSerializers: config.snapshotSerializers,
|
|
13966
|
+
diff: config.diff,
|
|
13967
|
+
retry: config.retry,
|
|
13968
|
+
disableConsoleIntercept: config.disableConsoleIntercept,
|
|
13969
|
+
root: config.root,
|
|
13970
|
+
name: config.name,
|
|
13971
|
+
globals: config.globals,
|
|
13972
|
+
snapshotEnvironment: config.snapshotEnvironment,
|
|
13973
|
+
passWithNoTests: config.passWithNoTests,
|
|
13974
|
+
coverage: ((coverage) => {
|
|
13975
|
+
const htmlReporter = coverage.reporter.find(([reporterName]) => reporterName === "html");
|
|
13976
|
+
const subdir = htmlReporter && htmlReporter[1]?.subdir;
|
|
13977
|
+
return {
|
|
13978
|
+
reportsDirectory: coverage.reportsDirectory,
|
|
13979
|
+
provider: coverage.provider,
|
|
13980
|
+
enabled: coverage.enabled,
|
|
13981
|
+
htmlReporter: htmlReporter ? { subdir } : void 0,
|
|
13982
|
+
customProviderModule: "customProviderModule" in coverage ? coverage.customProviderModule : void 0
|
|
13983
|
+
};
|
|
13984
|
+
})(config.coverage),
|
|
13985
|
+
fakeTimers: config.fakeTimers,
|
|
13986
|
+
poolOptions: {
|
|
13987
|
+
forks: {
|
|
13988
|
+
singleFork: poolOptions?.forks?.singleFork ?? coreConfig.poolOptions?.forks?.singleFork ?? false,
|
|
13989
|
+
isolate: poolOptions?.forks?.isolate ?? isolate ?? coreConfig.poolOptions?.forks?.isolate ?? true
|
|
13990
|
+
},
|
|
13991
|
+
threads: {
|
|
13992
|
+
singleThread: poolOptions?.threads?.singleThread ?? coreConfig.poolOptions?.threads?.singleThread ?? false,
|
|
13993
|
+
isolate: poolOptions?.threads?.isolate ?? isolate ?? coreConfig.poolOptions?.threads?.isolate ?? true
|
|
13994
|
+
},
|
|
13995
|
+
vmThreads: {
|
|
13996
|
+
singleThread: poolOptions?.vmThreads?.singleThread ?? coreConfig.poolOptions?.vmThreads?.singleThread ?? false
|
|
13997
|
+
},
|
|
13998
|
+
vmForks: {
|
|
13999
|
+
singleFork: poolOptions?.vmForks?.singleFork ?? coreConfig.poolOptions?.vmForks?.singleFork ?? false
|
|
14000
|
+
}
|
|
14001
|
+
},
|
|
14002
|
+
deps: {
|
|
14003
|
+
web: config.deps.web || {},
|
|
14004
|
+
optimizer: {
|
|
14005
|
+
web: {
|
|
14006
|
+
enabled: optimizer?.web?.enabled ?? true
|
|
14007
|
+
},
|
|
14008
|
+
ssr: {
|
|
14009
|
+
enabled: optimizer?.ssr?.enabled ?? true
|
|
14010
|
+
}
|
|
14011
|
+
},
|
|
14012
|
+
interopDefault: config.deps.interopDefault,
|
|
14013
|
+
moduleDirectories: config.deps.moduleDirectories
|
|
14014
|
+
},
|
|
14015
|
+
snapshotOptions: {
|
|
14016
|
+
// TODO: store it differently, not on the config
|
|
14017
|
+
snapshotEnvironment: void 0,
|
|
14018
|
+
updateSnapshot: coreConfig.snapshotOptions.updateSnapshot,
|
|
14019
|
+
snapshotFormat: {
|
|
14020
|
+
...coreConfig.snapshotOptions.snapshotFormat,
|
|
14021
|
+
compareKeys: void 0
|
|
14022
|
+
},
|
|
14023
|
+
expand: config.snapshotOptions.expand ?? coreConfig.snapshotOptions.expand
|
|
14024
|
+
},
|
|
14025
|
+
sequence: {
|
|
14026
|
+
shuffle: coreConfig.sequence.shuffle,
|
|
14027
|
+
concurrent: coreConfig.sequence.concurrent,
|
|
14028
|
+
seed: coreConfig.sequence.seed,
|
|
14029
|
+
hooks: coreConfig.sequence.hooks,
|
|
14030
|
+
setupFiles: coreConfig.sequence.setupFiles
|
|
14031
|
+
},
|
|
14032
|
+
inspect: coreConfig.inspect,
|
|
14033
|
+
inspectBrk: coreConfig.inspectBrk,
|
|
14034
|
+
inspector: coreConfig.inspector,
|
|
14035
|
+
watch: config.watch,
|
|
14036
|
+
includeTaskLocation: config.includeTaskLocation ?? coreConfig.includeTaskLocation,
|
|
14037
|
+
env: {
|
|
14038
|
+
...viteConfig?.env,
|
|
14039
|
+
...config.env
|
|
14040
|
+
},
|
|
14041
|
+
browser: ((browser) => {
|
|
14042
|
+
return {
|
|
14043
|
+
name: browser.name,
|
|
14044
|
+
headless: browser.headless,
|
|
14045
|
+
isolate: browser.isolate,
|
|
14046
|
+
fileParallelism: browser.fileParallelism,
|
|
14047
|
+
ui: browser.ui,
|
|
14048
|
+
viewport: browser.viewport,
|
|
14049
|
+
screenshotFailures: browser.screenshotFailures
|
|
14050
|
+
};
|
|
14051
|
+
})(config.browser),
|
|
14052
|
+
standalone: config.standalone,
|
|
14053
|
+
printConsoleTrace: config.printConsoleTrace ?? coreConfig.printConsoleTrace
|
|
14054
|
+
};
|
|
14055
|
+
}
|
|
14056
|
+
|
|
13799
14057
|
async function initializeProject(workspacePath, ctx, options) {
|
|
13800
|
-
var _a;
|
|
13801
14058
|
const project = new WorkspaceProject(workspacePath, ctx, options);
|
|
13802
14059
|
const configFile = options.extends ? resolve(dirname(options.workspaceConfigPath), options.extends) : typeof workspacePath === "number" || workspacePath.endsWith("/") ? false : workspacePath;
|
|
13803
14060
|
const root = options.root || (typeof workspacePath === "number" ? void 0 : workspacePath.endsWith("/") ? workspacePath : dirname(workspacePath));
|
|
@@ -13807,7 +14064,7 @@ async function initializeProject(workspacePath, ctx, options) {
|
|
|
13807
14064
|
logLevel: "error",
|
|
13808
14065
|
configFile,
|
|
13809
14066
|
// this will make "mode": "test" | "benchmark" inside defineConfig
|
|
13810
|
-
mode:
|
|
14067
|
+
mode: options.test?.mode || options.mode || ctx.config.mode,
|
|
13811
14068
|
plugins: [
|
|
13812
14069
|
...options.plugins || [],
|
|
13813
14070
|
WorkspaceVitestPlugin(project, { ...options, root, workspacePath })
|
|
@@ -13831,6 +14088,7 @@ class WorkspaceProject {
|
|
|
13831
14088
|
typechecker;
|
|
13832
14089
|
closingPromise;
|
|
13833
14090
|
testFilesList = null;
|
|
14091
|
+
testProject;
|
|
13834
14092
|
id = nanoid();
|
|
13835
14093
|
tmpDir = join(tmpdir(), this.id);
|
|
13836
14094
|
_globalSetups;
|
|
@@ -13864,7 +14122,6 @@ class WorkspaceProject {
|
|
|
13864
14122
|
};
|
|
13865
14123
|
}
|
|
13866
14124
|
async initializeGlobalSetup() {
|
|
13867
|
-
var _a;
|
|
13868
14125
|
if (this._globalSetups) {
|
|
13869
14126
|
return;
|
|
13870
14127
|
}
|
|
@@ -13873,10 +14130,10 @@ class WorkspaceProject {
|
|
|
13873
14130
|
this.config.globalSetup
|
|
13874
14131
|
);
|
|
13875
14132
|
for (const globalSetupFile of this._globalSetups) {
|
|
13876
|
-
const teardown = await
|
|
14133
|
+
const teardown = await globalSetupFile.setup?.({
|
|
13877
14134
|
provide: (key, value) => this.provide(key, value),
|
|
13878
14135
|
config: this.config
|
|
13879
|
-
})
|
|
14136
|
+
});
|
|
13880
14137
|
if (teardown == null || !!globalSetupFile.teardown) {
|
|
13881
14138
|
continue;
|
|
13882
14139
|
}
|
|
@@ -13889,12 +14146,11 @@ class WorkspaceProject {
|
|
|
13889
14146
|
}
|
|
13890
14147
|
}
|
|
13891
14148
|
async teardownGlobalSetup() {
|
|
13892
|
-
var _a;
|
|
13893
14149
|
if (!this._globalSetups) {
|
|
13894
14150
|
return;
|
|
13895
14151
|
}
|
|
13896
14152
|
for (const globalSetupFile of [...this._globalSetups].reverse()) {
|
|
13897
|
-
await
|
|
14153
|
+
await globalSetupFile.teardown?.();
|
|
13898
14154
|
}
|
|
13899
14155
|
}
|
|
13900
14156
|
get logger() {
|
|
@@ -13902,22 +14158,15 @@ class WorkspaceProject {
|
|
|
13902
14158
|
}
|
|
13903
14159
|
// it's possible that file path was imported with different queries (?raw, ?url, etc)
|
|
13904
14160
|
getModulesByFilepath(file) {
|
|
13905
|
-
|
|
13906
|
-
const set = this.server.moduleGraph.getModulesByFile(file) || ((_a = this.browser) == null ? void 0 : _a.vite.moduleGraph.getModulesByFile(file));
|
|
14161
|
+
const set = this.server.moduleGraph.getModulesByFile(file) || this.browser?.vite.moduleGraph.getModulesByFile(file);
|
|
13907
14162
|
return set || /* @__PURE__ */ new Set();
|
|
13908
14163
|
}
|
|
13909
14164
|
getModuleById(id) {
|
|
13910
|
-
|
|
13911
|
-
return this.server.moduleGraph.getModuleById(id) || ((_a = this.browser) == null ? void 0 : _a.vite.moduleGraph.getModuleById(id));
|
|
14165
|
+
return this.server.moduleGraph.getModuleById(id) || this.browser?.vite.moduleGraph.getModuleById(id);
|
|
13912
14166
|
}
|
|
13913
14167
|
getSourceMapModuleById(id) {
|
|
13914
|
-
var _a, _b;
|
|
13915
14168
|
const mod = this.server.moduleGraph.getModuleById(id);
|
|
13916
|
-
return
|
|
13917
|
-
}
|
|
13918
|
-
getBrowserSourceMapModuleById(id) {
|
|
13919
|
-
var _a, _b, _c;
|
|
13920
|
-
return (_c = (_b = (_a = this.browser) == null ? void 0 : _a.vite.moduleGraph.getModuleById(id)) == null ? void 0 : _b.transformResult) == null ? void 0 : _c.map;
|
|
14169
|
+
return mod?.ssrTransformResult?.map || mod?.transformResult?.map;
|
|
13921
14170
|
}
|
|
13922
14171
|
get reporters() {
|
|
13923
14172
|
return this.ctx.reporters;
|
|
@@ -13941,7 +14190,7 @@ class WorkspaceProject {
|
|
|
13941
14190
|
return this.testFilesList;
|
|
13942
14191
|
}
|
|
13943
14192
|
const testFiles = await this.globFiles(include, exclude, cwd);
|
|
13944
|
-
if (includeSource
|
|
14193
|
+
if (includeSource?.length) {
|
|
13945
14194
|
const files = await this.globFiles(includeSource, exclude, cwd);
|
|
13946
14195
|
await Promise.all(
|
|
13947
14196
|
files.map(async (file) => {
|
|
@@ -13972,7 +14221,6 @@ class WorkspaceProject {
|
|
|
13972
14221
|
return files.map((file) => resolve(cwd, file));
|
|
13973
14222
|
}
|
|
13974
14223
|
async isTargetFile(id, source) {
|
|
13975
|
-
var _a;
|
|
13976
14224
|
const relativeId = relative(this.config.dir || this.config.root, id);
|
|
13977
14225
|
if (mm.isMatch(relativeId, this.config.exclude)) {
|
|
13978
14226
|
return false;
|
|
@@ -13980,7 +14228,7 @@ class WorkspaceProject {
|
|
|
13980
14228
|
if (mm.isMatch(relativeId, this.config.include)) {
|
|
13981
14229
|
return true;
|
|
13982
14230
|
}
|
|
13983
|
-
if (
|
|
14231
|
+
if (this.config.includeSource?.length && mm.isMatch(relativeId, this.config.includeSource)) {
|
|
13984
14232
|
source = source || await promises$1.readFile(id, "utf-8");
|
|
13985
14233
|
return this.isInSourceTestFile(source);
|
|
13986
14234
|
}
|
|
@@ -14008,13 +14256,12 @@ class WorkspaceProject {
|
|
|
14008
14256
|
return testFiles;
|
|
14009
14257
|
}
|
|
14010
14258
|
async initBrowserServer(configFile) {
|
|
14011
|
-
var _a;
|
|
14012
14259
|
if (!this.isBrowserEnabled()) {
|
|
14013
14260
|
return;
|
|
14014
14261
|
}
|
|
14015
14262
|
await this.ctx.packageInstaller.ensureInstalled("@vitest/browser", this.config.root);
|
|
14016
14263
|
const { createBrowserServer } = await import('@vitest/browser');
|
|
14017
|
-
await
|
|
14264
|
+
await this.browser?.close();
|
|
14018
14265
|
const browser = await createBrowserServer(
|
|
14019
14266
|
this,
|
|
14020
14267
|
configFile,
|
|
@@ -14035,6 +14282,7 @@ class WorkspaceProject {
|
|
|
14035
14282
|
project.server = ctx.server;
|
|
14036
14283
|
project.runner = ctx.runner;
|
|
14037
14284
|
project.config = ctx.config;
|
|
14285
|
+
project.testProject = new TestProject(project);
|
|
14038
14286
|
return project;
|
|
14039
14287
|
}
|
|
14040
14288
|
static async createCoreProject(ctx) {
|
|
@@ -14052,6 +14300,7 @@ class WorkspaceProject {
|
|
|
14052
14300
|
server.config,
|
|
14053
14301
|
this.ctx.logger
|
|
14054
14302
|
);
|
|
14303
|
+
this.testProject = new TestProject(this);
|
|
14055
14304
|
this.server = server;
|
|
14056
14305
|
this.vitenode = new ViteNodeServer(server, this.config.server);
|
|
14057
14306
|
const node = this.vitenode;
|
|
@@ -14070,91 +14319,27 @@ class WorkspaceProject {
|
|
|
14070
14319
|
isBrowserEnabled() {
|
|
14071
14320
|
return isBrowserEnabled(this.config);
|
|
14072
14321
|
}
|
|
14073
|
-
getSerializableConfig(
|
|
14074
|
-
|
|
14075
|
-
|
|
14076
|
-
|
|
14077
|
-
|
|
14078
|
-
const config = deepMerge(
|
|
14079
|
-
{
|
|
14080
|
-
...this.config,
|
|
14081
|
-
poolOptions: {
|
|
14082
|
-
forks: {
|
|
14083
|
-
singleFork: ((_e = poolOptions == null ? void 0 : poolOptions.forks) == null ? void 0 : _e.singleFork) ?? ((_g = (_f = this.ctx.config.poolOptions) == null ? void 0 : _f.forks) == null ? void 0 : _g.singleFork) ?? false,
|
|
14084
|
-
isolate: ((_h = poolOptions == null ? void 0 : poolOptions.forks) == null ? void 0 : _h.isolate) ?? isolate ?? ((_j = (_i = this.ctx.config.poolOptions) == null ? void 0 : _i.forks) == null ? void 0 : _j.isolate) ?? true
|
|
14085
|
-
},
|
|
14086
|
-
threads: {
|
|
14087
|
-
singleThread: ((_k = poolOptions == null ? void 0 : poolOptions.threads) == null ? void 0 : _k.singleThread) ?? ((_m = (_l = this.ctx.config.poolOptions) == null ? void 0 : _l.threads) == null ? void 0 : _m.singleThread) ?? false,
|
|
14088
|
-
isolate: ((_n = poolOptions == null ? void 0 : poolOptions.threads) == null ? void 0 : _n.isolate) ?? isolate ?? ((_p = (_o = this.ctx.config.poolOptions) == null ? void 0 : _o.threads) == null ? void 0 : _p.isolate) ?? true
|
|
14089
|
-
},
|
|
14090
|
-
vmThreads: {
|
|
14091
|
-
singleThread: ((_q = poolOptions == null ? void 0 : poolOptions.vmThreads) == null ? void 0 : _q.singleThread) ?? ((_s = (_r = this.ctx.config.poolOptions) == null ? void 0 : _r.vmThreads) == null ? void 0 : _s.singleThread) ?? false
|
|
14092
|
-
}
|
|
14093
|
-
},
|
|
14094
|
-
reporters: [],
|
|
14095
|
-
deps: {
|
|
14096
|
-
...this.config.deps,
|
|
14097
|
-
optimizer: {
|
|
14098
|
-
web: {
|
|
14099
|
-
enabled: ((_t = optimizer == null ? void 0 : optimizer.web) == null ? void 0 : _t.enabled) ?? true
|
|
14100
|
-
},
|
|
14101
|
-
ssr: {
|
|
14102
|
-
enabled: ((_u = optimizer == null ? void 0 : optimizer.ssr) == null ? void 0 : _u.enabled) ?? true
|
|
14103
|
-
}
|
|
14104
|
-
}
|
|
14105
|
-
},
|
|
14106
|
-
snapshotOptions: {
|
|
14107
|
-
...this.ctx.config.snapshotOptions,
|
|
14108
|
-
expand: this.config.snapshotOptions.expand ?? this.ctx.config.snapshotOptions.expand,
|
|
14109
|
-
resolveSnapshotPath: void 0
|
|
14110
|
-
},
|
|
14111
|
-
onConsoleLog: void 0,
|
|
14112
|
-
onStackTrace: void 0,
|
|
14113
|
-
sequence: {
|
|
14114
|
-
...this.ctx.config.sequence,
|
|
14115
|
-
sequencer: void 0
|
|
14116
|
-
},
|
|
14117
|
-
benchmark: {
|
|
14118
|
-
...this.config.benchmark,
|
|
14119
|
-
reporters: []
|
|
14120
|
-
},
|
|
14121
|
-
inspect: this.ctx.config.inspect,
|
|
14122
|
-
inspectBrk: this.ctx.config.inspectBrk,
|
|
14123
|
-
inspector: this.ctx.config.inspector,
|
|
14124
|
-
alias: [],
|
|
14125
|
-
includeTaskLocation: this.config.includeTaskLocation ?? this.ctx.config.includeTaskLocation,
|
|
14126
|
-
env: {
|
|
14127
|
-
...(_v = this.server) == null ? void 0 : _v.config.env,
|
|
14128
|
-
...this.config.env
|
|
14129
|
-
},
|
|
14130
|
-
browser: {
|
|
14131
|
-
...this.config.browser,
|
|
14132
|
-
orchestratorScripts: [],
|
|
14133
|
-
testerScripts: [],
|
|
14134
|
-
commands: {}
|
|
14135
|
-
},
|
|
14136
|
-
printConsoleTrace: this.config.printConsoleTrace ?? this.ctx.config.printConsoleTrace
|
|
14137
|
-
},
|
|
14138
|
-
this.ctx.configOverride || {}
|
|
14322
|
+
getSerializableConfig() {
|
|
14323
|
+
const config = serializeConfig(
|
|
14324
|
+
this.config,
|
|
14325
|
+
this.ctx.config,
|
|
14326
|
+
this.server.config
|
|
14139
14327
|
);
|
|
14140
|
-
if (
|
|
14141
|
-
config
|
|
14142
|
-
if (config.browser.provider && config.browser.provider !== "preview") {
|
|
14143
|
-
config.browser.headless = true;
|
|
14144
|
-
}
|
|
14145
|
-
config.snapshotSerializers = [];
|
|
14146
|
-
config.diff = void 0;
|
|
14328
|
+
if (!this.ctx.configOverride) {
|
|
14329
|
+
return config;
|
|
14147
14330
|
}
|
|
14148
|
-
return
|
|
14331
|
+
return deepMerge(
|
|
14332
|
+
config,
|
|
14333
|
+
this.ctx.configOverride
|
|
14334
|
+
);
|
|
14149
14335
|
}
|
|
14150
14336
|
close() {
|
|
14151
|
-
var _a, _b;
|
|
14152
14337
|
if (!this.closingPromise) {
|
|
14153
14338
|
this.closingPromise = Promise.all(
|
|
14154
14339
|
[
|
|
14155
14340
|
this.server.close(),
|
|
14156
|
-
|
|
14157
|
-
|
|
14341
|
+
this.typechecker?.stop(),
|
|
14342
|
+
this.browser?.close(),
|
|
14158
14343
|
this.clearTmpDir()
|
|
14159
14344
|
].filter(Boolean)
|
|
14160
14345
|
).then(() => this._provided = {});
|
|
@@ -14163,16 +14348,15 @@ class WorkspaceProject {
|
|
|
14163
14348
|
}
|
|
14164
14349
|
async clearTmpDir() {
|
|
14165
14350
|
try {
|
|
14166
|
-
await rm(this.tmpDir, {
|
|
14351
|
+
await rm(this.tmpDir, { recursive: true });
|
|
14167
14352
|
} catch {
|
|
14168
14353
|
}
|
|
14169
14354
|
}
|
|
14170
14355
|
async initBrowserProvider() {
|
|
14171
|
-
var _a;
|
|
14172
14356
|
if (!this.isBrowserEnabled()) {
|
|
14173
14357
|
return;
|
|
14174
14358
|
}
|
|
14175
|
-
await
|
|
14359
|
+
await this.browser?.initBrowserProvider();
|
|
14176
14360
|
}
|
|
14177
14361
|
}
|
|
14178
14362
|
|
|
@@ -14187,7 +14371,7 @@ class VitestPackageInstaller {
|
|
|
14187
14371
|
try {
|
|
14188
14372
|
targetRequire.resolve(dependency, { paths: [root, __dirname] });
|
|
14189
14373
|
return true;
|
|
14190
|
-
} catch
|
|
14374
|
+
} catch {
|
|
14191
14375
|
}
|
|
14192
14376
|
}
|
|
14193
14377
|
if (/* @__PURE__ */ isPackageExists(dependency, { paths: [root, __dirname] })) {
|
|
@@ -14206,14 +14390,14 @@ class VitestPackageInstaller {
|
|
|
14206
14390
|
if (!promptInstall) {
|
|
14207
14391
|
return false;
|
|
14208
14392
|
}
|
|
14209
|
-
const prompts = await import('./index.
|
|
14393
|
+
const prompts = await import('./index.CM5UI-4O.js').then(function (n) { return n.i; });
|
|
14210
14394
|
const { install } = await prompts.prompt({
|
|
14211
14395
|
type: "confirm",
|
|
14212
14396
|
name: "install",
|
|
14213
14397
|
message: c.reset(`Do you want to install ${c.green(dependency)}?`)
|
|
14214
14398
|
});
|
|
14215
14399
|
if (install) {
|
|
14216
|
-
await (await import('
|
|
14400
|
+
await (await import('./index.DNUmWFkO.js')).installPackage(dependency, { dev: true });
|
|
14217
14401
|
process.stderr.write(
|
|
14218
14402
|
c.yellow(
|
|
14219
14403
|
`
|
|
@@ -14281,11 +14465,10 @@ class Vitest {
|
|
|
14281
14465
|
_onSetServer = [];
|
|
14282
14466
|
_onCancelListeners = [];
|
|
14283
14467
|
async setServer(options, server, cliOptions) {
|
|
14284
|
-
|
|
14285
|
-
(_a = this.unregisterWatcher) == null ? void 0 : _a.call(this);
|
|
14468
|
+
this.unregisterWatcher?.();
|
|
14286
14469
|
clearTimeout(this._rerunTimer);
|
|
14287
14470
|
this.restartsCount += 1;
|
|
14288
|
-
|
|
14471
|
+
this.pool?.close?.();
|
|
14289
14472
|
this.pool = void 0;
|
|
14290
14473
|
this.coverageProvider = void 0;
|
|
14291
14474
|
this.runningPromise = void 0;
|
|
@@ -14331,7 +14514,7 @@ class Vitest {
|
|
|
14331
14514
|
}
|
|
14332
14515
|
});
|
|
14333
14516
|
}
|
|
14334
|
-
this.reporters = resolved.mode === "benchmark" ? await createBenchmarkReporters(toArray(
|
|
14517
|
+
this.reporters = resolved.mode === "benchmark" ? await createBenchmarkReporters(toArray(resolved.benchmark?.reporters), this.runner) : await createReporters(resolved.reporters, this);
|
|
14335
14518
|
this.cache.results.setConfig(resolved.root, resolved.cache);
|
|
14336
14519
|
try {
|
|
14337
14520
|
await this.cache.results.readFromCache();
|
|
@@ -14365,9 +14548,8 @@ class Vitest {
|
|
|
14365
14548
|
return this.coreWorkspaceProject;
|
|
14366
14549
|
}
|
|
14367
14550
|
getProjectByTaskId(taskId) {
|
|
14368
|
-
var _a;
|
|
14369
14551
|
const task = this.state.idMap.get(taskId);
|
|
14370
|
-
const projectName = task.projectName ||
|
|
14552
|
+
const projectName = task.projectName || task?.file?.projectName || "";
|
|
14371
14553
|
return this.projects.find((p) => p.getName() === projectName) || this.getCoreWorkspaceProject() || this.projects[0];
|
|
14372
14554
|
}
|
|
14373
14555
|
getProjectByName(name = "") {
|
|
@@ -14440,7 +14622,7 @@ class Vitest {
|
|
|
14440
14622
|
}));
|
|
14441
14623
|
const workspacesByFolder = resolvedWorkspacesPaths.reduce((configByFolder, filepath) => {
|
|
14442
14624
|
const dir = filepath.endsWith("/") ? filepath.slice(0, -1) : dirname(filepath);
|
|
14443
|
-
configByFolder[dir]
|
|
14625
|
+
configByFolder[dir] ??= [];
|
|
14444
14626
|
configByFolder[dir].push(filepath);
|
|
14445
14627
|
return configByFolder;
|
|
14446
14628
|
}, {});
|
|
@@ -14521,7 +14703,10 @@ class Vitest {
|
|
|
14521
14703
|
if (this.coverageProvider !== void 0) {
|
|
14522
14704
|
return;
|
|
14523
14705
|
}
|
|
14524
|
-
this.coverageProvider = await getCoverageProvider(
|
|
14706
|
+
this.coverageProvider = await getCoverageProvider(
|
|
14707
|
+
this.config.coverage,
|
|
14708
|
+
this.runner
|
|
14709
|
+
);
|
|
14525
14710
|
if (this.coverageProvider) {
|
|
14526
14711
|
await this.coverageProvider.initialize(this);
|
|
14527
14712
|
this.config.coverage = this.coverageProvider.resolveOptions();
|
|
@@ -14532,7 +14717,6 @@ class Vitest {
|
|
|
14532
14717
|
return Promise.all(this.projects.map((w) => w.initBrowserProvider()));
|
|
14533
14718
|
}
|
|
14534
14719
|
async mergeReports() {
|
|
14535
|
-
var _a, _b;
|
|
14536
14720
|
if (this.reporters.some((r) => r instanceof BlobReporter)) {
|
|
14537
14721
|
throw new Error("Cannot merge reports when `--reporter=blob` is used. Remove blob reporter from the config first.");
|
|
14538
14722
|
}
|
|
@@ -14550,10 +14734,9 @@ class Vitest {
|
|
|
14550
14734
|
const filepaths = files2.map((f) => f.filepath);
|
|
14551
14735
|
this.state.clearFiles(project, filepaths);
|
|
14552
14736
|
files2.forEach((file) => {
|
|
14553
|
-
|
|
14554
|
-
(_a2 = file.logs) == null ? void 0 : _a2.forEach((log) => this.state.updateUserLog(log));
|
|
14737
|
+
file.logs?.forEach((log) => this.state.updateUserLog(log));
|
|
14555
14738
|
});
|
|
14556
|
-
this.state.collectFiles(files2);
|
|
14739
|
+
this.state.collectFiles(project, files2);
|
|
14557
14740
|
}
|
|
14558
14741
|
await this.report("onCollected", files).catch(noop$1);
|
|
14559
14742
|
for (const file of files) {
|
|
@@ -14577,7 +14760,7 @@ class Vitest {
|
|
|
14577
14760
|
}
|
|
14578
14761
|
await this.report("onFinished", files, errors);
|
|
14579
14762
|
await this.initCoverageProvider();
|
|
14580
|
-
await
|
|
14763
|
+
await this.coverageProvider?.mergeReports?.(coverages);
|
|
14581
14764
|
}
|
|
14582
14765
|
async collect(filters) {
|
|
14583
14766
|
this._onClose = [];
|
|
@@ -14595,11 +14778,10 @@ class Vitest {
|
|
|
14595
14778
|
};
|
|
14596
14779
|
}
|
|
14597
14780
|
async start(filters) {
|
|
14598
|
-
var _a, _b, _c, _d;
|
|
14599
14781
|
this._onClose = [];
|
|
14600
14782
|
try {
|
|
14601
14783
|
await this.initCoverageProvider();
|
|
14602
|
-
await
|
|
14784
|
+
await this.coverageProvider?.clean(this.config.coverage.clean);
|
|
14603
14785
|
await this.initBrowserProviders();
|
|
14604
14786
|
} finally {
|
|
14605
14787
|
await this.report("onInit", this);
|
|
@@ -14608,10 +14790,10 @@ class Vitest {
|
|
|
14608
14790
|
await this.globTestFiles(filters)
|
|
14609
14791
|
);
|
|
14610
14792
|
if (!files.length) {
|
|
14611
|
-
const coverage = await
|
|
14793
|
+
const coverage = await this.coverageProvider?.generateCoverage?.({ allTestsRun: true });
|
|
14612
14794
|
await this.reportCoverage(coverage, true);
|
|
14613
14795
|
this.logger.printNoTestFound(filters);
|
|
14614
|
-
if (!this.config.watch || !(this.config.changed ||
|
|
14796
|
+
if (!this.config.watch || !(this.config.changed || this.config.related?.length)) {
|
|
14615
14797
|
const exitCode = this.config.passWithNoTests ? 0 : 1;
|
|
14616
14798
|
process.exitCode = exitCode;
|
|
14617
14799
|
throw new FilesNotFoundError(this.mode);
|
|
@@ -14626,11 +14808,10 @@ class Vitest {
|
|
|
14626
14808
|
}
|
|
14627
14809
|
}
|
|
14628
14810
|
async init() {
|
|
14629
|
-
var _a;
|
|
14630
14811
|
this._onClose = [];
|
|
14631
14812
|
try {
|
|
14632
14813
|
await this.initCoverageProvider();
|
|
14633
|
-
await
|
|
14814
|
+
await this.coverageProvider?.clean(this.config.coverage.clean);
|
|
14634
14815
|
await this.initBrowserProviders();
|
|
14635
14816
|
} finally {
|
|
14636
14817
|
await this.report("onInit", this);
|
|
@@ -14647,7 +14828,7 @@ class Vitest {
|
|
|
14647
14828
|
}
|
|
14648
14829
|
deps.add(filepath2);
|
|
14649
14830
|
const mod = project.server.moduleGraph.getModuleById(filepath2);
|
|
14650
|
-
const transformed =
|
|
14831
|
+
const transformed = mod?.ssrTransformResult || await project.vitenode.transformRequest(filepath2);
|
|
14651
14832
|
if (!transformed) {
|
|
14652
14833
|
return;
|
|
14653
14834
|
}
|
|
@@ -14666,7 +14847,7 @@ class Vitest {
|
|
|
14666
14847
|
}
|
|
14667
14848
|
async filterTestsBySource(specs) {
|
|
14668
14849
|
if (this.config.changed && !this.config.related) {
|
|
14669
|
-
const { VitestGit } = await import('
|
|
14850
|
+
const { VitestGit } = await import('./git.ZtkbKc8u.js');
|
|
14670
14851
|
const vitestGit = new VitestGit(this.config.root);
|
|
14671
14852
|
const related2 = await vitestGit.findChangedFiles({
|
|
14672
14853
|
changedSince: this.config.changed
|
|
@@ -14715,7 +14896,7 @@ class Vitest {
|
|
|
14715
14896
|
if (!projects.has(coreProject)) {
|
|
14716
14897
|
projects.add(coreProject);
|
|
14717
14898
|
}
|
|
14718
|
-
for
|
|
14899
|
+
for (const project of projects) {
|
|
14719
14900
|
await project.initializeGlobalSetup();
|
|
14720
14901
|
}
|
|
14721
14902
|
}
|
|
@@ -14739,7 +14920,6 @@ class Vitest {
|
|
|
14739
14920
|
this._onCancelListeners = [];
|
|
14740
14921
|
this.isCancelling = false;
|
|
14741
14922
|
this.runningPromise = (async () => {
|
|
14742
|
-
var _a;
|
|
14743
14923
|
if (!this.pool) {
|
|
14744
14924
|
this.pool = createPool(this);
|
|
14745
14925
|
}
|
|
@@ -14748,7 +14928,7 @@ class Vitest {
|
|
|
14748
14928
|
this.snapshot.clear();
|
|
14749
14929
|
this.state.clearErrors();
|
|
14750
14930
|
if (!this.isFirstRun && this.config.coverage.cleanOnRerun) {
|
|
14751
|
-
await
|
|
14931
|
+
await this.coverageProvider?.clean();
|
|
14752
14932
|
}
|
|
14753
14933
|
await this.initializeGlobalSetup(specs);
|
|
14754
14934
|
try {
|
|
@@ -14763,9 +14943,8 @@ class Vitest {
|
|
|
14763
14943
|
this.cache.results.updateResults(files);
|
|
14764
14944
|
await this.cache.results.writeToCache();
|
|
14765
14945
|
})().finally(async () => {
|
|
14766
|
-
var _a;
|
|
14767
14946
|
const files = Array.from(new Set(specs.map(([, p]) => p)));
|
|
14768
|
-
const coverage = await
|
|
14947
|
+
const coverage = await this.coverageProvider?.generateCoverage({ allTestsRun });
|
|
14769
14948
|
await this.report("onFinished", this.state.getFiles(files), this.state.getUnhandledErrors(), coverage);
|
|
14770
14949
|
await this.reportCoverage(coverage, allTestsRun);
|
|
14771
14950
|
this.runningPromise = void 0;
|
|
@@ -14932,10 +15111,10 @@ class Vitest {
|
|
|
14932
15111
|
const projects = this.getModuleProjects(filepath);
|
|
14933
15112
|
projects.forEach(({ server, browser }) => {
|
|
14934
15113
|
const serverMods = server.moduleGraph.getModulesByFile(filepath);
|
|
14935
|
-
serverMods
|
|
15114
|
+
serverMods?.forEach((mod) => server.moduleGraph.invalidateModule(mod));
|
|
14936
15115
|
if (browser) {
|
|
14937
15116
|
const browserMods = browser.vite.moduleGraph.getModulesByFile(filepath);
|
|
14938
|
-
browserMods
|
|
15117
|
+
browserMods?.forEach((mod) => browser.vite.moduleGraph.invalidateModule(mod));
|
|
14939
15118
|
}
|
|
14940
15119
|
});
|
|
14941
15120
|
};
|
|
@@ -14965,10 +15144,9 @@ class Vitest {
|
|
|
14965
15144
|
updateLastChanged(id);
|
|
14966
15145
|
const matchingProjects = [];
|
|
14967
15146
|
await Promise.all(this.projects.map(async (project) => {
|
|
14968
|
-
var _a;
|
|
14969
15147
|
if (await project.isTargetFile(id)) {
|
|
14970
15148
|
matchingProjects.push(project);
|
|
14971
|
-
|
|
15149
|
+
project.testFilesList?.push(id);
|
|
14972
15150
|
}
|
|
14973
15151
|
}));
|
|
14974
15152
|
if (matchingProjects.length > 0) {
|
|
@@ -15074,8 +15252,7 @@ class Vitest {
|
|
|
15074
15252
|
}
|
|
15075
15253
|
if (this.pool) {
|
|
15076
15254
|
closePromises.push((async () => {
|
|
15077
|
-
|
|
15078
|
-
await ((_b = (_a = this.pool) == null ? void 0 : _a.close) == null ? void 0 : _b.call(_a));
|
|
15255
|
+
await this.pool?.close?.();
|
|
15079
15256
|
this.pool = void 0;
|
|
15080
15257
|
})());
|
|
15081
15258
|
}
|
|
@@ -15120,13 +15297,9 @@ class Vitest {
|
|
|
15120
15297
|
}
|
|
15121
15298
|
}
|
|
15122
15299
|
async report(name, ...args) {
|
|
15123
|
-
await Promise.all(this.reporters.map((r) =>
|
|
15124
|
-
|
|
15125
|
-
|
|
15126
|
-
r,
|
|
15127
|
-
...args
|
|
15128
|
-
);
|
|
15129
|
-
}));
|
|
15300
|
+
await Promise.all(this.reporters.map((r) => r[name]?.(
|
|
15301
|
+
...args
|
|
15302
|
+
)));
|
|
15130
15303
|
}
|
|
15131
15304
|
async getTestFilepaths() {
|
|
15132
15305
|
return this.globTestFiles().then((files) => files.map(([, file]) => file));
|
|
@@ -15146,8 +15319,7 @@ class Vitest {
|
|
|
15146
15319
|
}
|
|
15147
15320
|
// The server needs to be running for communication
|
|
15148
15321
|
shouldKeepServer() {
|
|
15149
|
-
|
|
15150
|
-
return !!((_a = this.config) == null ? void 0 : _a.watch);
|
|
15322
|
+
return !!this.config?.watch;
|
|
15151
15323
|
}
|
|
15152
15324
|
onServerRestart(fn) {
|
|
15153
15325
|
this._onRestartListeners.push(fn);
|
|
@@ -15165,10 +15337,7 @@ class Vitest {
|
|
|
15165
15337
|
|
|
15166
15338
|
async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
15167
15339
|
const userConfig = deepMerge({}, options);
|
|
15168
|
-
const getRoot = () =>
|
|
15169
|
-
var _a;
|
|
15170
|
-
return ((_a = ctx.config) == null ? void 0 : _a.root) || options.root || process.cwd();
|
|
15171
|
-
};
|
|
15340
|
+
const getRoot = () => ctx.config?.root || options.root || process.cwd();
|
|
15172
15341
|
async function UIPlugin() {
|
|
15173
15342
|
await ctx.packageInstaller.ensureInstalled("@vitest/ui", getRoot());
|
|
15174
15343
|
return (await import('@vitest/ui')).default(ctx);
|
|
@@ -15181,7 +15350,6 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
15181
15350
|
this.meta.watchMode = false;
|
|
15182
15351
|
},
|
|
15183
15352
|
async config(viteConfig) {
|
|
15184
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t;
|
|
15185
15353
|
if (options.watch) {
|
|
15186
15354
|
options = deepMerge({}, userConfig);
|
|
15187
15355
|
}
|
|
@@ -15199,10 +15367,10 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
15199
15367
|
open = testConfig.uiBase ?? "/__vitest__/";
|
|
15200
15368
|
}
|
|
15201
15369
|
const config = {
|
|
15202
|
-
root:
|
|
15370
|
+
root: viteConfig.test?.root || options.root,
|
|
15203
15371
|
esbuild: viteConfig.esbuild === false ? false : {
|
|
15204
15372
|
// Lowest target Vitest supports is Node18
|
|
15205
|
-
target:
|
|
15373
|
+
target: viteConfig.esbuild?.target || "node18",
|
|
15206
15374
|
sourcemap: "external",
|
|
15207
15375
|
// Enables using ignore hint for coverage providers with @preserve keyword
|
|
15208
15376
|
legalComments: "inline"
|
|
@@ -15235,25 +15403,25 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
15235
15403
|
test: {
|
|
15236
15404
|
poolOptions: {
|
|
15237
15405
|
threads: {
|
|
15238
|
-
isolate:
|
|
15406
|
+
isolate: options.poolOptions?.threads?.isolate ?? options.isolate ?? testConfig.poolOptions?.threads?.isolate ?? viteConfig.test?.isolate
|
|
15239
15407
|
},
|
|
15240
15408
|
forks: {
|
|
15241
|
-
isolate:
|
|
15409
|
+
isolate: options.poolOptions?.forks?.isolate ?? options.isolate ?? testConfig.poolOptions?.forks?.isolate ?? viteConfig.test?.isolate
|
|
15242
15410
|
}
|
|
15243
15411
|
}
|
|
15244
15412
|
}
|
|
15245
15413
|
};
|
|
15246
|
-
if (
|
|
15414
|
+
if (userConfig.coverage?.enabled && !userConfig.coverage.exclude && userConfig.include && config.test) {
|
|
15247
15415
|
config.test.coverage = {
|
|
15248
15416
|
exclude: [...coverageConfigDefaults.exclude, ...userConfig.include]
|
|
15249
15417
|
};
|
|
15250
15418
|
}
|
|
15251
|
-
if (
|
|
15252
|
-
const inline =
|
|
15419
|
+
if (viteConfig.ssr?.noExternal !== true) {
|
|
15420
|
+
const inline = testConfig.server?.deps?.inline;
|
|
15253
15421
|
if (inline === true) {
|
|
15254
15422
|
config.ssr = { noExternal: true };
|
|
15255
15423
|
} else {
|
|
15256
|
-
const noExternal =
|
|
15424
|
+
const noExternal = viteConfig.ssr?.noExternal;
|
|
15257
15425
|
const noExternalArray = typeof noExternal !== "undefined" ? toArray(noExternal) : void 0;
|
|
15258
15426
|
const uniqueInline = inline && noExternalArray ? inline.filter((dep) => !noExternalArray.includes(dep)) : inline;
|
|
15259
15427
|
config.ssr = {
|
|
@@ -15268,10 +15436,10 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
15268
15436
|
watch.usePolling = false;
|
|
15269
15437
|
}
|
|
15270
15438
|
}
|
|
15271
|
-
const classNameStrategy = typeof testConfig.css !== "boolean" &&
|
|
15439
|
+
const classNameStrategy = typeof testConfig.css !== "boolean" && testConfig.css?.modules?.classNameStrategy || "stable";
|
|
15272
15440
|
if (classNameStrategy !== "scoped") {
|
|
15273
|
-
config.css
|
|
15274
|
-
|
|
15441
|
+
config.css ??= {};
|
|
15442
|
+
config.css.modules ??= {};
|
|
15275
15443
|
if (config.css.modules) {
|
|
15276
15444
|
config.css.modules.generateScopedName = (name, filename) => {
|
|
15277
15445
|
const root = getRoot();
|
|
@@ -15286,7 +15454,6 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
15286
15454
|
return config;
|
|
15287
15455
|
},
|
|
15288
15456
|
async configResolved(viteConfig) {
|
|
15289
|
-
var _a, _b, _c;
|
|
15290
15457
|
const viteConfigTest = viteConfig.test || {};
|
|
15291
15458
|
if (viteConfigTest.watch === false) {
|
|
15292
15459
|
viteConfigTest.run = true;
|
|
@@ -15297,10 +15464,10 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
15297
15464
|
options = deepMerge({}, configDefaults, viteConfigTest, options);
|
|
15298
15465
|
options.api = resolveApiServerConfig(options, defaultPort);
|
|
15299
15466
|
const { PROD, DEV, ...envs } = viteConfig.env;
|
|
15300
|
-
|
|
15301
|
-
|
|
15467
|
+
process.env.PROD ??= PROD ? "1" : "";
|
|
15468
|
+
process.env.DEV ??= DEV ? "1" : "";
|
|
15302
15469
|
for (const name in envs) {
|
|
15303
|
-
|
|
15470
|
+
process.env[name] ??= envs[name];
|
|
15304
15471
|
}
|
|
15305
15472
|
if (!options.watch) {
|
|
15306
15473
|
viteConfig.server.watch = null;
|
|
@@ -15334,7 +15501,6 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
15334
15501
|
}
|
|
15335
15502
|
|
|
15336
15503
|
async function createVitest(mode, options, viteOverrides = {}, vitestOptions = {}) {
|
|
15337
|
-
var _a;
|
|
15338
15504
|
const ctx = new Vitest(mode, vitestOptions);
|
|
15339
15505
|
const root = resolve(options.root || process.cwd());
|
|
15340
15506
|
const configPath = options.config === false ? false : options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
|
|
@@ -15349,7 +15515,7 @@ async function createVitest(mode, options, viteOverrides = {}, vitestOptions = {
|
|
|
15349
15515
|
const server = await createViteServer(
|
|
15350
15516
|
mergeConfig(config, mergeConfig(viteOverrides, { root: options.root }))
|
|
15351
15517
|
);
|
|
15352
|
-
if (
|
|
15518
|
+
if (ctx.config.api?.port) {
|
|
15353
15519
|
await server.listen();
|
|
15354
15520
|
}
|
|
15355
15521
|
return ctx;
|
|
@@ -15395,42 +15561,41 @@ class WatchFilter {
|
|
|
15395
15561
|
}
|
|
15396
15562
|
filterHandler(filterFunc, onSubmit) {
|
|
15397
15563
|
return async (str, key) => {
|
|
15398
|
-
var _a, _b;
|
|
15399
15564
|
switch (true) {
|
|
15400
15565
|
case key.sequence === "\x7F":
|
|
15401
|
-
if (this.currentKeyword &&
|
|
15402
|
-
this.currentKeyword =
|
|
15566
|
+
if (this.currentKeyword && this.currentKeyword?.length > 1) {
|
|
15567
|
+
this.currentKeyword = this.currentKeyword?.slice(0, -1);
|
|
15403
15568
|
} else {
|
|
15404
15569
|
this.currentKeyword = void 0;
|
|
15405
15570
|
}
|
|
15406
15571
|
break;
|
|
15407
|
-
case (
|
|
15408
|
-
case
|
|
15572
|
+
case (key?.ctrl && key?.name === "c"):
|
|
15573
|
+
case key?.name === "escape":
|
|
15409
15574
|
this.cancel();
|
|
15410
15575
|
onSubmit(void 0);
|
|
15411
15576
|
break;
|
|
15412
|
-
case
|
|
15413
|
-
case
|
|
15577
|
+
case key?.name === "enter":
|
|
15578
|
+
case key?.name === "return":
|
|
15414
15579
|
onSubmit(
|
|
15415
15580
|
this.results[this.selectionIndex] || this.currentKeyword || ""
|
|
15416
15581
|
);
|
|
15417
15582
|
this.currentKeyword = void 0;
|
|
15418
15583
|
break;
|
|
15419
|
-
case
|
|
15584
|
+
case key?.name === "up":
|
|
15420
15585
|
if (this.selectionIndex && this.selectionIndex > 0) {
|
|
15421
15586
|
this.selectionIndex--;
|
|
15422
15587
|
} else {
|
|
15423
15588
|
this.selectionIndex = -1;
|
|
15424
15589
|
}
|
|
15425
15590
|
break;
|
|
15426
|
-
case
|
|
15591
|
+
case key?.name === "down":
|
|
15427
15592
|
if (this.selectionIndex < this.results.length - 1) {
|
|
15428
15593
|
this.selectionIndex++;
|
|
15429
15594
|
} else if (this.selectionIndex >= this.results.length - 1) {
|
|
15430
15595
|
this.selectionIndex = this.results.length - 1;
|
|
15431
15596
|
}
|
|
15432
15597
|
break;
|
|
15433
|
-
case (!
|
|
15598
|
+
case (!key?.ctrl && !key?.meta):
|
|
15434
15599
|
if (this.currentKeyword === void 0) {
|
|
15435
15600
|
this.currentKeyword = str;
|
|
15436
15601
|
} else {
|
|
@@ -15509,8 +15674,7 @@ ${resultBody}`;
|
|
|
15509
15674
|
}
|
|
15510
15675
|
}
|
|
15511
15676
|
restoreCursor() {
|
|
15512
|
-
|
|
15513
|
-
const cursortPos = this.keywordOffset() + (((_a = this.currentKeyword) == null ? void 0 : _a.length) || 0);
|
|
15677
|
+
const cursortPos = this.keywordOffset() + (this.currentKeyword?.length || 0);
|
|
15514
15678
|
this.write(`${ESC}${cursortPos}G`);
|
|
15515
15679
|
}
|
|
15516
15680
|
cancel() {
|
|
@@ -15565,7 +15729,7 @@ function registerConsoleShortcuts(ctx, stdin = process.stdin, stdout2) {
|
|
|
15565
15729
|
process.kill(process.pid, "SIGTSTP");
|
|
15566
15730
|
return;
|
|
15567
15731
|
}
|
|
15568
|
-
const name = key
|
|
15732
|
+
const name = key?.name;
|
|
15569
15733
|
if (ctx.runningPromise) {
|
|
15570
15734
|
if (cancelKeys.includes(name)) {
|
|
15571
15735
|
await ctx.cancelCurrentRun("keyboard-input");
|
|
@@ -15625,7 +15789,7 @@ function registerConsoleShortcuts(ctx, stdin = process.stdin, stdout2) {
|
|
|
15625
15789
|
const files = ctx.state.getFilepaths();
|
|
15626
15790
|
const cliFiles = ctx.config.standalone && !files.length ? await ctx.getTestFilepaths() : void 0;
|
|
15627
15791
|
await ctx.changeNamePattern(
|
|
15628
|
-
|
|
15792
|
+
filter?.trim() || "",
|
|
15629
15793
|
cliFiles,
|
|
15630
15794
|
"change pattern"
|
|
15631
15795
|
);
|
|
@@ -15655,7 +15819,7 @@ function registerConsoleShortcuts(ctx, stdin = process.stdin, stdout2) {
|
|
|
15655
15819
|
return files.map((file) => relative(ctx.config.root, file[1]));
|
|
15656
15820
|
});
|
|
15657
15821
|
on();
|
|
15658
|
-
latestFilename =
|
|
15822
|
+
latestFilename = filter?.trim() || "";
|
|
15659
15823
|
const lastResults = watchFilter.getLastResults();
|
|
15660
15824
|
await ctx.changeFilenamePattern(
|
|
15661
15825
|
latestFilename,
|
|
@@ -15673,7 +15837,7 @@ function registerConsoleShortcuts(ctx, stdin = process.stdin, stdout2) {
|
|
|
15673
15837
|
stdin.on("keypress", keypressHandler);
|
|
15674
15838
|
}
|
|
15675
15839
|
function off() {
|
|
15676
|
-
rl
|
|
15840
|
+
rl?.close();
|
|
15677
15841
|
rl = void 0;
|
|
15678
15842
|
stdin.removeListener("keypress", keypressHandler);
|
|
15679
15843
|
if (stdin.isTTY) {
|
|
@@ -15704,8 +15868,8 @@ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides, v
|
|
|
15704
15868
|
}
|
|
15705
15869
|
}
|
|
15706
15870
|
}
|
|
15707
|
-
const stdin =
|
|
15708
|
-
const stdout =
|
|
15871
|
+
const stdin = vitestOptions?.stdin || process.stdin;
|
|
15872
|
+
const stdout = vitestOptions?.stdout || process.stdout;
|
|
15709
15873
|
let stdinCleanup;
|
|
15710
15874
|
if (stdin.isTTY && ctx.config.watch) {
|
|
15711
15875
|
stdinCleanup = registerConsoleShortcuts(ctx, stdin, stdout);
|
|
@@ -15744,15 +15908,14 @@ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides, v
|
|
|
15744
15908
|
if (ctx.shouldKeepServer()) {
|
|
15745
15909
|
return ctx;
|
|
15746
15910
|
}
|
|
15747
|
-
stdinCleanup
|
|
15911
|
+
stdinCleanup?.();
|
|
15748
15912
|
await ctx.close();
|
|
15749
15913
|
return ctx;
|
|
15750
15914
|
}
|
|
15751
15915
|
async function prepareVitest(mode, options = {}, viteOverrides, vitestOptions) {
|
|
15752
|
-
var _a, _b, _c;
|
|
15753
15916
|
process.env.TEST = "true";
|
|
15754
15917
|
process.env.VITEST = "true";
|
|
15755
|
-
|
|
15918
|
+
process.env.NODE_ENV ??= "test";
|
|
15756
15919
|
if (options.run) {
|
|
15757
15920
|
options.watch = false;
|
|
15758
15921
|
}
|
|
@@ -15760,8 +15923,8 @@ async function prepareVitest(mode, options = {}, viteOverrides, vitestOptions) {
|
|
|
15760
15923
|
if (typeof options.browser === "object" && !("enabled" in options.browser)) {
|
|
15761
15924
|
options.browser.enabled = true;
|
|
15762
15925
|
}
|
|
15763
|
-
if (typeof
|
|
15764
|
-
|
|
15926
|
+
if (typeof options.typecheck?.only === "boolean") {
|
|
15927
|
+
options.typecheck.enabled ??= true;
|
|
15765
15928
|
}
|
|
15766
15929
|
const ctx = await createVitest(mode, options, viteOverrides, vitestOptions);
|
|
15767
15930
|
const environmentPackage = getEnvPackageName(ctx.config.environment);
|
|
@@ -15774,8 +15937,7 @@ async function prepareVitest(mode, options = {}, viteOverrides, vitestOptions) {
|
|
|
15774
15937
|
function processCollected(ctx, files, options) {
|
|
15775
15938
|
let errorsPrinted = false;
|
|
15776
15939
|
forEachSuite(files, (suite) => {
|
|
15777
|
-
|
|
15778
|
-
const errors = ((_a = suite.result) == null ? void 0 : _a.errors) || [];
|
|
15940
|
+
const errors = suite.result?.errors || [];
|
|
15779
15941
|
errors.forEach((error) => {
|
|
15780
15942
|
errorsPrinted = true;
|
|
15781
15943
|
ctx.logger.printError(error, {
|
|
@@ -15839,6 +16001,23 @@ function formatCollectedAsString(files) {
|
|
|
15839
16001
|
});
|
|
15840
16002
|
}).flat();
|
|
15841
16003
|
}
|
|
16004
|
+
const envPackageNames = {
|
|
16005
|
+
"jsdom": "jsdom",
|
|
16006
|
+
"happy-dom": "happy-dom",
|
|
16007
|
+
"edge-runtime": "@edge-runtime/vm"
|
|
16008
|
+
};
|
|
16009
|
+
function getEnvPackageName(env) {
|
|
16010
|
+
if (env === "node") {
|
|
16011
|
+
return null;
|
|
16012
|
+
}
|
|
16013
|
+
if (env in envPackageNames) {
|
|
16014
|
+
return envPackageNames[env];
|
|
16015
|
+
}
|
|
16016
|
+
if (env[0] === "." || env[0] === "/") {
|
|
16017
|
+
return null;
|
|
16018
|
+
}
|
|
16019
|
+
return `vitest-environment-${env}`;
|
|
16020
|
+
}
|
|
15842
16021
|
|
|
15843
16022
|
var cliApi = /*#__PURE__*/Object.freeze({
|
|
15844
16023
|
__proto__: null,
|