vitest 1.0.0-beta.1 → 1.0.0-beta.3
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 +0 -29
- package/dist/browser.d.ts +2 -2
- package/dist/browser.js +2 -2
- package/dist/child.js +9 -4
- package/dist/{chunk-api-setup.0aeabd21.js → chunk-api-setup.37a43981.js} +3 -2
- package/dist/{chunk-install-pkg.a430b45e.js → chunk-install-pkg.6349b322.js} +22 -21
- package/dist/{chunk-integrations-globals.c3c5e678.js → chunk-integrations-globals.9df12d91.js} +2 -3
- package/dist/{chunk-node-git.36288174.js → chunk-node-git.6c12e560.js} +1 -1
- package/dist/{chunk-runtime-console.ea222ffb.js → chunk-runtime-console.f3263f87.js} +19 -4
- package/dist/cli-wrapper.js +1 -1
- package/dist/cli.js +14 -18
- package/dist/config.cjs +2 -1
- package/dist/config.d.ts +3 -3
- package/dist/config.js +2 -1
- package/dist/coverage.d.ts +1 -1
- package/dist/coverage.js +2 -2
- package/dist/entry-vm.js +9 -4
- package/dist/entry.js +10 -5
- package/dist/environments.d.ts +1 -1
- package/dist/environments.js +1 -13
- package/dist/execute.d.ts +1 -1
- package/dist/execute.js +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.js +3 -4
- package/dist/node.d.ts +5 -3
- package/dist/node.js +14 -13
- package/dist/{reporters-7bd09217.d.ts → reporters-1678fe04.d.ts} +84 -47
- package/dist/reporters.d.ts +1 -1
- package/dist/reporters.js +6 -1
- package/dist/runners.d.ts +3 -2
- package/dist/runners.js +33 -37
- package/dist/{suite-543d56bd.d.ts → suite-0579b50d.d.ts} +1 -1
- package/dist/suite.d.ts +2 -2
- package/dist/{vendor-environments.e73c5410.js → vendor-environments.dcc4a34e.js} +6 -37
- package/dist/{vendor-execute.07d1a420.js → vendor-execute.e6e4e89b.js} +1 -0
- package/dist/{vendor-index.d36f5516.js → vendor-index.3d079eea.js} +6 -1
- package/dist/{vendor-index.f7fcd5e8.js → vendor-index.68ecee35.js} +1 -1
- package/dist/{vendor-index.85fc950a.js → vendor-index.8efe7746.js} +375 -375
- package/dist/{vendor-index.0b5b3600.js → vendor-loader.9c966f23.js} +36 -9
- package/dist/{vendor-node.bde9fb47.js → vendor-node.327f8f1f.js} +1996 -1984
- package/dist/{vendor-reporters.f6975b8d.js → vendor-reporters.b9600369.js} +42 -24
- package/dist/vendor-vi.d30b47ae.js +3510 -0
- package/dist/vm.js +10 -5
- package/dist/worker.js +9 -4
- package/package.json +12 -28
- package/dist/loader.js +0 -100
- package/dist/vendor-index.98139333.js +0 -129
- package/dist/vendor-vi.7f2b988f.js +0 -3491
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { relative, resolve, basename, dirname, join, extname, normalize, toNamespacedPath } from 'pathe';
|
|
2
2
|
import { loadConfigFromFile, searchForWorkspaceRoot, version as version$2, createServer, mergeConfig } from 'vite';
|
|
3
3
|
import path$a from 'node:path';
|
|
4
|
-
import url, { fileURLToPath
|
|
4
|
+
import url, { fileURLToPath } from 'node:url';
|
|
5
5
|
import process$1 from 'node:process';
|
|
6
6
|
import fs$8, { promises, existsSync, readFileSync } from 'node:fs';
|
|
7
7
|
import { E as EXIT_CODE_RESTART, c as configFiles, d as defaultPort, a as defaultBrowserPort, w as workspacesFiles, C as CONFIG_NAMES } from './vendor-constants.538d9b49.js';
|
|
8
8
|
import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './vendor-_commonjsHelpers.7d1333e8.js';
|
|
9
9
|
import require$$0 from 'os';
|
|
10
10
|
import f$1 from 'path';
|
|
11
|
-
import require$$
|
|
12
|
-
import require$$0$
|
|
13
|
-
import require$$2
|
|
11
|
+
import require$$0$1 from 'util';
|
|
12
|
+
import require$$0$2 from 'stream';
|
|
13
|
+
import require$$2 from 'events';
|
|
14
14
|
import $ from 'fs';
|
|
15
15
|
import c from 'picocolors';
|
|
16
16
|
import { slash as slash$2, normalizeRequestId, cleanUrl } from 'vite-node/utils';
|
|
@@ -19,7 +19,7 @@ import { SnapshotManager } from '@vitest/snapshot/manager';
|
|
|
19
19
|
import { ViteNodeServer } from 'vite-node/server';
|
|
20
20
|
import { r as removeUndefinedValues, a as isWindows } from './vendor-index.29282562.js';
|
|
21
21
|
import { g as getCoverageProvider, C as CoverageProviderMap } from './vendor-coverage.78040316.js';
|
|
22
|
-
import {
|
|
22
|
+
import { r as rootDir } from './vendor-paths.84fc7a99.js';
|
|
23
23
|
import v8 from 'node:v8';
|
|
24
24
|
import * as nodeos from 'node:os';
|
|
25
25
|
import EventEmitter from 'node:events';
|
|
@@ -28,22 +28,23 @@ import { c as createBirpc } from './vendor-index.1ca68bd5.js';
|
|
|
28
28
|
import { g as groupBy, A as AggregateErrorPonyfill, s as slash$1, t as toArray, i as isPrimitive, d as deepMerge, n as noop$1, a as stdout } from './vendor-base.9c08bbd0.js';
|
|
29
29
|
import { MessageChannel } from 'node:worker_threads';
|
|
30
30
|
import { createDefer, shuffle, inspect, positionToOffset, lineSplitRE, toArray as toArray$1, notNullish } from '@vitest/utils';
|
|
31
|
+
import { writeFile, rm } from 'node:fs/promises';
|
|
32
|
+
import { performance } from 'node:perf_hooks';
|
|
33
|
+
import { e as execa, a as signalExit } from './vendor-index.8efe7746.js';
|
|
34
|
+
import { TraceMap, generatedPositionFor, parseErrorStacktrace } from '@vitest/utils/source-map';
|
|
31
35
|
import { isPackageExists, resolveModule } from 'local-pkg';
|
|
32
36
|
import { isCI } from 'std-env';
|
|
33
|
-
import { R as ReportersMap, B as BenchmarkReportsMap, s as stringWidth, a as ansiStyles, b as stripAnsi, c as sliceAnsi, d as divider, F as F_POINTER, e as cliTruncate } from './vendor-reporters.f6975b8d.js';
|
|
34
|
-
import crypto, { createHash } from 'node:crypto';
|
|
35
|
-
import { o as onExit, e as execa } from './vendor-index.85fc950a.js';
|
|
36
|
-
import { TraceMap, generatedPositionFor, parseErrorStacktrace } from '@vitest/utils/source-map';
|
|
37
|
-
import { writeFile, rm } from 'node:fs/promises';
|
|
38
37
|
import ue from 'module';
|
|
39
38
|
import { parse as parse$4 } from 'acorn';
|
|
40
39
|
import { ancestor, simple, findNodeAround } from 'acorn-walk';
|
|
41
40
|
import { generateHash, calculateSuiteHash, someTasksAreOnly, interpretTaskModes, getTasks, hasFailed } from '@vitest/runner/utils';
|
|
41
|
+
import { R as ReportersMap, B as BenchmarkReportsMap, s as stringWidth, a as ansiStyles, b as stripAnsi, c as sliceAnsi, d as divider, F as F_POINTER, e as cliTruncate } from './vendor-reporters.b9600369.js';
|
|
42
|
+
import crypto, { createHash } from 'node:crypto';
|
|
42
43
|
import MagicString from 'magic-string';
|
|
43
44
|
import { stripLiteral } from 'strip-literal';
|
|
44
|
-
import { g as getEnvPackageName } from './vendor-environments.
|
|
45
|
+
import { g as getEnvPackageName } from './vendor-environments.dcc4a34e.js';
|
|
45
46
|
import readline from 'node:readline';
|
|
46
|
-
import require$$0$
|
|
47
|
+
import require$$0$3 from 'readline';
|
|
47
48
|
|
|
48
49
|
function _mergeNamespaces(n, m) {
|
|
49
50
|
m.forEach(function (e) {
|
|
@@ -60,7 +61,7 @@ function _mergeNamespaces(n, m) {
|
|
|
60
61
|
return Object.freeze(n);
|
|
61
62
|
}
|
|
62
63
|
|
|
63
|
-
var version$1 = "1.0.0-beta.
|
|
64
|
+
var version$1 = "1.0.0-beta.3";
|
|
64
65
|
|
|
65
66
|
const __dirname$1 = url.fileURLToPath(new URL(".", import.meta.url));
|
|
66
67
|
async function ensurePackageInstalled(dependency, root) {
|
|
@@ -79,7 +80,7 @@ async function ensurePackageInstalled(dependency, root) {
|
|
|
79
80
|
message: c.reset(`Do you want to install ${c.green(dependency)}?`)
|
|
80
81
|
});
|
|
81
82
|
if (install) {
|
|
82
|
-
await (await import('./chunk-install-pkg.
|
|
83
|
+
await (await import('./chunk-install-pkg.6349b322.js')).installPackage(dependency, { dev: true });
|
|
83
84
|
process.stderr.write(c.yellow(`
|
|
84
85
|
Package ${dependency} installed, re-run the command to start.
|
|
85
86
|
`));
|
|
@@ -1166,7 +1167,7 @@ var toRegexRange_1 = toRegexRange$1;
|
|
|
1166
1167
|
* Licensed under the MIT License.
|
|
1167
1168
|
*/
|
|
1168
1169
|
|
|
1169
|
-
const util$3 = require$$
|
|
1170
|
+
const util$3 = require$$0$1;
|
|
1170
1171
|
const toRegexRange = toRegexRange_1;
|
|
1171
1172
|
|
|
1172
1173
|
const isObject$1 = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
|
@@ -4198,7 +4199,7 @@ var picomatch_1 = picomatch$2;
|
|
|
4198
4199
|
|
|
4199
4200
|
var picomatch$1 = picomatch_1;
|
|
4200
4201
|
|
|
4201
|
-
const util$2 = require$$
|
|
4202
|
+
const util$2 = require$$0$1;
|
|
4202
4203
|
const braces = braces_1;
|
|
4203
4204
|
const picomatch = picomatch$1;
|
|
4204
4205
|
const utils$b = utils$f;
|
|
@@ -4863,7 +4864,7 @@ var stream$4 = {};
|
|
|
4863
4864
|
* Copyright (c) 2014-2020 Teambition
|
|
4864
4865
|
* Licensed under the MIT license.
|
|
4865
4866
|
*/
|
|
4866
|
-
const Stream = require$$0$
|
|
4867
|
+
const Stream = require$$0$2;
|
|
4867
4868
|
const PassThrough = Stream.PassThrough;
|
|
4868
4869
|
const slice = Array.prototype.slice;
|
|
4869
4870
|
|
|
@@ -6027,7 +6028,7 @@ let Reader$1 = class Reader {
|
|
|
6027
6028
|
reader$1.default = Reader$1;
|
|
6028
6029
|
|
|
6029
6030
|
Object.defineProperty(async$4, "__esModule", { value: true });
|
|
6030
|
-
const events_1 = require$$2
|
|
6031
|
+
const events_1 = require$$2;
|
|
6031
6032
|
const fsScandir$2 = out$2;
|
|
6032
6033
|
const fastq = queueExports;
|
|
6033
6034
|
const common$1 = common$3;
|
|
@@ -6156,7 +6157,7 @@ function callSuccessCallback(callback, entries) {
|
|
|
6156
6157
|
var stream$2 = {};
|
|
6157
6158
|
|
|
6158
6159
|
Object.defineProperty(stream$2, "__esModule", { value: true });
|
|
6159
|
-
const stream_1$5 = require$$0$
|
|
6160
|
+
const stream_1$5 = require$$0$2;
|
|
6160
6161
|
const async_1$3 = async$4;
|
|
6161
6162
|
class StreamProvider {
|
|
6162
6163
|
constructor(_root, _settings) {
|
|
@@ -6366,7 +6367,7 @@ reader.default = Reader;
|
|
|
6366
6367
|
var stream$1 = {};
|
|
6367
6368
|
|
|
6368
6369
|
Object.defineProperty(stream$1, "__esModule", { value: true });
|
|
6369
|
-
const stream_1$3 = require$$0$
|
|
6370
|
+
const stream_1$3 = require$$0$2;
|
|
6370
6371
|
const fsStat$1 = out$1;
|
|
6371
6372
|
const fsWalk$2 = out$3;
|
|
6372
6373
|
const reader_1$2 = reader;
|
|
@@ -6792,7 +6793,7 @@ async$7.default = ProviderAsync;
|
|
|
6792
6793
|
var stream = {};
|
|
6793
6794
|
|
|
6794
6795
|
Object.defineProperty(stream, "__esModule", { value: true });
|
|
6795
|
-
const stream_1$1 = require$$0$
|
|
6796
|
+
const stream_1$1 = require$$0$2;
|
|
6796
6797
|
const stream_2 = stream$1;
|
|
6797
6798
|
const provider_1$1 = provider;
|
|
6798
6799
|
class ProviderStream extends provider_1$1.default {
|
|
@@ -7102,7 +7103,7 @@ function createMethodsRPC(project) {
|
|
|
7102
7103
|
const ctx = project.ctx;
|
|
7103
7104
|
return {
|
|
7104
7105
|
async onWorkerExit(error, code) {
|
|
7105
|
-
await ctx.logger.printError(error, { type: "Unexpected Exit" });
|
|
7106
|
+
await ctx.logger.printError(error, { type: "Unexpected Exit", fullStack: true });
|
|
7106
7107
|
process.exit(code || 1);
|
|
7107
7108
|
},
|
|
7108
7109
|
snapshotSaved(snapshot) {
|
|
@@ -7164,7 +7165,6 @@ function createMethodsRPC(project) {
|
|
|
7164
7165
|
};
|
|
7165
7166
|
}
|
|
7166
7167
|
|
|
7167
|
-
const childPath = fileURLToPath(pathToFileURL(resolve(distDir, "./child.js")).href);
|
|
7168
7168
|
function createChildProcessChannel(project) {
|
|
7169
7169
|
const emitter = new EventEmitter();
|
|
7170
7170
|
const cleanup = () => emitter.removeAllListeners();
|
|
@@ -7195,7 +7195,7 @@ function stringifyRegex(input) {
|
|
|
7195
7195
|
return input;
|
|
7196
7196
|
return `$$vitest:${input.toString()}`;
|
|
7197
7197
|
}
|
|
7198
|
-
function createChildProcessPool(ctx, { execArgv, env }) {
|
|
7198
|
+
function createChildProcessPool(ctx, { execArgv, env, forksPath }) {
|
|
7199
7199
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7200
7200
|
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length;
|
|
7201
7201
|
const threadsCount = ctx.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
|
|
@@ -7203,7 +7203,7 @@ function createChildProcessPool(ctx, { execArgv, env }) {
|
|
|
7203
7203
|
const minThreads = ((_d = (_c = ctx.config.poolOptions) == null ? void 0 : _c.forks) == null ? void 0 : _d.minForks) ?? threadsCount;
|
|
7204
7204
|
const options = {
|
|
7205
7205
|
runtime: "child_process",
|
|
7206
|
-
filename:
|
|
7206
|
+
filename: forksPath,
|
|
7207
7207
|
maxThreads,
|
|
7208
7208
|
minThreads,
|
|
7209
7209
|
env,
|
|
@@ -7231,7 +7231,8 @@ function createChildProcessPool(ctx, { execArgv, env }) {
|
|
|
7231
7231
|
files,
|
|
7232
7232
|
invalidates,
|
|
7233
7233
|
environment,
|
|
7234
|
-
workerId
|
|
7234
|
+
workerId,
|
|
7235
|
+
projectName: project.getName()
|
|
7235
7236
|
};
|
|
7236
7237
|
try {
|
|
7237
7238
|
await pool.run(data, { name, channel });
|
|
@@ -7292,7 +7293,7 @@ function createChildProcessPool(ctx, { execArgv, env }) {
|
|
|
7292
7293
|
const grouped = groupBy(files, ({ project, environment }) => project.getName() + environment.name + JSON.stringify(environment.options));
|
|
7293
7294
|
for (const group of Object.values(grouped)) {
|
|
7294
7295
|
results.push(...await Promise.allSettled(group.map(({ file, environment, project }) => runFiles(project, getConfig(project), [file], environment, invalidates))));
|
|
7295
|
-
await new Promise((
|
|
7296
|
+
await new Promise((resolve) => pool.queueSize === 0 ? resolve() : pool.once("drain", resolve));
|
|
7296
7297
|
await pool.recycleWorkers();
|
|
7297
7298
|
}
|
|
7298
7299
|
}
|
|
@@ -7327,7 +7328,6 @@ function createChildProcessPool(ctx, { execArgv, env }) {
|
|
|
7327
7328
|
};
|
|
7328
7329
|
}
|
|
7329
7330
|
|
|
7330
|
-
const workerPath$1 = pathToFileURL(resolve(distDir, "./worker.js")).href;
|
|
7331
7331
|
function createWorkerChannel$1(project) {
|
|
7332
7332
|
const channel = new MessageChannel();
|
|
7333
7333
|
const port = channel.port2;
|
|
@@ -7347,14 +7347,14 @@ function createWorkerChannel$1(project) {
|
|
|
7347
7347
|
project.ctx.onCancel((reason) => rpc.onCancel(reason));
|
|
7348
7348
|
return { workerPort, port };
|
|
7349
7349
|
}
|
|
7350
|
-
function createThreadsPool(ctx, { execArgv, env }) {
|
|
7350
|
+
function createThreadsPool(ctx, { execArgv, env, workerPath }) {
|
|
7351
7351
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
7352
7352
|
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length;
|
|
7353
7353
|
const threadsCount = ctx.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
|
|
7354
7354
|
const maxThreads = ((_b = (_a = ctx.config.poolOptions) == null ? void 0 : _a.threads) == null ? void 0 : _b.maxThreads) ?? threadsCount;
|
|
7355
7355
|
const minThreads = ((_d = (_c = ctx.config.poolOptions) == null ? void 0 : _c.threads) == null ? void 0 : _d.minThreads) ?? threadsCount;
|
|
7356
7356
|
const options = {
|
|
7357
|
-
filename: workerPath
|
|
7357
|
+
filename: workerPath,
|
|
7358
7358
|
// TODO: investigate further
|
|
7359
7359
|
// It seems atomics introduced V8 Fatal Error https://github.com/vitest-dev/vitest/issues/1191
|
|
7360
7360
|
useAtomics: ((_f = (_e = ctx.config.poolOptions) == null ? void 0 : _e.threads) == null ? void 0 : _f.useAtomics) ?? false,
|
|
@@ -7386,7 +7386,8 @@ function createThreadsPool(ctx, { execArgv, env }) {
|
|
|
7386
7386
|
files,
|
|
7387
7387
|
invalidates,
|
|
7388
7388
|
environment,
|
|
7389
|
-
workerId
|
|
7389
|
+
workerId,
|
|
7390
|
+
projectName: project.getName()
|
|
7390
7391
|
};
|
|
7391
7392
|
try {
|
|
7392
7393
|
await pool.run(data, { transferList: [workerPort], name });
|
|
@@ -7443,7 +7444,7 @@ function createThreadsPool(ctx, { execArgv, env }) {
|
|
|
7443
7444
|
const grouped = groupBy(files, ({ project, environment }) => project.getName() + environment.name + JSON.stringify(environment.options));
|
|
7444
7445
|
for (const group of Object.values(grouped)) {
|
|
7445
7446
|
results.push(...await Promise.allSettled(group.map(({ file, environment, project }) => runFiles(project, getConfig(project), [file], environment, invalidates))));
|
|
7446
|
-
await new Promise((
|
|
7447
|
+
await new Promise((resolve) => pool.queueSize === 0 ? resolve() : pool.once("drain", resolve));
|
|
7447
7448
|
await pool.recycleWorkers();
|
|
7448
7449
|
}
|
|
7449
7450
|
}
|
|
@@ -7614,7 +7615,6 @@ function stringToBytes(input, percentageReference) {
|
|
|
7614
7615
|
return null;
|
|
7615
7616
|
}
|
|
7616
7617
|
|
|
7617
|
-
const workerPath = pathToFileURL(resolve(distDir, "./vm.js")).href;
|
|
7618
7618
|
const suppressWarningsPath = resolve(rootDir, "./suppress-warnings.cjs");
|
|
7619
7619
|
function createWorkerChannel(project) {
|
|
7620
7620
|
const channel = new MessageChannel();
|
|
@@ -7635,14 +7635,14 @@ function createWorkerChannel(project) {
|
|
|
7635
7635
|
project.ctx.onCancel((reason) => rpc.onCancel(reason));
|
|
7636
7636
|
return { workerPort, port };
|
|
7637
7637
|
}
|
|
7638
|
-
function createVmThreadsPool(ctx, { execArgv, env }) {
|
|
7638
|
+
function createVmThreadsPool(ctx, { execArgv, env, vmPath }) {
|
|
7639
7639
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
7640
7640
|
const numCpus = typeof nodeos.availableParallelism === "function" ? nodeos.availableParallelism() : nodeos.cpus().length;
|
|
7641
7641
|
const threadsCount = ctx.config.watch ? Math.max(Math.floor(numCpus / 2), 1) : Math.max(numCpus - 1, 1);
|
|
7642
7642
|
const maxThreads = ((_b = (_a = ctx.config.poolOptions) == null ? void 0 : _a.vmThreads) == null ? void 0 : _b.maxThreads) ?? threadsCount;
|
|
7643
7643
|
const minThreads = ((_d = (_c = ctx.config.poolOptions) == null ? void 0 : _c.vmThreads) == null ? void 0 : _d.minThreads) ?? threadsCount;
|
|
7644
7644
|
const options = {
|
|
7645
|
-
filename:
|
|
7645
|
+
filename: vmPath,
|
|
7646
7646
|
// TODO: investigate further
|
|
7647
7647
|
// It seems atomics introduced V8 Fatal Error https://github.com/vitest-dev/vitest/issues/1191
|
|
7648
7648
|
useAtomics: ((_f = (_e = ctx.config.poolOptions) == null ? void 0 : _e.vmThreads) == null ? void 0 : _f.useAtomics) ?? false,
|
|
@@ -7677,7 +7677,8 @@ function createVmThreadsPool(ctx, { execArgv, env }) {
|
|
|
7677
7677
|
files,
|
|
7678
7678
|
invalidates,
|
|
7679
7679
|
environment,
|
|
7680
|
-
workerId
|
|
7680
|
+
workerId,
|
|
7681
|
+
projectName: project.getName()
|
|
7681
7682
|
};
|
|
7682
7683
|
try {
|
|
7683
7684
|
await pool.run(data, { transferList: [workerPort], name });
|
|
@@ -7740,1878 +7741,1986 @@ function getMemoryLimit(config) {
|
|
|
7740
7741
|
return null;
|
|
7741
7742
|
}
|
|
7742
7743
|
|
|
7743
|
-
const
|
|
7744
|
-
|
|
7745
|
-
function
|
|
7746
|
-
|
|
7747
|
-
forks: null,
|
|
7748
|
-
|
|
7749
|
-
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
7760
|
-
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
...execArgv,
|
|
7782
|
-
...conditions
|
|
7783
|
-
],
|
|
7784
|
-
env: {
|
|
7785
|
-
TEST: "true",
|
|
7786
|
-
VITEST: "true",
|
|
7787
|
-
NODE_ENV: ctx.config.mode || "test",
|
|
7788
|
-
VITEST_MODE: ctx.config.watch ? "WATCH" : "RUN",
|
|
7789
|
-
...process.env,
|
|
7790
|
-
...ctx.config.env
|
|
7791
|
-
}
|
|
7792
|
-
};
|
|
7793
|
-
const filesByPool = {
|
|
7794
|
-
forks: [],
|
|
7795
|
-
threads: [],
|
|
7796
|
-
browser: [],
|
|
7797
|
-
vmThreads: []
|
|
7798
|
-
};
|
|
7799
|
-
for (const spec of files) {
|
|
7800
|
-
const pool = getPoolName(spec);
|
|
7801
|
-
if (!(pool in filesByPool))
|
|
7802
|
-
throw new Error(`Unknown pool name "${pool}" for ${spec[1]}. Available pools: ${Object.keys(filesByPool).join(", ")}`);
|
|
7803
|
-
filesByPool[pool].push(spec);
|
|
7804
|
-
}
|
|
7805
|
-
await Promise.all(Object.entries(filesByPool).map((entry) => {
|
|
7806
|
-
const [pool, files2] = entry;
|
|
7807
|
-
if (!files2.length)
|
|
7808
|
-
return null;
|
|
7809
|
-
if (pool === "browser") {
|
|
7810
|
-
pools.browser ?? (pools.browser = createBrowserPool(ctx));
|
|
7811
|
-
return pools.browser.runTests(files2, invalidate);
|
|
7812
|
-
}
|
|
7813
|
-
if (pool === "vmThreads") {
|
|
7814
|
-
pools.vmThreads ?? (pools.vmThreads = createVmThreadsPool(ctx, options));
|
|
7815
|
-
return pools.vmThreads.runTests(files2, invalidate);
|
|
7816
|
-
}
|
|
7817
|
-
if (pool === "threads") {
|
|
7818
|
-
pools.threads ?? (pools.threads = createThreadsPool(ctx, options));
|
|
7819
|
-
return pools.threads.runTests(files2, invalidate);
|
|
7820
|
-
}
|
|
7821
|
-
pools.forks ?? (pools.forks = createChildProcessPool(ctx, options));
|
|
7822
|
-
return pools.forks.runTests(files2, invalidate);
|
|
7823
|
-
}));
|
|
7824
|
-
}
|
|
7825
|
-
return {
|
|
7826
|
-
runTests,
|
|
7827
|
-
async close() {
|
|
7828
|
-
await Promise.all(Object.values(pools).map((p) => p == null ? void 0 : p.close()));
|
|
7744
|
+
const A=r=>r!==null&&typeof r=="object",a=(r,t)=>Object.assign(new Error(`[${r}]: ${t}`),{code:r}),_$1="ERR_INVALID_PACKAGE_CONFIG",E="ERR_INVALID_PACKAGE_TARGET",I="ERR_PACKAGE_PATH_NOT_EXPORTED",R$1=/^\d+$/,O=/^(\.{1,2}|node_modules)$/i,w=/\/|\\/;var h=(r=>(r.Export="exports",r.Import="imports",r))(h||{});const f=(r,t,e,o,c)=>{if(t==null)return [];if(typeof t=="string"){const[n,...i]=t.split(w);if(n===".."||i.some(l=>O.test(l)))throw a(E,`Invalid "${r}" target "${t}" defined in the package config`);return [c?t.replace(/\*/g,c):t]}if(Array.isArray(t))return t.flatMap(n=>f(r,n,e,o,c));if(A(t)){for(const n of Object.keys(t)){if(R$1.test(n))throw a(_$1,"Cannot contain numeric property keys");if(n==="default"||o.includes(n))return f(r,t[n],e,o,c)}return []}throw a(E,`Invalid "${r}" target "${t}"`)},s="*",m=(r,t)=>{const e=r.indexOf(s),o=t.indexOf(s);return e===o?t.length>r.length:o>e};function d$1(r,t){if(!t.includes(s)&&r.hasOwnProperty(t))return [t];let e,o;for(const c of Object.keys(r))if(c.includes(s)){const[n,i,l]=c.split(s);if(l===void 0&&t.startsWith(n)&&t.endsWith(i)){const g=t.slice(n.length,-i.length||void 0);g&&(!e||m(e,c))&&(e=c,o=g);}}return [e,o]}const p=r=>Object.keys(r).reduce((t,e)=>{const o=e===""||e[0]!==".";if(t===void 0||t===o)return o;throw a(_$1,'"exports" cannot contain some keys starting with "." and some not')},void 0),u=/^\w+:/,v=(r,t,e)=>{if(!r)throw new Error('"exports" is required');t=t===""?".":`./${t}`,(typeof r=="string"||Array.isArray(r)||A(r)&&p(r))&&(r={".":r});const[o,c]=d$1(r,t),n=f(h.Export,r[o],t,e,c);if(n.length===0)throw a(I,t==="."?'No "exports" main defined':`Package subpath '${t}' is not defined by "exports"`);for(const i of n)if(!i.startsWith("./")&&!u.test(i))throw a(E,`Invalid "exports" target "${i}" defined in the package config`);return n};
|
|
7745
|
+
|
|
7746
|
+
function U(e){return e.startsWith("\\\\?\\")?e:e.replace(/\\/g,"/")}const Y=(e,s)=>{for(;;){const i=f$1.posix.join(e,s);if($.existsSync(i))return i;const n=f$1.dirname(e);if(n===e)return;e=n;}},S=/^\.{1,2}(\/.*)?$/,V=e=>{const s=U(e);return S.test(s)?s:`./${s}`};function re(e,s=!1){const i=e.length;let n=0,t="",l=0,c=16,m=0,p=0,L=0,g=0,T=0;function k(o,r){let u=0,E=0;for(;u<o||!r;){let v=e.charCodeAt(n);if(v>=48&&v<=57)E=E*16+v-48;else if(v>=65&&v<=70)E=E*16+v-65+10;else if(v>=97&&v<=102)E=E*16+v-97+10;else break;n++,u++;}return u<o&&(E=-1),E}function j(o){n=o,t="",l=0,c=16,T=0;}function w(){let o=n;if(e.charCodeAt(n)===48)n++;else for(n++;n<e.length&&_(e.charCodeAt(n));)n++;if(n<e.length&&e.charCodeAt(n)===46)if(n++,n<e.length&&_(e.charCodeAt(n)))for(n++;n<e.length&&_(e.charCodeAt(n));)n++;else return T=3,e.substring(o,n);let r=n;if(n<e.length&&(e.charCodeAt(n)===69||e.charCodeAt(n)===101))if(n++,(n<e.length&&e.charCodeAt(n)===43||e.charCodeAt(n)===45)&&n++,n<e.length&&_(e.charCodeAt(n))){for(n++;n<e.length&&_(e.charCodeAt(n));)n++;r=n;}else T=3;return e.substring(o,r)}function b(){let o="",r=n;for(;;){if(n>=i){o+=e.substring(r,n),T=2;break}const u=e.charCodeAt(n);if(u===34){o+=e.substring(r,n),n++;break}if(u===92){if(o+=e.substring(r,n),n++,n>=i){T=2;break}switch(e.charCodeAt(n++)){case 34:o+='"';break;case 92:o+="\\";break;case 47:o+="/";break;case 98:o+="\b";break;case 102:o+="\f";break;case 110:o+=`
|
|
7747
|
+
`;break;case 114:o+="\r";break;case 116:o+=" ";break;case 117:const v=k(4,!0);v>=0?o+=String.fromCharCode(v):T=4;break;default:T=5;}r=n;continue}if(u>=0&&u<=31)if(F(u)){o+=e.substring(r,n),T=2;break}else T=6;n++;}return o}function A(){if(t="",T=0,l=n,p=m,g=L,n>=i)return l=i,c=17;let o=e.charCodeAt(n);if(W(o)){do n++,t+=String.fromCharCode(o),o=e.charCodeAt(n);while(W(o));return c=15}if(F(o))return n++,t+=String.fromCharCode(o),o===13&&e.charCodeAt(n)===10&&(n++,t+=`
|
|
7748
|
+
`),m++,L=n,c=14;switch(o){case 123:return n++,c=1;case 125:return n++,c=2;case 91:return n++,c=3;case 93:return n++,c=4;case 58:return n++,c=6;case 44:return n++,c=5;case 34:return n++,t=b(),c=10;case 47:const r=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<i&&!F(e.charCodeAt(n));)n++;return t=e.substring(r,n),c=12}if(e.charCodeAt(n+1)===42){n+=2;const u=i-1;let E=!1;for(;n<u;){const v=e.charCodeAt(n);if(v===42&&e.charCodeAt(n+1)===47){n+=2,E=!0;break}n++,F(v)&&(v===13&&e.charCodeAt(n)===10&&n++,m++,L=n);}return E||(n++,T=1),t=e.substring(r,n),c=13}return t+=String.fromCharCode(o),n++,c=16;case 45:if(t+=String.fromCharCode(o),n++,n===i||!_(e.charCodeAt(n)))return c=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return t+=w(),c=11;default:for(;n<i&&N(o);)n++,o=e.charCodeAt(n);if(l!==n){switch(t=e.substring(l,n),t){case"true":return c=8;case"false":return c=9;case"null":return c=7}return c=16}return t+=String.fromCharCode(o),n++,c=16}}function N(o){if(W(o)||F(o))return !1;switch(o){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return !1}return !0}function h(){let o;do o=A();while(o>=12&&o<=15);return o}return {setPosition:j,getPosition:()=>n,scan:s?h:A,getToken:()=>c,getTokenValue:()=>t,getTokenOffset:()=>l,getTokenLength:()=>n-l,getTokenStartLine:()=>p,getTokenStartCharacter:()=>l-g,getTokenError:()=>T}}function W(e){return e===32||e===9}function F(e){return e===10||e===13}function _(e){return e>=48&&e<=57}var Z;(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab";})(Z||(Z={}));var x;(function(e){e.DEFAULT={allowTrailingComma:!1};})(x||(x={}));function pe(e,s=[],i=x.DEFAULT){let n=null,t=[];const l=[];function c(p){Array.isArray(t)?t.push(p):n!==null&&(t[n]=p);}return ge(e,{onObjectBegin:()=>{const p={};c(p),l.push(t),t=p,n=null;},onObjectProperty:p=>{n=p;},onObjectEnd:()=>{t=l.pop();},onArrayBegin:()=>{const p=[];c(p),l.push(t),t=p,n=null;},onArrayEnd:()=>{t=l.pop();},onLiteralValue:c,onError:(p,L,g)=>{s.push({error:p,offset:L,length:g});}},i),t[0]}function ge(e,s,i=x.DEFAULT){const n=re(e,!1),t=[];function l(a){return a?()=>a(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function c(a){return a?()=>a(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>t.slice()):()=>!0}function m(a){return a?O=>a(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function p(a){return a?O=>a(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>t.slice()):()=>!0}const L=c(s.onObjectBegin),g=p(s.onObjectProperty),T=l(s.onObjectEnd),k=c(s.onArrayBegin),j=l(s.onArrayEnd),w=p(s.onLiteralValue),b=m(s.onSeparator),A=l(s.onComment),N=m(s.onError),h=i&&i.disallowComments,o=i&&i.allowTrailingComma;function r(){for(;;){const a=n.scan();switch(n.getTokenError()){case 4:u(14);break;case 5:u(15);break;case 3:u(13);break;case 1:h||u(11);break;case 2:u(12);break;case 6:u(16);break}switch(a){case 12:case 13:h?u(10):A();break;case 16:u(1);break;case 15:case 14:break;default:return a}}}function u(a,O=[],X=[]){if(N(a),O.length+X.length>0){let y=n.getToken();for(;y!==17;){if(O.indexOf(y)!==-1){r();break}else if(X.indexOf(y)!==-1)break;y=r();}}}function E(a){const O=n.getTokenValue();return a?w(O):(g(O),t.push(O)),r(),!0}function v(){switch(n.getToken()){case 11:const a=n.getTokenValue();let O=Number(a);isNaN(O)&&(u(2),O=0),w(O);break;case 7:w(null);break;case 8:w(!0);break;case 9:w(!1);break;default:return !1}return r(),!0}function oe(){return n.getToken()!==10?(u(3,[],[2,5]),!1):(E(!1),n.getToken()===6?(b(":"),r(),P()||u(4,[],[2,5])):u(5,[],[2,5]),t.pop(),!0)}function le(){L(),r();let a=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(a||u(4,[],[]),b(","),r(),n.getToken()===2&&o)break}else a&&u(6,[],[]);oe()||u(4,[],[2,5]),a=!0;}return T(),n.getToken()!==2?u(7,[2],[]):r(),!0}function ce(){k(),r();let a=!0,O=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(O||u(4,[],[]),b(","),r(),n.getToken()===4&&o)break}else O&&u(6,[],[]);a?(t.push(0),a=!1):t[t.length-1]++,P()||u(4,[],[4,5]),O=!0;}return j(),a||t.pop(),n.getToken()!==4?u(8,[4],[]):r(),!0}function P(){switch(n.getToken()){case 3:return ce();case 1:return le();case 10:return E(!0);default:return v()}}return r(),n.getToken()===17?i.allowEmptyContent?!0:(u(4,[],[]),!1):P()?(n.getToken()!==17&&u(9,[],[]),!0):(u(4,[],[]),!1)}var d;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter";})(d||(d={}));var q;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF";})(q||(q={}));const ae=pe;var K;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter";})(K||(K={}));const C=e=>ae($.readFileSync(e,"utf8")),{existsSync:B}=$,me=()=>{const{findPnpApi:e}=ue;return e&&e(process.cwd())},J=(e,s,i)=>{let n="tsconfig.json";const t=C(e);if(t)if(!i&&t.exports)try{const[l]=v(t.exports,s,["require","types"]);n=l;}catch{return}else !s&&t.tsconfig&&(n=t.tsconfig);return f$1.join(e,"..",n)},M="package.json",R="tsconfig.json",ke=(e,s)=>{let i=e;if(e===".."&&(i=f$1.join(i,R)),e[0]==="."&&(i=f$1.resolve(s,i)),f$1.isAbsolute(i)){if(B(i)){if($.statSync(i).isFile())return i}else if(!i.endsWith(".json")){const k=`${i}.json`;if(B(k))return k}return}const[n,...t]=e.split("/"),l=n[0]==="@"?`${n}/${t.shift()}`:n,c=t.join("/"),m=me();if(m){const{resolveRequest:k}=m;try{if(l===e){const j=k(f$1.join(l,M),s);if(j){const w=J(j,c);if(w&&B(w))return w}}else {let j;try{j=k(e,s,{extensions:[".json"]});}catch{j=k(f$1.join(e,R),s);}if(j)return j}}catch{}}const p=Y(s,f$1.join("node_modules",l));if(!p||!$.statSync(p).isDirectory())return;const L=f$1.join(p,M);if(B(L)){const k=J(L,c);if(!k)return;if(B(k))return k}const g=f$1.join(p,c),T=g.endsWith(".json");if(!T){const k=`${g}.json`;if(B(k))return k}if(B(g)){if($.statSync(g).isDirectory()){const k=f$1.join(g,M);if(B(k)){const w=J(k,"",!0);if(w&&B(w))return w}const j=f$1.join(g,R);if(B(j))return j}else if(T)return g}},be=(e,s)=>{var i;const n=ke(e,s);if(!n)throw new Error(`File '${e}' not found.`);const t=G(n);if(delete t.references,(i=t.compilerOptions)!=null&&i.baseUrl){const{compilerOptions:l}=t;l.baseUrl=f$1.relative(s,f$1.join(f$1.dirname(n),l.baseUrl))||"./";}return t.files&&(t.files=t.files.map(l=>f$1.relative(s,f$1.join(f$1.dirname(n),l)))),t.include&&(t.include=t.include.map(l=>f$1.relative(s,f$1.join(f$1.dirname(n),l)))),t},G=e=>{let s;try{s=$.realpathSync(e);}catch{throw new Error(`Cannot resolve tsconfig at path: ${e}`)}const i=f$1.dirname(s);let n=C(s)||{};if(typeof n!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${e}`);if(n.extends){const t=Array.isArray(n.extends)?n.extends:[n.extends];delete n.extends;for(const l of t.reverse()){const c=be(l,i),m={...c,...n,compilerOptions:{...c.compilerOptions,...n.compilerOptions}};c.watchOptions&&(m.watchOptions={...c.watchOptions,...n.watchOptions}),n=m;}}if(n.compilerOptions){const{compilerOptions:t}=n;if(t.baseUrl){const l=f$1.resolve(i,t.baseUrl),c=V(f$1.relative(i,l));t.baseUrl=c;}t.outDir&&(Array.isArray(n.exclude)||(n.exclude=[]),n.exclude.push(t.outDir),t.outDir=V(t.outDir));}else n.compilerOptions={};if(n.files&&(n.files=n.files.map(V)),n.include&&(n.include=n.include.map(U)),n.watchOptions){const{watchOptions:t}=n;t.excludeDirectories&&(t.excludeDirectories=t.excludeDirectories.map(l=>U(f$1.resolve(i,l))));}return n},Te=(e=process.cwd(),s="tsconfig.json")=>{const i=Y(U(e),s);if(!i)return null;const n=G(i);return {path:i,config:n}};f$1.posix;process.platform==="win32";
|
|
7749
|
+
|
|
7750
|
+
const __dirname = url.fileURLToPath(new URL(".", import.meta.url));
|
|
7751
|
+
const newLineRegExp = /\r?\n/;
|
|
7752
|
+
const errCodeRegExp = /error TS(?<errCode>\d+)/;
|
|
7753
|
+
async function makeTscErrorInfo(errInfo) {
|
|
7754
|
+
var _a;
|
|
7755
|
+
const [errFilePathPos = "", ...errMsgRawArr] = errInfo.split(":");
|
|
7756
|
+
if (!errFilePathPos || errMsgRawArr.length === 0 || errMsgRawArr.join("").length === 0)
|
|
7757
|
+
return ["unknown filepath", null];
|
|
7758
|
+
const errMsgRaw = errMsgRawArr.join("").trim();
|
|
7759
|
+
const [errFilePath, errPos] = errFilePathPos.slice(0, -1).split("(");
|
|
7760
|
+
if (!errFilePath || !errPos)
|
|
7761
|
+
return ["unknown filepath", null];
|
|
7762
|
+
const [errLine, errCol] = errPos.split(",");
|
|
7763
|
+
if (!errLine || !errCol)
|
|
7764
|
+
return [errFilePath, null];
|
|
7765
|
+
const execArr = errCodeRegExp.exec(errMsgRaw);
|
|
7766
|
+
if (!execArr)
|
|
7767
|
+
return [errFilePath, null];
|
|
7768
|
+
const errCodeStr = ((_a = execArr.groups) == null ? void 0 : _a.errCode) ?? "";
|
|
7769
|
+
if (!errCodeStr)
|
|
7770
|
+
return [errFilePath, null];
|
|
7771
|
+
const line = Number(errLine);
|
|
7772
|
+
const col = Number(errCol);
|
|
7773
|
+
const errCode = Number(errCodeStr);
|
|
7774
|
+
return [
|
|
7775
|
+
errFilePath,
|
|
7776
|
+
{
|
|
7777
|
+
filePath: errFilePath,
|
|
7778
|
+
errCode,
|
|
7779
|
+
line,
|
|
7780
|
+
column: col,
|
|
7781
|
+
errMsg: errMsgRaw.slice(`error TS${errCode} `.length)
|
|
7829
7782
|
}
|
|
7830
|
-
|
|
7783
|
+
];
|
|
7831
7784
|
}
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7785
|
+
async function getTsconfig(root, config) {
|
|
7786
|
+
const configName = config.tsconfig ? basename(config.tsconfig) : void 0;
|
|
7787
|
+
const configSearchPath = config.tsconfig ? dirname(resolve(root, config.tsconfig)) : root;
|
|
7788
|
+
const tsconfig = Te(configSearchPath, configName);
|
|
7789
|
+
if (!tsconfig)
|
|
7790
|
+
throw new Error("no tsconfig.json found");
|
|
7791
|
+
const tempConfigPath = join(dirname(tsconfig.path), "tsconfig.vitest-temp.json");
|
|
7835
7792
|
try {
|
|
7836
|
-
|
|
7837
|
-
|
|
7838
|
-
|
|
7793
|
+
const tmpTsConfig = { ...tsconfig.config };
|
|
7794
|
+
tmpTsConfig.compilerOptions = tmpTsConfig.compilerOptions || {};
|
|
7795
|
+
tmpTsConfig.compilerOptions.emitDeclarationOnly = false;
|
|
7796
|
+
tmpTsConfig.compilerOptions.incremental = true;
|
|
7797
|
+
tmpTsConfig.compilerOptions.tsBuildInfoFile = join(
|
|
7798
|
+
__dirname,
|
|
7799
|
+
"tsconfig.tmp.tsbuildinfo"
|
|
7800
|
+
);
|
|
7801
|
+
const tsconfigFinalContent = JSON.stringify(tmpTsConfig, null, 2);
|
|
7802
|
+
await writeFile(tempConfigPath, tsconfigFinalContent);
|
|
7803
|
+
return { path: tempConfigPath, config: tmpTsConfig };
|
|
7804
|
+
} catch (err) {
|
|
7805
|
+
throw new Error("failed to write tsconfig.temp.json", { cause: err });
|
|
7839
7806
|
}
|
|
7840
|
-
if (customReporterModule.default === null || customReporterModule.default === void 0)
|
|
7841
|
-
throw new Error(`Custom reporter loaded from ${path} was not the default export`);
|
|
7842
|
-
return customReporterModule.default;
|
|
7843
|
-
}
|
|
7844
|
-
function createReporters(reporterReferences, runner) {
|
|
7845
|
-
const promisedReporters = reporterReferences.map(async (referenceOrInstance) => {
|
|
7846
|
-
if (typeof referenceOrInstance === "string") {
|
|
7847
|
-
if (referenceOrInstance === "html") {
|
|
7848
|
-
await ensurePackageInstalled("@vitest/ui", runner.root);
|
|
7849
|
-
const CustomReporter = await loadCustomReporterModule("@vitest/ui/reporter", runner);
|
|
7850
|
-
return new CustomReporter();
|
|
7851
|
-
} else if (referenceOrInstance in ReportersMap) {
|
|
7852
|
-
const BuiltinReporter = ReportersMap[referenceOrInstance];
|
|
7853
|
-
return new BuiltinReporter();
|
|
7854
|
-
} else {
|
|
7855
|
-
const CustomReporter = await loadCustomReporterModule(referenceOrInstance, runner);
|
|
7856
|
-
return new CustomReporter();
|
|
7857
|
-
}
|
|
7858
|
-
}
|
|
7859
|
-
return referenceOrInstance;
|
|
7860
|
-
});
|
|
7861
|
-
return Promise.all(promisedReporters);
|
|
7862
7807
|
}
|
|
7863
|
-
function
|
|
7864
|
-
const
|
|
7865
|
-
|
|
7866
|
-
|
|
7867
|
-
|
|
7868
|
-
return
|
|
7869
|
-
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
|
|
7808
|
+
async function getRawErrsMapFromTsCompile(tscErrorStdout) {
|
|
7809
|
+
const rawErrsMap = /* @__PURE__ */ new Map();
|
|
7810
|
+
const infos = await Promise.all(
|
|
7811
|
+
tscErrorStdout.split(newLineRegExp).reduce((prev, next) => {
|
|
7812
|
+
if (!next)
|
|
7813
|
+
return prev;
|
|
7814
|
+
else if (!next.startsWith(" "))
|
|
7815
|
+
prev.push(next);
|
|
7816
|
+
else
|
|
7817
|
+
prev[prev.length - 1] += `
|
|
7818
|
+
${next}`;
|
|
7819
|
+
return prev;
|
|
7820
|
+
}, []).map((errInfoLine) => makeTscErrorInfo(errInfoLine))
|
|
7821
|
+
);
|
|
7822
|
+
infos.forEach(([errFilePath, errInfo]) => {
|
|
7823
|
+
var _a;
|
|
7824
|
+
if (!errInfo)
|
|
7825
|
+
return;
|
|
7826
|
+
if (!rawErrsMap.has(errFilePath))
|
|
7827
|
+
rawErrsMap.set(errFilePath, [errInfo]);
|
|
7828
|
+
else
|
|
7829
|
+
(_a = rawErrsMap.get(errFilePath)) == null ? void 0 : _a.push(errInfo);
|
|
7875
7830
|
});
|
|
7876
|
-
return
|
|
7831
|
+
return rawErrsMap;
|
|
7877
7832
|
}
|
|
7878
7833
|
|
|
7879
|
-
function
|
|
7880
|
-
|
|
7881
|
-
|
|
7882
|
-
|
|
7883
|
-
|
|
7884
|
-
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
|
|
7888
|
-
|
|
7889
|
-
|
|
7890
|
-
|
|
7891
|
-
processTimeoutCauses = /* @__PURE__ */ new Set();
|
|
7892
|
-
catchError(err, type) {
|
|
7893
|
-
if (isAggregateError(err))
|
|
7894
|
-
return err.errors.forEach((error) => this.catchError(error, type));
|
|
7895
|
-
if (err === Object(err))
|
|
7896
|
-
err.type = type;
|
|
7897
|
-
else
|
|
7898
|
-
err = { type, message: err };
|
|
7899
|
-
const _err = err;
|
|
7900
|
-
if (_err && typeof _err === "object" && _err.code === "VITEST_PENDING") {
|
|
7901
|
-
const task = this.idMap.get(_err.taskId);
|
|
7902
|
-
if (task) {
|
|
7903
|
-
task.mode = "skip";
|
|
7904
|
-
task.result ?? (task.result = { state: "skip" });
|
|
7905
|
-
task.result.state = "skip";
|
|
7906
|
-
}
|
|
7907
|
-
return;
|
|
7834
|
+
function createIndexMap(source) {
|
|
7835
|
+
const map = /* @__PURE__ */ new Map();
|
|
7836
|
+
let index = 0;
|
|
7837
|
+
let line = 1;
|
|
7838
|
+
let column = 1;
|
|
7839
|
+
for (const char of source) {
|
|
7840
|
+
map.set(`${line}:${column}`, index++);
|
|
7841
|
+
if (char === "\n" || char === "\r\n") {
|
|
7842
|
+
line++;
|
|
7843
|
+
column = 0;
|
|
7844
|
+
} else {
|
|
7845
|
+
column++;
|
|
7908
7846
|
}
|
|
7909
|
-
this.errorsSet.add(err);
|
|
7910
7847
|
}
|
|
7911
|
-
|
|
7912
|
-
|
|
7913
|
-
|
|
7914
|
-
|
|
7915
|
-
|
|
7916
|
-
|
|
7917
|
-
|
|
7918
|
-
|
|
7848
|
+
return map;
|
|
7849
|
+
}
|
|
7850
|
+
|
|
7851
|
+
async function collectTests(ctx, filepath) {
|
|
7852
|
+
const request = await ctx.vitenode.transformRequest(filepath, filepath);
|
|
7853
|
+
if (!request)
|
|
7854
|
+
return null;
|
|
7855
|
+
const ast = parse$4(request.code, {
|
|
7856
|
+
ecmaVersion: "latest",
|
|
7857
|
+
allowAwaitOutsideFunction: true
|
|
7858
|
+
});
|
|
7859
|
+
const testFilepath = relative(ctx.config.root, filepath);
|
|
7860
|
+
const file = {
|
|
7861
|
+
filepath,
|
|
7862
|
+
type: "suite",
|
|
7863
|
+
id: generateHash(`${testFilepath}${ctx.config.name || ""}`),
|
|
7864
|
+
name: testFilepath,
|
|
7865
|
+
mode: "run",
|
|
7866
|
+
tasks: [],
|
|
7867
|
+
start: ast.start,
|
|
7868
|
+
end: ast.end,
|
|
7869
|
+
projectName: ctx.getName(),
|
|
7870
|
+
meta: { typecheck: true }
|
|
7871
|
+
};
|
|
7872
|
+
const definitions = [];
|
|
7873
|
+
const getName = (callee) => {
|
|
7874
|
+
var _a, _b, _c;
|
|
7875
|
+
if (!callee)
|
|
7876
|
+
return null;
|
|
7877
|
+
if (callee.type === "Identifier")
|
|
7878
|
+
return callee.name;
|
|
7879
|
+
if (callee.type === "MemberExpression") {
|
|
7880
|
+
if ((_b = (_a = callee.object) == null ? void 0 : _a.name) == null ? void 0 : _b.startsWith("__vite_ssr_"))
|
|
7881
|
+
return getName(callee.property);
|
|
7882
|
+
return getName((_c = callee.object) == null ? void 0 : _c.property);
|
|
7883
|
+
}
|
|
7884
|
+
return null;
|
|
7885
|
+
};
|
|
7886
|
+
ancestor(ast, {
|
|
7887
|
+
CallExpression(node) {
|
|
7888
|
+
var _a;
|
|
7889
|
+
const { callee } = node;
|
|
7890
|
+
const name = getName(callee);
|
|
7891
|
+
if (!name)
|
|
7892
|
+
return;
|
|
7893
|
+
if (!["it", "test", "describe", "suite"].includes(name))
|
|
7894
|
+
return;
|
|
7895
|
+
const { arguments: [{ value: message }] } = node;
|
|
7896
|
+
const property = (_a = callee == null ? void 0 : callee.property) == null ? void 0 : _a.name;
|
|
7897
|
+
let mode = !property || property === name ? "run" : property;
|
|
7898
|
+
if (!["run", "skip", "todo", "only", "skipIf", "runIf"].includes(mode))
|
|
7899
|
+
throw new Error(`${name}.${mode} syntax is not supported when testing types`);
|
|
7900
|
+
if (mode === "skipIf" || mode === "runIf")
|
|
7901
|
+
mode = "skip";
|
|
7902
|
+
definitions.push({
|
|
7903
|
+
start: node.start,
|
|
7904
|
+
end: node.end,
|
|
7905
|
+
name: message,
|
|
7906
|
+
type: name === "it" || name === "test" ? "test" : "suite",
|
|
7907
|
+
mode
|
|
7908
|
+
});
|
|
7909
|
+
}
|
|
7910
|
+
});
|
|
7911
|
+
let lastSuite = file;
|
|
7912
|
+
const updateLatestSuite = (index) => {
|
|
7913
|
+
const suite = lastSuite;
|
|
7914
|
+
while (lastSuite !== file && lastSuite.end < index)
|
|
7915
|
+
lastSuite = suite.suite;
|
|
7916
|
+
return lastSuite;
|
|
7917
|
+
};
|
|
7918
|
+
definitions.sort((a, b) => a.start - b.start).forEach((definition) => {
|
|
7919
|
+
const latestSuite = updateLatestSuite(definition.start);
|
|
7920
|
+
let mode = definition.mode;
|
|
7921
|
+
if (latestSuite.mode !== "run")
|
|
7922
|
+
mode = latestSuite.mode;
|
|
7923
|
+
if (definition.type === "suite") {
|
|
7924
|
+
const task2 = {
|
|
7925
|
+
type: definition.type,
|
|
7926
|
+
id: "",
|
|
7927
|
+
suite: latestSuite,
|
|
7928
|
+
file,
|
|
7929
|
+
tasks: [],
|
|
7930
|
+
mode,
|
|
7931
|
+
name: definition.name,
|
|
7932
|
+
end: definition.end,
|
|
7933
|
+
start: definition.start,
|
|
7934
|
+
projectName: ctx.getName(),
|
|
7935
|
+
meta: {
|
|
7936
|
+
typecheck: true
|
|
7937
|
+
}
|
|
7938
|
+
};
|
|
7939
|
+
definition.task = task2;
|
|
7940
|
+
latestSuite.tasks.push(task2);
|
|
7941
|
+
lastSuite = task2;
|
|
7942
|
+
return;
|
|
7943
|
+
}
|
|
7944
|
+
const task = {
|
|
7945
|
+
type: definition.type,
|
|
7946
|
+
id: "",
|
|
7947
|
+
suite: latestSuite,
|
|
7948
|
+
file,
|
|
7949
|
+
mode,
|
|
7950
|
+
context: {},
|
|
7951
|
+
// not used in typecheck
|
|
7952
|
+
name: definition.name,
|
|
7953
|
+
end: definition.end,
|
|
7954
|
+
start: definition.start,
|
|
7955
|
+
meta: {
|
|
7956
|
+
typecheck: true
|
|
7957
|
+
}
|
|
7958
|
+
};
|
|
7959
|
+
definition.task = task;
|
|
7960
|
+
latestSuite.tasks.push(task);
|
|
7961
|
+
});
|
|
7962
|
+
calculateSuiteHash(file);
|
|
7963
|
+
const hasOnly = someTasksAreOnly(file);
|
|
7964
|
+
interpretTaskModes(file, ctx.config.testNamePattern, hasOnly, false, ctx.config.allowOnly);
|
|
7965
|
+
return {
|
|
7966
|
+
file,
|
|
7967
|
+
parsed: request.code,
|
|
7968
|
+
filepath,
|
|
7969
|
+
map: request.map,
|
|
7970
|
+
definitions
|
|
7971
|
+
};
|
|
7972
|
+
}
|
|
7973
|
+
|
|
7974
|
+
class TypeCheckError extends Error {
|
|
7975
|
+
constructor(message, stacks) {
|
|
7976
|
+
super(message);
|
|
7977
|
+
this.message = message;
|
|
7978
|
+
this.stacks = stacks;
|
|
7919
7979
|
}
|
|
7920
|
-
|
|
7921
|
-
|
|
7980
|
+
name = "TypeCheckError";
|
|
7981
|
+
}
|
|
7982
|
+
class Typechecker {
|
|
7983
|
+
constructor(ctx) {
|
|
7984
|
+
this.ctx = ctx;
|
|
7922
7985
|
}
|
|
7923
|
-
|
|
7924
|
-
|
|
7986
|
+
_onParseStart;
|
|
7987
|
+
_onParseEnd;
|
|
7988
|
+
_onWatcherRerun;
|
|
7989
|
+
_result = {
|
|
7990
|
+
files: [],
|
|
7991
|
+
sourceErrors: [],
|
|
7992
|
+
time: 0
|
|
7993
|
+
};
|
|
7994
|
+
_startTime = 0;
|
|
7995
|
+
_output = "";
|
|
7996
|
+
_tests = {};
|
|
7997
|
+
tempConfigPath;
|
|
7998
|
+
allowJs;
|
|
7999
|
+
process;
|
|
8000
|
+
files = [];
|
|
8001
|
+
setFiles(files) {
|
|
8002
|
+
this.files = files;
|
|
7925
8003
|
}
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
return keys.map((key) => this.filesMap.get(key)).filter(Boolean).flat();
|
|
7929
|
-
return Array.from(this.filesMap.values()).flat();
|
|
8004
|
+
onParseStart(fn) {
|
|
8005
|
+
this._onParseStart = fn;
|
|
7930
8006
|
}
|
|
7931
|
-
|
|
7932
|
-
|
|
8007
|
+
onParseEnd(fn) {
|
|
8008
|
+
this._onParseEnd = fn;
|
|
7933
8009
|
}
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
var _a;
|
|
7937
|
-
return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
|
|
7938
|
-
}).map((i) => i.filepath);
|
|
8010
|
+
onWatcherRerun(fn) {
|
|
8011
|
+
this._onWatcherRerun = fn;
|
|
7939
8012
|
}
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
this.pathsSet.add(path);
|
|
7943
|
-
});
|
|
8013
|
+
async collectFileTests(filepath) {
|
|
8014
|
+
return collectTests(this.ctx, filepath);
|
|
7944
8015
|
}
|
|
7945
|
-
|
|
7946
|
-
files.
|
|
7947
|
-
const
|
|
7948
|
-
|
|
7949
|
-
otherProject.push(file);
|
|
7950
|
-
this.filesMap.set(file.filepath, otherProject);
|
|
7951
|
-
this.updateId(file);
|
|
8016
|
+
getFiles() {
|
|
8017
|
+
return this.files.filter((filename) => {
|
|
8018
|
+
const extension = extname(filename);
|
|
8019
|
+
return extension !== ".js" || this.allowJs;
|
|
7952
8020
|
});
|
|
7953
8021
|
}
|
|
7954
|
-
|
|
7955
|
-
|
|
7956
|
-
|
|
7957
|
-
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
|
|
7961
|
-
|
|
7962
|
-
|
|
7963
|
-
|
|
7964
|
-
|
|
7965
|
-
this.filesMap.set(path, filtered);
|
|
7966
|
-
});
|
|
8022
|
+
async collectTests() {
|
|
8023
|
+
const tests = (await Promise.all(
|
|
8024
|
+
this.getFiles().map((filepath) => this.collectFileTests(filepath))
|
|
8025
|
+
)).reduce((acc, data) => {
|
|
8026
|
+
if (!data)
|
|
8027
|
+
return acc;
|
|
8028
|
+
acc[data.filepath] = data;
|
|
8029
|
+
return acc;
|
|
8030
|
+
}, {});
|
|
8031
|
+
this._tests = tests;
|
|
8032
|
+
return tests;
|
|
7967
8033
|
}
|
|
7968
|
-
|
|
7969
|
-
|
|
7970
|
-
|
|
7971
|
-
|
|
7972
|
-
|
|
7973
|
-
|
|
7974
|
-
this.updateId(task2);
|
|
7975
|
-
});
|
|
8034
|
+
markPassed(file) {
|
|
8035
|
+
var _a;
|
|
8036
|
+
if (!((_a = file.result) == null ? void 0 : _a.state)) {
|
|
8037
|
+
file.result = {
|
|
8038
|
+
state: "pass"
|
|
8039
|
+
};
|
|
7976
8040
|
}
|
|
7977
|
-
|
|
7978
|
-
|
|
7979
|
-
|
|
7980
|
-
|
|
7981
|
-
|
|
7982
|
-
task.result
|
|
7983
|
-
|
|
7984
|
-
|
|
7985
|
-
|
|
8041
|
+
const markTasks = (tasks) => {
|
|
8042
|
+
var _a2;
|
|
8043
|
+
for (const task of tasks) {
|
|
8044
|
+
if ("tasks" in task)
|
|
8045
|
+
markTasks(task.tasks);
|
|
8046
|
+
if (!((_a2 = task.result) == null ? void 0 : _a2.state) && task.mode === "run") {
|
|
8047
|
+
task.result = {
|
|
8048
|
+
state: "pass"
|
|
8049
|
+
};
|
|
8050
|
+
}
|
|
7986
8051
|
}
|
|
7987
|
-
}
|
|
7988
|
-
|
|
7989
|
-
updateUserLog(log) {
|
|
7990
|
-
const task = log.taskId && this.idMap.get(log.taskId);
|
|
7991
|
-
if (task) {
|
|
7992
|
-
if (!task.logs)
|
|
7993
|
-
task.logs = [];
|
|
7994
|
-
task.logs.push(log);
|
|
7995
|
-
}
|
|
8052
|
+
};
|
|
8053
|
+
markTasks(file.tasks);
|
|
7996
8054
|
}
|
|
7997
|
-
|
|
7998
|
-
|
|
7999
|
-
|
|
8000
|
-
|
|
8001
|
-
|
|
8055
|
+
async prepareResults(output) {
|
|
8056
|
+
const typeErrors = await this.parseTscLikeOutput(output);
|
|
8057
|
+
const testFiles = new Set(this.getFiles());
|
|
8058
|
+
if (!this._tests)
|
|
8059
|
+
this._tests = await this.collectTests();
|
|
8060
|
+
const sourceErrors = [];
|
|
8061
|
+
const files = [];
|
|
8062
|
+
testFiles.forEach((path) => {
|
|
8063
|
+
const { file, definitions, map, parsed } = this._tests[path];
|
|
8064
|
+
const errors = typeErrors.get(path);
|
|
8065
|
+
files.push(file);
|
|
8066
|
+
if (!errors) {
|
|
8067
|
+
this.markPassed(file);
|
|
8068
|
+
return;
|
|
8069
|
+
}
|
|
8070
|
+
const sortedDefinitions = [...definitions.sort((a, b) => b.start - a.start)];
|
|
8071
|
+
const traceMap = map && new TraceMap(map);
|
|
8072
|
+
const indexMap = createIndexMap(parsed);
|
|
8073
|
+
const markState = (task, state) => {
|
|
8074
|
+
task.result = {
|
|
8075
|
+
state: task.mode === "run" || task.mode === "only" ? state : task.mode
|
|
8076
|
+
};
|
|
8077
|
+
if (task.suite)
|
|
8078
|
+
markState(task.suite, state);
|
|
8079
|
+
};
|
|
8080
|
+
errors.forEach(({ error, originalError }) => {
|
|
8081
|
+
var _a;
|
|
8082
|
+
const processedPos = traceMap ? generatedPositionFor(traceMap, {
|
|
8083
|
+
line: originalError.line,
|
|
8084
|
+
column: originalError.column,
|
|
8085
|
+
source: basename(path)
|
|
8086
|
+
}) : originalError;
|
|
8087
|
+
const line = processedPos.line ?? originalError.line;
|
|
8088
|
+
const column = processedPos.column ?? originalError.column;
|
|
8089
|
+
const index = indexMap.get(`${line}:${column}`);
|
|
8090
|
+
const definition = index != null && sortedDefinitions.find((def) => def.start <= index && def.end >= index);
|
|
8091
|
+
const suite = definition ? definition.task : file;
|
|
8092
|
+
const state = suite.mode === "run" || suite.mode === "only" ? "fail" : suite.mode;
|
|
8093
|
+
const errors2 = ((_a = suite.result) == null ? void 0 : _a.errors) || [];
|
|
8094
|
+
suite.result = {
|
|
8095
|
+
state,
|
|
8096
|
+
errors: errors2
|
|
8097
|
+
};
|
|
8098
|
+
errors2.push(error);
|
|
8099
|
+
if (state === "fail" && suite.suite)
|
|
8100
|
+
markState(suite.suite, "fail");
|
|
8101
|
+
});
|
|
8102
|
+
this.markPassed(file);
|
|
8103
|
+
});
|
|
8104
|
+
typeErrors.forEach((errors, path) => {
|
|
8105
|
+
if (!testFiles.has(path))
|
|
8106
|
+
sourceErrors.push(...errors.map(({ error }) => error));
|
|
8107
|
+
});
|
|
8108
|
+
return {
|
|
8109
|
+
files,
|
|
8110
|
+
sourceErrors,
|
|
8111
|
+
time: performance.now() - this._startTime
|
|
8112
|
+
};
|
|
8002
8113
|
}
|
|
8003
|
-
|
|
8004
|
-
|
|
8005
|
-
|
|
8006
|
-
|
|
8007
|
-
|
|
8008
|
-
|
|
8009
|
-
|
|
8010
|
-
|
|
8011
|
-
|
|
8012
|
-
|
|
8013
|
-
|
|
8014
|
-
|
|
8015
|
-
|
|
8016
|
-
|
|
8114
|
+
async parseTscLikeOutput(output) {
|
|
8115
|
+
const errorsMap = await getRawErrsMapFromTsCompile(output);
|
|
8116
|
+
const typesErrors = /* @__PURE__ */ new Map();
|
|
8117
|
+
errorsMap.forEach((errors, path) => {
|
|
8118
|
+
const filepath = resolve(this.ctx.config.root, path);
|
|
8119
|
+
const suiteErrors = errors.map((info) => {
|
|
8120
|
+
const limit = Error.stackTraceLimit;
|
|
8121
|
+
Error.stackTraceLimit = 0;
|
|
8122
|
+
const error = new TypeCheckError(info.errMsg, [
|
|
8123
|
+
{
|
|
8124
|
+
file: filepath,
|
|
8125
|
+
line: info.line,
|
|
8126
|
+
column: info.column,
|
|
8127
|
+
method: ""
|
|
8128
|
+
}
|
|
8129
|
+
]);
|
|
8130
|
+
Error.stackTraceLimit = limit;
|
|
8131
|
+
return {
|
|
8132
|
+
originalError: info,
|
|
8133
|
+
error: {
|
|
8134
|
+
name: error.name,
|
|
8135
|
+
nameStr: String(error.name),
|
|
8136
|
+
message: info.errMsg,
|
|
8137
|
+
stacks: error.stacks,
|
|
8138
|
+
stack: "",
|
|
8139
|
+
stackStr: ""
|
|
8140
|
+
}
|
|
8141
|
+
};
|
|
8142
|
+
});
|
|
8143
|
+
typesErrors.set(filepath, suiteErrors);
|
|
8144
|
+
});
|
|
8145
|
+
return typesErrors;
|
|
8017
8146
|
}
|
|
8018
|
-
|
|
8019
|
-
|
|
8020
|
-
|
|
8021
|
-
const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**", "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*"];
|
|
8022
|
-
const benchmarkConfigDefaults = {
|
|
8023
|
-
include: ["**/*.{bench,benchmark}.?(c|m)[jt]s?(x)"],
|
|
8024
|
-
exclude: defaultExclude,
|
|
8025
|
-
includeSource: [],
|
|
8026
|
-
reporters: ["default"]
|
|
8027
|
-
};
|
|
8028
|
-
const defaultCoverageExcludes = [
|
|
8029
|
-
"coverage/**",
|
|
8030
|
-
"dist/**",
|
|
8031
|
-
"packages/*/test?(s)/**",
|
|
8032
|
-
"**/*.d.ts",
|
|
8033
|
-
"**/virtual:*",
|
|
8034
|
-
"**/__x00__*",
|
|
8035
|
-
"**/\0*",
|
|
8036
|
-
"cypress/**",
|
|
8037
|
-
"test?(s)/**",
|
|
8038
|
-
"test?(-*).?(c|m)[jt]s?(x)",
|
|
8039
|
-
"**/*{.,-}{test,spec}.?(c|m)[jt]s?(x)",
|
|
8040
|
-
"**/__tests__/**",
|
|
8041
|
-
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*",
|
|
8042
|
-
"**/vitest.{workspace,projects}.[jt]s?(on)",
|
|
8043
|
-
"**/.{eslint,mocha,prettier}rc.{?(c|m)js,yml}"
|
|
8044
|
-
];
|
|
8045
|
-
const coverageConfigDefaults = {
|
|
8046
|
-
provider: "v8",
|
|
8047
|
-
enabled: false,
|
|
8048
|
-
clean: true,
|
|
8049
|
-
cleanOnRerun: true,
|
|
8050
|
-
reportsDirectory: "./coverage",
|
|
8051
|
-
exclude: defaultCoverageExcludes,
|
|
8052
|
-
reportOnFailure: false,
|
|
8053
|
-
reporter: [["text", {}], ["html", {}], ["clover", {}], ["json", {}]],
|
|
8054
|
-
extension: [".js", ".cjs", ".mjs", ".ts", ".mts", ".cts", ".tsx", ".jsx", ".vue", ".svelte"],
|
|
8055
|
-
allowExternal: false
|
|
8056
|
-
};
|
|
8057
|
-
const fakeTimersDefaults = {
|
|
8058
|
-
loopLimit: 1e4,
|
|
8059
|
-
shouldClearNativeTimers: true,
|
|
8060
|
-
toFake: [
|
|
8061
|
-
"setTimeout",
|
|
8062
|
-
"clearTimeout",
|
|
8063
|
-
"setInterval",
|
|
8064
|
-
"clearInterval",
|
|
8065
|
-
"setImmediate",
|
|
8066
|
-
"clearImmediate",
|
|
8067
|
-
"Date"
|
|
8068
|
-
]
|
|
8069
|
-
};
|
|
8070
|
-
const config = {
|
|
8071
|
-
allowOnly: !isCI,
|
|
8072
|
-
watch: !isCI,
|
|
8073
|
-
globals: false,
|
|
8074
|
-
environment: "node",
|
|
8075
|
-
pool: "threads",
|
|
8076
|
-
clearMocks: false,
|
|
8077
|
-
restoreMocks: false,
|
|
8078
|
-
mockReset: false,
|
|
8079
|
-
include: defaultInclude,
|
|
8080
|
-
exclude: defaultExclude,
|
|
8081
|
-
testTimeout: 5e3,
|
|
8082
|
-
hookTimeout: 1e4,
|
|
8083
|
-
teardownTimeout: 1e4,
|
|
8084
|
-
watchExclude: ["**/node_modules/**", "**/dist/**"],
|
|
8085
|
-
forceRerunTriggers: [
|
|
8086
|
-
"**/package.json/**",
|
|
8087
|
-
"**/{vitest,vite}.config.*/**"
|
|
8088
|
-
],
|
|
8089
|
-
update: false,
|
|
8090
|
-
reporters: [],
|
|
8091
|
-
silent: false,
|
|
8092
|
-
hideSkippedTests: false,
|
|
8093
|
-
api: false,
|
|
8094
|
-
ui: false,
|
|
8095
|
-
uiBase: "/__vitest__/",
|
|
8096
|
-
open: true,
|
|
8097
|
-
css: {
|
|
8098
|
-
include: []
|
|
8099
|
-
},
|
|
8100
|
-
coverage: coverageConfigDefaults,
|
|
8101
|
-
fakeTimers: fakeTimersDefaults,
|
|
8102
|
-
maxConcurrency: 5,
|
|
8103
|
-
dangerouslyIgnoreUnhandledErrors: false,
|
|
8104
|
-
typecheck: {
|
|
8105
|
-
checker: "tsc",
|
|
8106
|
-
include: ["**/*.{test,spec}-d.?(c|m)[jt]s?(x)"],
|
|
8107
|
-
exclude: defaultExclude
|
|
8108
|
-
},
|
|
8109
|
-
slowTestThreshold: 300
|
|
8110
|
-
};
|
|
8111
|
-
const configDefaults = Object.freeze(config);
|
|
8112
|
-
|
|
8113
|
-
class FilesStatsCache {
|
|
8114
|
-
cache = /* @__PURE__ */ new Map();
|
|
8115
|
-
getStats(key) {
|
|
8116
|
-
return this.cache.get(key);
|
|
8147
|
+
async clear() {
|
|
8148
|
+
if (this.tempConfigPath)
|
|
8149
|
+
await rm(this.tempConfigPath, { force: true });
|
|
8117
8150
|
}
|
|
8118
|
-
async
|
|
8119
|
-
|
|
8120
|
-
|
|
8121
|
-
|
|
8122
|
-
});
|
|
8123
|
-
await Promise.all(promises);
|
|
8151
|
+
async stop() {
|
|
8152
|
+
var _a;
|
|
8153
|
+
await this.clear();
|
|
8154
|
+
(_a = this.process) == null ? void 0 : _a.kill();
|
|
8124
8155
|
}
|
|
8125
|
-
async
|
|
8126
|
-
if (
|
|
8156
|
+
async ensurePackageInstalled(root, checker) {
|
|
8157
|
+
if (checker !== "tsc" && checker !== "vue-tsc")
|
|
8127
8158
|
return;
|
|
8128
|
-
const
|
|
8129
|
-
|
|
8130
|
-
}
|
|
8131
|
-
removeStats(fsPath) {
|
|
8132
|
-
this.cache.forEach((_, key) => {
|
|
8133
|
-
if (key.endsWith(fsPath))
|
|
8134
|
-
this.cache.delete(key);
|
|
8135
|
-
});
|
|
8159
|
+
const packageName = checker === "tsc" ? "typescript" : "vue-tsc";
|
|
8160
|
+
await ensurePackageInstalled(packageName, root);
|
|
8136
8161
|
}
|
|
8137
|
-
|
|
8138
|
-
|
|
8139
|
-
|
|
8140
|
-
|
|
8141
|
-
|
|
8142
|
-
|
|
8143
|
-
version = version$1;
|
|
8144
|
-
root = "/";
|
|
8145
|
-
getCachePath() {
|
|
8146
|
-
return this.cachePath;
|
|
8162
|
+
async prepare() {
|
|
8163
|
+
const { root, typecheck } = this.ctx.config;
|
|
8164
|
+
await this.ensurePackageInstalled(root, typecheck.checker);
|
|
8165
|
+
const { config, path } = await getTsconfig(root, typecheck);
|
|
8166
|
+
this.tempConfigPath = path;
|
|
8167
|
+
this.allowJs = typecheck.allowJs || config.allowJs || false;
|
|
8147
8168
|
}
|
|
8148
|
-
|
|
8149
|
-
|
|
8150
|
-
|
|
8151
|
-
this.cachePath = resolve(config.dir, "results.json");
|
|
8169
|
+
getExitCode() {
|
|
8170
|
+
var _a;
|
|
8171
|
+
return ((_a = this.process) == null ? void 0 : _a.exitCode) != null && this.process.exitCode;
|
|
8152
8172
|
}
|
|
8153
|
-
|
|
8154
|
-
return this.
|
|
8173
|
+
getOutput() {
|
|
8174
|
+
return this._output;
|
|
8155
8175
|
}
|
|
8156
|
-
async
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
const
|
|
8162
|
-
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
|
|
8171
|
-
|
|
8172
|
-
}
|
|
8173
|
-
}
|
|
8174
|
-
updateResults(files) {
|
|
8175
|
-
files.forEach((file) => {
|
|
8176
|
-
const result = file.result;
|
|
8177
|
-
if (!result)
|
|
8178
|
-
return;
|
|
8179
|
-
const duration = result.duration || 0;
|
|
8180
|
-
const relativePath = relative(this.root, file.filepath);
|
|
8181
|
-
this.cache.set(`${file.projectName || ""}:${relativePath}`, {
|
|
8182
|
-
duration: duration >= 0 ? duration : 0,
|
|
8183
|
-
failed: result.state === "fail"
|
|
8184
|
-
});
|
|
8185
|
-
});
|
|
8186
|
-
}
|
|
8187
|
-
removeFromCache(filepath) {
|
|
8188
|
-
this.cache.forEach((_, key) => {
|
|
8189
|
-
if (key.endsWith(filepath))
|
|
8190
|
-
this.cache.delete(key);
|
|
8176
|
+
async start() {
|
|
8177
|
+
var _a, _b, _c;
|
|
8178
|
+
if (!this.tempConfigPath)
|
|
8179
|
+
throw new Error("tsconfig was not initialized");
|
|
8180
|
+
const { root, watch, typecheck } = this.ctx.config;
|
|
8181
|
+
const args = ["--noEmit", "--pretty", "false", "-p", this.tempConfigPath];
|
|
8182
|
+
if (watch)
|
|
8183
|
+
args.push("--watch");
|
|
8184
|
+
if (typecheck.allowJs)
|
|
8185
|
+
args.push("--allowJs", "--checkJs");
|
|
8186
|
+
this._output = "";
|
|
8187
|
+
this._startTime = performance.now();
|
|
8188
|
+
const child = execa(typecheck.checker, args, {
|
|
8189
|
+
cwd: root,
|
|
8190
|
+
stdout: "pipe",
|
|
8191
|
+
reject: false
|
|
8191
8192
|
});
|
|
8192
|
-
|
|
8193
|
-
|
|
8194
|
-
|
|
8195
|
-
|
|
8196
|
-
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
|
|
8200
|
-
|
|
8201
|
-
|
|
8202
|
-
|
|
8193
|
+
this.process = child;
|
|
8194
|
+
await ((_a = this._onParseStart) == null ? void 0 : _a.call(this));
|
|
8195
|
+
let rerunTriggered = false;
|
|
8196
|
+
(_b = child.stdout) == null ? void 0 : _b.on("data", (chunk) => {
|
|
8197
|
+
var _a2;
|
|
8198
|
+
this._output += chunk;
|
|
8199
|
+
if (!watch)
|
|
8200
|
+
return;
|
|
8201
|
+
if (this._output.includes("File change detected") && !rerunTriggered) {
|
|
8202
|
+
(_a2 = this._onWatcherRerun) == null ? void 0 : _a2.call(this);
|
|
8203
|
+
this._startTime = performance.now();
|
|
8204
|
+
this._result.sourceErrors = [];
|
|
8205
|
+
this._result.files = [];
|
|
8206
|
+
this._tests = null;
|
|
8207
|
+
rerunTriggered = true;
|
|
8208
|
+
}
|
|
8209
|
+
if (/Found \w+ errors*. Watching for/.test(this._output)) {
|
|
8210
|
+
rerunTriggered = false;
|
|
8211
|
+
this.prepareResults(this._output).then((result) => {
|
|
8212
|
+
var _a3;
|
|
8213
|
+
this._result = result;
|
|
8214
|
+
(_a3 = this._onParseEnd) == null ? void 0 : _a3.call(this, result);
|
|
8215
|
+
});
|
|
8216
|
+
this._output = "";
|
|
8217
|
+
}
|
|
8203
8218
|
});
|
|
8204
|
-
|
|
8205
|
-
|
|
8206
|
-
|
|
8207
|
-
|
|
8208
|
-
|
|
8209
|
-
results = new ResultsCache();
|
|
8210
|
-
stats = new FilesStatsCache();
|
|
8211
|
-
getFileTestResults(key) {
|
|
8212
|
-
return this.results.getResults(key);
|
|
8219
|
+
if (!watch) {
|
|
8220
|
+
await child;
|
|
8221
|
+
this._result = await this.prepareResults(this._output);
|
|
8222
|
+
await ((_c = this._onParseEnd) == null ? void 0 : _c.call(this, this._result));
|
|
8223
|
+
}
|
|
8213
8224
|
}
|
|
8214
|
-
|
|
8215
|
-
return this.
|
|
8225
|
+
getResult() {
|
|
8226
|
+
return this._result;
|
|
8216
8227
|
}
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
return projectName ? resolve(root, baseDir, crypto.createHash("md5").update(projectName, "utf-8").digest("hex")) : resolve(root, baseDir);
|
|
8228
|
+
getTestFiles() {
|
|
8229
|
+
return Object.values(this._tests || {}).map((i) => i.file);
|
|
8220
8230
|
}
|
|
8221
|
-
|
|
8222
|
-
|
|
8223
|
-
const root = resolve(options.root || process.cwd());
|
|
8224
|
-
const configPath = options.config === false ? false : options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
|
|
8225
|
-
const config = configPath ? (_a = await loadConfigFromFile({ command: "serve", mode: "test" }, configPath)) == null ? void 0 : _a.config : void 0;
|
|
8226
|
-
const cache = (_b = config == null ? void 0 : config.test) == null ? void 0 : _b.cache;
|
|
8227
|
-
const projectName = (_c = config == null ? void 0 : config.test) == null ? void 0 : _c.name;
|
|
8228
|
-
if (cache === false)
|
|
8229
|
-
throw new Error("Cache is disabled");
|
|
8230
|
-
const cachePath = VitestCache.resolveCacheDir(root, cache == null ? void 0 : cache.dir, projectName);
|
|
8231
|
-
let cleared = false;
|
|
8232
|
-
if (fs$8.existsSync(cachePath)) {
|
|
8233
|
-
fs$8.rmSync(cachePath, { recursive: true, force: true });
|
|
8234
|
-
cleared = true;
|
|
8235
|
-
}
|
|
8236
|
-
return { dir: cachePath, cleared };
|
|
8231
|
+
getTestPacks() {
|
|
8232
|
+
return Object.values(this._tests || {}).map(({ file }) => getTasks(file)).flat().map((i) => [i.id, i.result, { typecheck: true }]);
|
|
8237
8233
|
}
|
|
8238
8234
|
}
|
|
8239
8235
|
|
|
8240
|
-
|
|
8241
|
-
|
|
8242
|
-
|
|
8243
|
-
|
|
8244
|
-
|
|
8245
|
-
|
|
8246
|
-
|
|
8247
|
-
|
|
8248
|
-
|
|
8249
|
-
const
|
|
8250
|
-
|
|
8251
|
-
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
|
|
8258
|
-
|
|
8259
|
-
|
|
8260
|
-
|
|
8261
|
-
|
|
8262
|
-
|
|
8263
|
-
|
|
8264
|
-
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
|
|
8273
|
-
|
|
8274
|
-
|
|
8236
|
+
function createTypecheckPool(ctx) {
|
|
8237
|
+
const promisesMap = /* @__PURE__ */ new WeakMap();
|
|
8238
|
+
const rerunTriggered = /* @__PURE__ */ new WeakMap();
|
|
8239
|
+
async function onParseEnd(project, { files, sourceErrors }) {
|
|
8240
|
+
var _a;
|
|
8241
|
+
const checker = project.typechecker;
|
|
8242
|
+
await ctx.report("onTaskUpdate", checker.getTestPacks());
|
|
8243
|
+
if (!project.config.typecheck.ignoreSourceErrors)
|
|
8244
|
+
sourceErrors.forEach((error) => ctx.state.catchError(error, "Unhandled Source Error"));
|
|
8245
|
+
const processError = !hasFailed(files) && checker.getExitCode();
|
|
8246
|
+
if (processError) {
|
|
8247
|
+
const error = new Error(checker.getOutput());
|
|
8248
|
+
error.stack = "";
|
|
8249
|
+
ctx.state.catchError(error, "Typecheck Error");
|
|
8250
|
+
}
|
|
8251
|
+
(_a = promisesMap.get(project)) == null ? void 0 : _a.resolve();
|
|
8252
|
+
rerunTriggered.set(project, false);
|
|
8253
|
+
if (ctx.config.watch && !ctx.runningPromise) {
|
|
8254
|
+
await ctx.report("onFinished", files);
|
|
8255
|
+
await ctx.report("onWatcherStart", files, [
|
|
8256
|
+
...project.config.typecheck.ignoreSourceErrors ? [] : sourceErrors,
|
|
8257
|
+
...ctx.state.getUnhandledErrors()
|
|
8258
|
+
]);
|
|
8259
|
+
}
|
|
8260
|
+
}
|
|
8261
|
+
async function createWorkspaceTypechecker(project, files) {
|
|
8262
|
+
const checker = project.typechecker ?? new Typechecker(project);
|
|
8263
|
+
if (project.typechecker)
|
|
8264
|
+
return checker;
|
|
8265
|
+
project.typechecker = checker;
|
|
8266
|
+
checker.setFiles(files);
|
|
8267
|
+
checker.onParseStart(async () => {
|
|
8268
|
+
ctx.state.collectFiles(checker.getTestFiles());
|
|
8269
|
+
await ctx.report("onCollected");
|
|
8270
|
+
});
|
|
8271
|
+
checker.onParseEnd((result) => onParseEnd(project, result));
|
|
8272
|
+
checker.onWatcherRerun(async () => {
|
|
8273
|
+
rerunTriggered.set(project, true);
|
|
8274
|
+
if (!ctx.runningPromise) {
|
|
8275
|
+
ctx.state.clearErrors();
|
|
8276
|
+
await ctx.report("onWatcherRerun", files, "File change detected. Triggering rerun.");
|
|
8275
8277
|
}
|
|
8276
|
-
|
|
8277
|
-
|
|
8278
|
-
|
|
8279
|
-
|
|
8280
|
-
return bState.duration - aState.duration;
|
|
8278
|
+
await checker.collectTests();
|
|
8279
|
+
ctx.state.collectFiles(checker.getTestFiles());
|
|
8280
|
+
await ctx.report("onTaskUpdate", checker.getTestPacks());
|
|
8281
|
+
await ctx.report("onCollected");
|
|
8281
8282
|
});
|
|
8283
|
+
await checker.prepare();
|
|
8284
|
+
await checker.collectTests();
|
|
8285
|
+
checker.start();
|
|
8286
|
+
return checker;
|
|
8287
|
+
}
|
|
8288
|
+
async function runTests(specs) {
|
|
8289
|
+
const specsByProject = groupBy(specs, ([project]) => project.getName());
|
|
8290
|
+
const promises = [];
|
|
8291
|
+
for (const name in specsByProject) {
|
|
8292
|
+
const project = specsByProject[name][0][0];
|
|
8293
|
+
const files = specsByProject[name].map(([_, file]) => file);
|
|
8294
|
+
const promise = createDefer();
|
|
8295
|
+
const _p = new Promise((resolve) => {
|
|
8296
|
+
const _i = setInterval(() => {
|
|
8297
|
+
if (!project.typechecker || rerunTriggered.get(project)) {
|
|
8298
|
+
resolve(true);
|
|
8299
|
+
clearInterval(_i);
|
|
8300
|
+
}
|
|
8301
|
+
});
|
|
8302
|
+
setTimeout(() => {
|
|
8303
|
+
resolve(false);
|
|
8304
|
+
clearInterval(_i);
|
|
8305
|
+
}, 500);
|
|
8306
|
+
});
|
|
8307
|
+
const triggered = await _p;
|
|
8308
|
+
if (project.typechecker && !triggered) {
|
|
8309
|
+
ctx.state.collectFiles(project.typechecker.getTestFiles());
|
|
8310
|
+
await ctx.report("onCollected");
|
|
8311
|
+
await onParseEnd(project, project.typechecker.getResult());
|
|
8312
|
+
continue;
|
|
8313
|
+
}
|
|
8314
|
+
promises.push(promise);
|
|
8315
|
+
promisesMap.set(project, promise);
|
|
8316
|
+
createWorkspaceTypechecker(project, files);
|
|
8317
|
+
}
|
|
8318
|
+
await Promise.all(promises);
|
|
8282
8319
|
}
|
|
8320
|
+
return {
|
|
8321
|
+
runTests,
|
|
8322
|
+
async close() {
|
|
8323
|
+
const promises = ctx.projects.map((project) => {
|
|
8324
|
+
var _a;
|
|
8325
|
+
return (_a = project.typechecker) == null ? void 0 : _a.stop();
|
|
8326
|
+
});
|
|
8327
|
+
await Promise.all(promises);
|
|
8328
|
+
}
|
|
8329
|
+
};
|
|
8283
8330
|
}
|
|
8284
8331
|
|
|
8285
|
-
|
|
8286
|
-
|
|
8287
|
-
|
|
8288
|
-
|
|
8289
|
-
|
|
8290
|
-
|
|
8291
|
-
|
|
8292
|
-
|
|
8293
|
-
|
|
8294
|
-
|
|
8295
|
-
|
|
8296
|
-
|
|
8297
|
-
|
|
8298
|
-
|
|
8299
|
-
|
|
8300
|
-
|
|
8301
|
-
let api;
|
|
8302
|
-
if (options.ui && !options.api)
|
|
8303
|
-
api = { port: defaultPort };
|
|
8304
|
-
else if (options.api === true)
|
|
8305
|
-
api = { port: defaultPort };
|
|
8306
|
-
else if (typeof options.api === "number")
|
|
8307
|
-
api = { port: options.api };
|
|
8308
|
-
if (typeof options.api === "object") {
|
|
8309
|
-
if (api) {
|
|
8310
|
-
if (options.api.port)
|
|
8311
|
-
api.port = options.api.port;
|
|
8312
|
-
if (options.api.strictPort)
|
|
8313
|
-
api.strictPort = options.api.strictPort;
|
|
8314
|
-
if (options.api.host)
|
|
8315
|
-
api.host = options.api.host;
|
|
8316
|
-
} else {
|
|
8317
|
-
api = { ...options.api };
|
|
8332
|
+
function createPool(ctx) {
|
|
8333
|
+
const pools = {
|
|
8334
|
+
forks: null,
|
|
8335
|
+
threads: null,
|
|
8336
|
+
browser: null,
|
|
8337
|
+
vmThreads: null,
|
|
8338
|
+
typescript: null
|
|
8339
|
+
};
|
|
8340
|
+
function getDefaultPoolName(project, file) {
|
|
8341
|
+
if (project.config.browser.enabled)
|
|
8342
|
+
return "browser";
|
|
8343
|
+
if (project.config.typecheck.enabled) {
|
|
8344
|
+
for (const glob of project.config.typecheck.include) {
|
|
8345
|
+
if (mm.isMatch(file, glob, { cwd: project.config.root }))
|
|
8346
|
+
return "typescript";
|
|
8347
|
+
}
|
|
8318
8348
|
}
|
|
8349
|
+
return project.config.pool;
|
|
8319
8350
|
}
|
|
8320
|
-
|
|
8321
|
-
|
|
8322
|
-
|
|
8323
|
-
|
|
8324
|
-
|
|
8325
|
-
|
|
8326
|
-
return api;
|
|
8327
|
-
}
|
|
8328
|
-
function resolveConfig(mode, options, viteConfig) {
|
|
8329
|
-
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;
|
|
8330
|
-
if (options.dom) {
|
|
8331
|
-
if (((_a = viteConfig.test) == null ? void 0 : _a.environment) != null && viteConfig.test.environment !== "happy-dom") {
|
|
8332
|
-
console.warn(
|
|
8333
|
-
c.yellow(
|
|
8334
|
-
`${c.inverse(c.yellow(" Vitest "))} Your config.test.environment ("${viteConfig.test.environment}") conflicts with --dom flag ("happy-dom"), ignoring "${viteConfig.test.environment}"`
|
|
8335
|
-
)
|
|
8336
|
-
);
|
|
8351
|
+
function getPoolName([project, file]) {
|
|
8352
|
+
for (const [glob, pool] of project.config.poolMatchGlobs || []) {
|
|
8353
|
+
if (pool === "browser")
|
|
8354
|
+
throw new Error('Since Vitest 0.31.0 "browser" pool is not supported in "poolMatchGlobs". You can create a workspace to run some of your tests in browser in parallel. Read more: https://vitest.dev/guide/workspace');
|
|
8355
|
+
if (mm.isMatch(file, glob, { cwd: project.config.root }))
|
|
8356
|
+
return pool;
|
|
8337
8357
|
}
|
|
8338
|
-
|
|
8358
|
+
return getDefaultPoolName(project, file);
|
|
8339
8359
|
}
|
|
8340
|
-
|
|
8341
|
-
|
|
8342
|
-
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
|
|
8349
|
-
|
|
8350
|
-
|
|
8351
|
-
|
|
8352
|
-
|
|
8353
|
-
|
|
8354
|
-
|
|
8355
|
-
|
|
8356
|
-
|
|
8357
|
-
|
|
8358
|
-
|
|
8359
|
-
|
|
8360
|
-
|
|
8360
|
+
async function runTests(files, invalidate) {
|
|
8361
|
+
var _a;
|
|
8362
|
+
const conditions = ((_a = ctx.server.config.resolve.conditions) == null ? void 0 : _a.flatMap((c) => ["--conditions", c])) || [];
|
|
8363
|
+
const execArgv = process.execArgv.filter(
|
|
8364
|
+
(execArg) => execArg.startsWith("--cpu-prof") || execArg.startsWith("--heap-prof")
|
|
8365
|
+
);
|
|
8366
|
+
const options = {
|
|
8367
|
+
...ctx.projectFiles,
|
|
8368
|
+
execArgv: [
|
|
8369
|
+
...execArgv,
|
|
8370
|
+
...conditions
|
|
8371
|
+
],
|
|
8372
|
+
env: {
|
|
8373
|
+
TEST: "true",
|
|
8374
|
+
VITEST: "true",
|
|
8375
|
+
NODE_ENV: ctx.config.mode || "test",
|
|
8376
|
+
VITEST_MODE: ctx.config.watch ? "WATCH" : "RUN",
|
|
8377
|
+
...process.env,
|
|
8378
|
+
...ctx.config.env
|
|
8379
|
+
}
|
|
8380
|
+
};
|
|
8381
|
+
const filesByPool = {
|
|
8382
|
+
forks: [],
|
|
8383
|
+
threads: [],
|
|
8384
|
+
browser: [],
|
|
8385
|
+
vmThreads: [],
|
|
8386
|
+
typescript: []
|
|
8387
|
+
};
|
|
8388
|
+
for (const spec of files) {
|
|
8389
|
+
const pool = getPoolName(spec);
|
|
8390
|
+
if (!(pool in filesByPool))
|
|
8391
|
+
throw new Error(`Unknown pool name "${pool}" for ${spec[1]}. Available pools: ${Object.keys(filesByPool).join(", ")}`);
|
|
8392
|
+
filesByPool[pool].push(spec);
|
|
8393
|
+
}
|
|
8394
|
+
await Promise.all(Object.entries(filesByPool).map((entry) => {
|
|
8395
|
+
const [pool, files2] = entry;
|
|
8396
|
+
if (!files2.length)
|
|
8397
|
+
return null;
|
|
8398
|
+
if (pool === "browser") {
|
|
8399
|
+
pools.browser ?? (pools.browser = createBrowserPool(ctx));
|
|
8400
|
+
return pools.browser.runTests(files2, invalidate);
|
|
8401
|
+
}
|
|
8402
|
+
if (pool === "vmThreads") {
|
|
8403
|
+
pools.vmThreads ?? (pools.vmThreads = createVmThreadsPool(ctx, options));
|
|
8404
|
+
return pools.vmThreads.runTests(files2, invalidate);
|
|
8405
|
+
}
|
|
8406
|
+
if (pool === "threads") {
|
|
8407
|
+
pools.threads ?? (pools.threads = createThreadsPool(ctx, options));
|
|
8408
|
+
return pools.threads.runTests(files2, invalidate);
|
|
8409
|
+
}
|
|
8410
|
+
if (pool === "typescript") {
|
|
8411
|
+
pools.typescript ?? (pools.typescript = createTypecheckPool(ctx));
|
|
8412
|
+
return pools.typescript.runTests(files2);
|
|
8413
|
+
}
|
|
8414
|
+
pools.forks ?? (pools.forks = createChildProcessPool(ctx, options));
|
|
8415
|
+
return pools.forks.runTests(files2, invalidate);
|
|
8416
|
+
}));
|
|
8361
8417
|
}
|
|
8362
|
-
|
|
8363
|
-
|
|
8364
|
-
|
|
8365
|
-
|
|
8366
|
-
const inspectOption = `--inspect${resolved.inspectBrk ? "-brk" : ""}`;
|
|
8367
|
-
throw new Error(`You cannot use ${inspectOption} without "poolOptions.threads.singleThread" or "poolOptions.forks.singleFork"`);
|
|
8418
|
+
return {
|
|
8419
|
+
runTests,
|
|
8420
|
+
async close() {
|
|
8421
|
+
await Promise.all(Object.values(pools).map((p) => p == null ? void 0 : p.close()));
|
|
8368
8422
|
}
|
|
8423
|
+
};
|
|
8424
|
+
}
|
|
8425
|
+
|
|
8426
|
+
async function loadCustomReporterModule(path, runner) {
|
|
8427
|
+
let customReporterModule;
|
|
8428
|
+
try {
|
|
8429
|
+
customReporterModule = await runner.executeId(path);
|
|
8430
|
+
} catch (customReporterModuleError) {
|
|
8431
|
+
throw new Error(`Failed to load custom Reporter from ${path}`, { cause: customReporterModuleError });
|
|
8369
8432
|
}
|
|
8370
|
-
if (
|
|
8371
|
-
throw new Error(
|
|
8372
|
-
|
|
8373
|
-
|
|
8374
|
-
|
|
8375
|
-
|
|
8376
|
-
|
|
8377
|
-
|
|
8378
|
-
|
|
8379
|
-
|
|
8380
|
-
|
|
8381
|
-
|
|
8433
|
+
if (customReporterModule.default === null || customReporterModule.default === void 0)
|
|
8434
|
+
throw new Error(`Custom reporter loaded from ${path} was not the default export`);
|
|
8435
|
+
return customReporterModule.default;
|
|
8436
|
+
}
|
|
8437
|
+
function createReporters(reporterReferences, runner) {
|
|
8438
|
+
const promisedReporters = reporterReferences.map(async (referenceOrInstance) => {
|
|
8439
|
+
if (typeof referenceOrInstance === "string") {
|
|
8440
|
+
if (referenceOrInstance === "html") {
|
|
8441
|
+
await ensurePackageInstalled("@vitest/ui", runner.root);
|
|
8442
|
+
const CustomReporter = await loadCustomReporterModule("@vitest/ui/reporter", runner);
|
|
8443
|
+
return new CustomReporter();
|
|
8444
|
+
} else if (referenceOrInstance in ReportersMap) {
|
|
8445
|
+
const BuiltinReporter = ReportersMap[referenceOrInstance];
|
|
8446
|
+
return new BuiltinReporter();
|
|
8447
|
+
} else {
|
|
8448
|
+
const CustomReporter = await loadCustomReporterModule(referenceOrInstance, runner);
|
|
8449
|
+
return new CustomReporter();
|
|
8450
|
+
}
|
|
8451
|
+
}
|
|
8452
|
+
return referenceOrInstance;
|
|
8382
8453
|
});
|
|
8383
|
-
|
|
8384
|
-
|
|
8385
|
-
|
|
8386
|
-
|
|
8387
|
-
|
|
8388
|
-
|
|
8389
|
-
|
|
8390
|
-
|
|
8391
|
-
|
|
8392
|
-
|
|
8393
|
-
|
|
8394
|
-
|
|
8395
|
-
(_p = resolved.server).deps ?? (_p.deps = {});
|
|
8396
|
-
const deprecatedDepsOptions = ["inline", "external", "fallbackCJS"];
|
|
8397
|
-
deprecatedDepsOptions.forEach((option) => {
|
|
8398
|
-
if (resolved.deps[option] === void 0)
|
|
8399
|
-
return;
|
|
8400
|
-
if (option === "fallbackCJS") {
|
|
8401
|
-
console.warn(c.yellow(`${c.inverse(c.yellow(" Vitest "))} "deps.${option}" is deprecated. Use "server.deps.${option}" instead`));
|
|
8402
|
-
} else {
|
|
8403
|
-
const transformMode = resolved.environment === "happy-dom" || resolved.environment === "jsdom" ? "web" : "ssr";
|
|
8404
|
-
console.warn(
|
|
8405
|
-
c.yellow(
|
|
8406
|
-
`${c.inverse(c.yellow(" Vitest "))} "deps.${option}" is deprecated. If you rely on vite-node directly, use "server.deps.${option}" instead. Otherwise, consider using "deps.optimizer.${transformMode}.${option === "external" ? "exclude" : "include"}"`
|
|
8407
|
-
)
|
|
8408
|
-
);
|
|
8454
|
+
return Promise.all(promisedReporters);
|
|
8455
|
+
}
|
|
8456
|
+
function createBenchmarkReporters(reporterReferences, runner) {
|
|
8457
|
+
const promisedReporters = reporterReferences.map(async (referenceOrInstance) => {
|
|
8458
|
+
if (typeof referenceOrInstance === "string") {
|
|
8459
|
+
if (referenceOrInstance in BenchmarkReportsMap) {
|
|
8460
|
+
const BuiltinReporter = BenchmarkReportsMap[referenceOrInstance];
|
|
8461
|
+
return new BuiltinReporter();
|
|
8462
|
+
} else {
|
|
8463
|
+
const CustomReporter = await loadCustomReporterModule(referenceOrInstance, runner);
|
|
8464
|
+
return new CustomReporter();
|
|
8465
|
+
}
|
|
8409
8466
|
}
|
|
8410
|
-
|
|
8411
|
-
resolved.server.deps[option] = resolved.deps[option];
|
|
8467
|
+
return referenceOrInstance;
|
|
8412
8468
|
});
|
|
8413
|
-
|
|
8414
|
-
|
|
8415
|
-
|
|
8416
|
-
|
|
8417
|
-
|
|
8418
|
-
|
|
8419
|
-
|
|
8469
|
+
return Promise.all(promisedReporters);
|
|
8470
|
+
}
|
|
8471
|
+
|
|
8472
|
+
function isAggregateError(err) {
|
|
8473
|
+
if (typeof AggregateError !== "undefined" && err instanceof AggregateError)
|
|
8474
|
+
return true;
|
|
8475
|
+
return err instanceof Error && "errors" in err;
|
|
8476
|
+
}
|
|
8477
|
+
class StateManager {
|
|
8478
|
+
filesMap = /* @__PURE__ */ new Map();
|
|
8479
|
+
pathsSet = /* @__PURE__ */ new Set();
|
|
8480
|
+
browserTestPromises = /* @__PURE__ */ new Map();
|
|
8481
|
+
idMap = /* @__PURE__ */ new Map();
|
|
8482
|
+
taskFileMap = /* @__PURE__ */ new WeakMap();
|
|
8483
|
+
errorsSet = /* @__PURE__ */ new Set();
|
|
8484
|
+
processTimeoutCauses = /* @__PURE__ */ new Set();
|
|
8485
|
+
catchError(err, type) {
|
|
8486
|
+
if (isAggregateError(err))
|
|
8487
|
+
return err.errors.forEach((error) => this.catchError(error, type));
|
|
8488
|
+
if (err === Object(err))
|
|
8489
|
+
err.type = type;
|
|
8490
|
+
else
|
|
8491
|
+
err = { type, message: err };
|
|
8492
|
+
const _err = err;
|
|
8493
|
+
if (_err && typeof _err === "object" && _err.code === "VITEST_PENDING") {
|
|
8494
|
+
const task = this.idMap.get(_err.taskId);
|
|
8495
|
+
if (task) {
|
|
8496
|
+
task.mode = "skip";
|
|
8497
|
+
task.result ?? (task.result = { state: "skip" });
|
|
8498
|
+
task.result.state = "skip";
|
|
8499
|
+
}
|
|
8500
|
+
return;
|
|
8420
8501
|
}
|
|
8502
|
+
this.errorsSet.add(err);
|
|
8421
8503
|
}
|
|
8422
|
-
(
|
|
8423
|
-
|
|
8424
|
-
if (resolved.runner) {
|
|
8425
|
-
resolved.runner = resolveModule(resolved.runner, { paths: [resolved.root] }) ?? resolve(resolved.root, resolved.runner);
|
|
8504
|
+
clearErrors() {
|
|
8505
|
+
this.errorsSet.clear();
|
|
8426
8506
|
}
|
|
8427
|
-
|
|
8428
|
-
|
|
8429
|
-
console.warn(
|
|
8430
|
-
c.yellow(
|
|
8431
|
-
`${c.inverse(c.yellow(" Vitest "))} "deps.registerNodeLoader" is deprecated.If you rely on aliases inside external packages, use "deps.optimizer.${transformMode}.include" instead.`
|
|
8432
|
-
)
|
|
8433
|
-
);
|
|
8507
|
+
getUnhandledErrors() {
|
|
8508
|
+
return Array.from(this.errorsSet.values());
|
|
8434
8509
|
}
|
|
8435
|
-
|
|
8436
|
-
|
|
8437
|
-
resolved.snapshotFormat.plugins = [];
|
|
8438
|
-
const UPDATE_SNAPSHOT = resolved.update || process.env.UPDATE_SNAPSHOT;
|
|
8439
|
-
resolved.snapshotOptions = {
|
|
8440
|
-
snapshotFormat: resolved.snapshotFormat || {},
|
|
8441
|
-
updateSnapshot: isCI && !UPDATE_SNAPSHOT ? "none" : UPDATE_SNAPSHOT ? "all" : "new",
|
|
8442
|
-
resolveSnapshotPath: options.resolveSnapshotPath,
|
|
8443
|
-
// resolved inside the worker
|
|
8444
|
-
snapshotEnvironment: null
|
|
8445
|
-
};
|
|
8446
|
-
if (options.resolveSnapshotPath)
|
|
8447
|
-
delete resolved.resolveSnapshotPath;
|
|
8448
|
-
if (process.env.VITEST_MAX_THREADS) {
|
|
8449
|
-
resolved.poolOptions = {
|
|
8450
|
-
...resolved.poolOptions,
|
|
8451
|
-
threads: {
|
|
8452
|
-
...(_s = resolved.poolOptions) == null ? void 0 : _s.threads,
|
|
8453
|
-
maxThreads: Number.parseInt(process.env.VITEST_MAX_THREADS)
|
|
8454
|
-
},
|
|
8455
|
-
vmThreads: {
|
|
8456
|
-
...(_t = resolved.poolOptions) == null ? void 0 : _t.vmThreads,
|
|
8457
|
-
maxThreads: Number.parseInt(process.env.VITEST_MAX_THREADS)
|
|
8458
|
-
}
|
|
8459
|
-
};
|
|
8510
|
+
addProcessTimeoutCause(cause) {
|
|
8511
|
+
this.processTimeoutCauses.add(cause);
|
|
8460
8512
|
}
|
|
8461
|
-
|
|
8462
|
-
|
|
8463
|
-
...resolved.poolOptions,
|
|
8464
|
-
threads: {
|
|
8465
|
-
...(_u = resolved.poolOptions) == null ? void 0 : _u.threads,
|
|
8466
|
-
minThreads: Number.parseInt(process.env.VITEST_MIN_THREADS)
|
|
8467
|
-
},
|
|
8468
|
-
vmThreads: {
|
|
8469
|
-
...(_v = resolved.poolOptions) == null ? void 0 : _v.vmThreads,
|
|
8470
|
-
minThreads: Number.parseInt(process.env.VITEST_MIN_THREADS)
|
|
8471
|
-
}
|
|
8472
|
-
};
|
|
8513
|
+
getProcessTimeoutCauses() {
|
|
8514
|
+
return Array.from(this.processTimeoutCauses.values());
|
|
8473
8515
|
}
|
|
8474
|
-
|
|
8475
|
-
|
|
8476
|
-
...resolved.poolOptions,
|
|
8477
|
-
forks: {
|
|
8478
|
-
...(_w = resolved.poolOptions) == null ? void 0 : _w.forks,
|
|
8479
|
-
maxForks: Number.parseInt(process.env.VITEST_MAX_FORKS)
|
|
8480
|
-
}
|
|
8481
|
-
};
|
|
8516
|
+
getPaths() {
|
|
8517
|
+
return Array.from(this.pathsSet);
|
|
8482
8518
|
}
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
...(_x = resolved.poolOptions) == null ? void 0 : _x.forks,
|
|
8488
|
-
minForks: Number.parseInt(process.env.VITEST_MIN_FORKS)
|
|
8489
|
-
}
|
|
8490
|
-
};
|
|
8519
|
+
getFiles(keys) {
|
|
8520
|
+
if (keys)
|
|
8521
|
+
return keys.map((key) => this.filesMap.get(key)).filter(Boolean).flat();
|
|
8522
|
+
return Array.from(this.filesMap.values()).flat();
|
|
8491
8523
|
}
|
|
8492
|
-
|
|
8493
|
-
|
|
8494
|
-
...benchmarkConfigDefaults,
|
|
8495
|
-
...resolved.benchmark
|
|
8496
|
-
};
|
|
8497
|
-
resolved.coverage.enabled = false;
|
|
8498
|
-
resolved.include = resolved.benchmark.include;
|
|
8499
|
-
resolved.exclude = resolved.benchmark.exclude;
|
|
8500
|
-
resolved.includeSource = resolved.benchmark.includeSource;
|
|
8501
|
-
const reporters = Array.from(/* @__PURE__ */ new Set([
|
|
8502
|
-
...toArray(resolved.benchmark.reporters),
|
|
8503
|
-
// @ts-expect-error reporter is CLI flag
|
|
8504
|
-
...toArray(options.reporter)
|
|
8505
|
-
])).filter(Boolean);
|
|
8506
|
-
if (reporters.length)
|
|
8507
|
-
resolved.benchmark.reporters = reporters;
|
|
8508
|
-
else
|
|
8509
|
-
resolved.benchmark.reporters = ["default"];
|
|
8510
|
-
if (options.outputFile)
|
|
8511
|
-
resolved.benchmark.outputFile = options.outputFile;
|
|
8524
|
+
getFilepaths() {
|
|
8525
|
+
return Array.from(this.filesMap.keys());
|
|
8512
8526
|
}
|
|
8513
|
-
|
|
8514
|
-
(
|
|
8515
|
-
|
|
8516
|
-
|
|
8517
|
-
|
|
8518
|
-
resolved.coverage.exclude.push(...resolved.setupFiles.map((file) => `${resolved.coverage.allowExternal ? "**/" : ""}${relative(resolved.root, file)}`));
|
|
8519
|
-
resolved.forceRerunTriggers = [
|
|
8520
|
-
...resolved.forceRerunTriggers,
|
|
8521
|
-
...resolved.setupFiles
|
|
8522
|
-
];
|
|
8523
|
-
if (resolved.diff) {
|
|
8524
|
-
resolved.diff = normalize(
|
|
8525
|
-
resolveModule(resolved.diff, { paths: [resolved.root] }) ?? resolve(resolved.root, resolved.diff)
|
|
8526
|
-
);
|
|
8527
|
-
resolved.forceRerunTriggers.push(resolved.diff);
|
|
8527
|
+
getFailedFilepaths() {
|
|
8528
|
+
return this.getFiles().filter((i) => {
|
|
8529
|
+
var _a;
|
|
8530
|
+
return ((_a = i.result) == null ? void 0 : _a.state) === "fail";
|
|
8531
|
+
}).map((i) => i.filepath);
|
|
8528
8532
|
}
|
|
8529
|
-
|
|
8530
|
-
|
|
8531
|
-
|
|
8532
|
-
if (mode !== "benchmark") {
|
|
8533
|
-
const cliReporters = toArray(resolved.reporter || []).map((reporter) => {
|
|
8534
|
-
if (/^\.\.?\//.test(reporter))
|
|
8535
|
-
return resolve(process.cwd(), reporter);
|
|
8536
|
-
return reporter;
|
|
8533
|
+
collectPaths(paths = []) {
|
|
8534
|
+
paths.forEach((path) => {
|
|
8535
|
+
this.pathsSet.add(path);
|
|
8537
8536
|
});
|
|
8538
|
-
const reporters = cliReporters.length ? cliReporters : resolved.reporters;
|
|
8539
|
-
resolved.reporters = Array.from(new Set(toArray(reporters))).filter(Boolean);
|
|
8540
8537
|
}
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8538
|
+
collectFiles(files = []) {
|
|
8539
|
+
files.forEach((file) => {
|
|
8540
|
+
const existing = this.filesMap.get(file.filepath) || [];
|
|
8541
|
+
const otherProject = existing.filter((i) => i.projectName !== file.projectName);
|
|
8542
|
+
otherProject.push(file);
|
|
8543
|
+
this.filesMap.set(file.filepath, otherProject);
|
|
8544
|
+
this.updateId(file);
|
|
8545
|
+
});
|
|
8549
8546
|
}
|
|
8550
|
-
|
|
8551
|
-
|
|
8552
|
-
|
|
8553
|
-
|
|
8554
|
-
|
|
8555
|
-
|
|
8547
|
+
// this file is reused by ws-client, and shoult not rely on heavy dependencies like workspace
|
|
8548
|
+
clearFiles(_project, paths = []) {
|
|
8549
|
+
const project = _project;
|
|
8550
|
+
paths.forEach((path) => {
|
|
8551
|
+
const files = this.filesMap.get(path);
|
|
8552
|
+
if (!files)
|
|
8553
|
+
return;
|
|
8554
|
+
const filtered = files.filter((file) => file.projectName !== project.config.name);
|
|
8555
|
+
if (!filtered.length)
|
|
8556
|
+
this.filesMap.delete(path);
|
|
8557
|
+
else
|
|
8558
|
+
this.filesMap.set(path, filtered);
|
|
8559
|
+
});
|
|
8556
8560
|
}
|
|
8557
|
-
(
|
|
8558
|
-
|
|
8559
|
-
|
|
8560
|
-
|
|
8561
|
-
|
|
8562
|
-
|
|
8563
|
-
|
|
8564
|
-
|
|
8565
|
-
|
|
8566
|
-
|
|
8567
|
-
|
|
8561
|
+
updateId(task) {
|
|
8562
|
+
if (this.idMap.get(task.id) === task)
|
|
8563
|
+
return;
|
|
8564
|
+
this.idMap.set(task.id, task);
|
|
8565
|
+
if (task.type === "suite") {
|
|
8566
|
+
task.tasks.forEach((task2) => {
|
|
8567
|
+
this.updateId(task2);
|
|
8568
|
+
});
|
|
8569
|
+
}
|
|
8570
|
+
}
|
|
8571
|
+
updateTasks(packs) {
|
|
8572
|
+
for (const [id, result, meta] of packs) {
|
|
8573
|
+
const task = this.idMap.get(id);
|
|
8574
|
+
if (task) {
|
|
8575
|
+
task.result = result;
|
|
8576
|
+
task.meta = meta;
|
|
8577
|
+
if ((result == null ? void 0 : result.state) === "skip")
|
|
8578
|
+
task.mode = "skip";
|
|
8579
|
+
}
|
|
8580
|
+
}
|
|
8581
|
+
}
|
|
8582
|
+
updateUserLog(log) {
|
|
8583
|
+
const task = log.taskId && this.idMap.get(log.taskId);
|
|
8584
|
+
if (task) {
|
|
8585
|
+
if (!task.logs)
|
|
8586
|
+
task.logs = [];
|
|
8587
|
+
task.logs.push(log);
|
|
8588
|
+
}
|
|
8589
|
+
}
|
|
8590
|
+
getCountOfFailedTests() {
|
|
8591
|
+
return Array.from(this.idMap.values()).filter((t) => {
|
|
8592
|
+
var _a;
|
|
8593
|
+
return ((_a = t.result) == null ? void 0 : _a.state) === "fail";
|
|
8594
|
+
}).length;
|
|
8595
|
+
}
|
|
8596
|
+
cancelFiles(files, root) {
|
|
8597
|
+
this.collectFiles(files.map((filepath) => ({
|
|
8598
|
+
filepath,
|
|
8599
|
+
name: relative(root, filepath),
|
|
8600
|
+
id: filepath,
|
|
8601
|
+
mode: "skip",
|
|
8602
|
+
type: "suite",
|
|
8603
|
+
result: {
|
|
8604
|
+
state: "skip"
|
|
8605
|
+
},
|
|
8606
|
+
meta: {},
|
|
8607
|
+
// Cancelled files have not yet collected tests
|
|
8608
|
+
tasks: []
|
|
8609
|
+
})));
|
|
8568
8610
|
}
|
|
8569
|
-
resolved.browser ?? (resolved.browser = {});
|
|
8570
|
-
(_D = resolved.browser).enabled ?? (_D.enabled = false);
|
|
8571
|
-
(_E = resolved.browser).headless ?? (_E.headless = isCI);
|
|
8572
|
-
(_F = resolved.browser).slowHijackESM ?? (_F.slowHijackESM = true);
|
|
8573
|
-
(_G = resolved.browser).isolate ?? (_G.isolate = true);
|
|
8574
|
-
resolved.browser.api = resolveApiServerConfig(resolved.browser) || {
|
|
8575
|
-
port: defaultBrowserPort
|
|
8576
|
-
};
|
|
8577
|
-
resolved.testTransformMode ?? (resolved.testTransformMode = {});
|
|
8578
|
-
return resolved;
|
|
8579
|
-
}
|
|
8580
|
-
function isBrowserEnabled(config) {
|
|
8581
|
-
var _a, _b;
|
|
8582
|
-
if ((_a = config.browser) == null ? void 0 : _a.enabled)
|
|
8583
|
-
return true;
|
|
8584
|
-
return ((_b = config.poolMatchGlobs) == null ? void 0 : _b.length) && config.poolMatchGlobs.some(([, pool]) => pool === "browser");
|
|
8585
8611
|
}
|
|
8586
8612
|
|
|
8587
|
-
const
|
|
8588
|
-
const
|
|
8589
|
-
const
|
|
8590
|
-
|
|
8591
|
-
|
|
8592
|
-
|
|
8593
|
-
|
|
8594
|
-
|
|
8595
|
-
ansiEscapes.cursorTo = (x, y) => {
|
|
8596
|
-
if (typeof x !== 'number') {
|
|
8597
|
-
throw new TypeError('The `x` argument is required');
|
|
8598
|
-
}
|
|
8599
|
-
|
|
8600
|
-
if (typeof y !== 'number') {
|
|
8601
|
-
return ESC$1 + (x + 1) + 'G';
|
|
8602
|
-
}
|
|
8603
|
-
|
|
8604
|
-
return ESC$1 + (y + 1) + ';' + (x + 1) + 'H';
|
|
8613
|
+
const defaultInclude = ["**/*.{test,spec}.?(c|m)[jt]s?(x)"];
|
|
8614
|
+
const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**", "**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*"];
|
|
8615
|
+
const benchmarkConfigDefaults = {
|
|
8616
|
+
include: ["**/*.{bench,benchmark}.?(c|m)[jt]s?(x)"],
|
|
8617
|
+
exclude: defaultExclude,
|
|
8618
|
+
includeSource: [],
|
|
8619
|
+
reporters: ["default"]
|
|
8605
8620
|
};
|
|
8606
|
-
|
|
8607
|
-
|
|
8608
|
-
|
|
8609
|
-
|
|
8610
|
-
|
|
8611
|
-
|
|
8612
|
-
|
|
8613
|
-
|
|
8614
|
-
|
|
8615
|
-
|
|
8616
|
-
|
|
8617
|
-
|
|
8618
|
-
|
|
8619
|
-
|
|
8620
|
-
|
|
8621
|
-
|
|
8622
|
-
|
|
8623
|
-
|
|
8624
|
-
|
|
8625
|
-
|
|
8626
|
-
|
|
8621
|
+
const defaultCoverageExcludes = [
|
|
8622
|
+
"coverage/**",
|
|
8623
|
+
"dist/**",
|
|
8624
|
+
"packages/*/test?(s)/**",
|
|
8625
|
+
"**/*.d.ts",
|
|
8626
|
+
"**/virtual:*",
|
|
8627
|
+
"**/__x00__*",
|
|
8628
|
+
"**/\0*",
|
|
8629
|
+
"cypress/**",
|
|
8630
|
+
"test?(s)/**",
|
|
8631
|
+
"test?(-*).?(c|m)[jt]s?(x)",
|
|
8632
|
+
"**/*{.,-}{test,spec}.?(c|m)[jt]s?(x)",
|
|
8633
|
+
"**/__tests__/**",
|
|
8634
|
+
"**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build}.config.*",
|
|
8635
|
+
"**/vitest.{workspace,projects}.[jt]s?(on)",
|
|
8636
|
+
"**/.{eslint,mocha,prettier}rc.{?(c|m)js,yml}"
|
|
8637
|
+
];
|
|
8638
|
+
const coverageConfigDefaults = {
|
|
8639
|
+
provider: "v8",
|
|
8640
|
+
enabled: false,
|
|
8641
|
+
all: true,
|
|
8642
|
+
clean: true,
|
|
8643
|
+
cleanOnRerun: true,
|
|
8644
|
+
reportsDirectory: "./coverage",
|
|
8645
|
+
exclude: defaultCoverageExcludes,
|
|
8646
|
+
reportOnFailure: false,
|
|
8647
|
+
reporter: [["text", {}], ["html", {}], ["clover", {}], ["json", {}]],
|
|
8648
|
+
extension: [".js", ".cjs", ".mjs", ".ts", ".mts", ".cts", ".tsx", ".jsx", ".vue", ".svelte", ".marko"],
|
|
8649
|
+
allowExternal: false
|
|
8627
8650
|
};
|
|
8628
|
-
|
|
8629
|
-
|
|
8630
|
-
|
|
8631
|
-
|
|
8632
|
-
|
|
8633
|
-
|
|
8634
|
-
|
|
8635
|
-
|
|
8636
|
-
|
|
8637
|
-
|
|
8638
|
-
|
|
8639
|
-
|
|
8640
|
-
ansiEscapes.cursorHide = ESC$1 + '?25l';
|
|
8641
|
-
ansiEscapes.cursorShow = ESC$1 + '?25h';
|
|
8642
|
-
|
|
8643
|
-
ansiEscapes.eraseLines = count => {
|
|
8644
|
-
let clear = '';
|
|
8645
|
-
|
|
8646
|
-
for (let i = 0; i < count; i++) {
|
|
8647
|
-
clear += ansiEscapes.eraseLine + (i < count - 1 ? ansiEscapes.cursorUp() : '');
|
|
8648
|
-
}
|
|
8649
|
-
|
|
8650
|
-
if (count) {
|
|
8651
|
-
clear += ansiEscapes.cursorLeft;
|
|
8652
|
-
}
|
|
8653
|
-
|
|
8654
|
-
return clear;
|
|
8655
|
-
};
|
|
8656
|
-
|
|
8657
|
-
ansiEscapes.eraseEndLine = ESC$1 + 'K';
|
|
8658
|
-
ansiEscapes.eraseStartLine = ESC$1 + '1K';
|
|
8659
|
-
ansiEscapes.eraseLine = ESC$1 + '2K';
|
|
8660
|
-
ansiEscapes.eraseDown = ESC$1 + 'J';
|
|
8661
|
-
ansiEscapes.eraseUp = ESC$1 + '1J';
|
|
8662
|
-
ansiEscapes.eraseScreen = ESC$1 + '2J';
|
|
8663
|
-
ansiEscapes.scrollUp = ESC$1 + 'S';
|
|
8664
|
-
ansiEscapes.scrollDown = ESC$1 + 'T';
|
|
8665
|
-
|
|
8666
|
-
ansiEscapes.clearScreen = '\u001Bc';
|
|
8667
|
-
|
|
8668
|
-
ansiEscapes.clearTerminal = process.platform === 'win32' ?
|
|
8669
|
-
`${ansiEscapes.eraseScreen}${ESC$1}0f` :
|
|
8670
|
-
// 1. Erases the screen (Only done in case `2` is not supported)
|
|
8671
|
-
// 2. Erases the whole screen including scrollback buffer
|
|
8672
|
-
// 3. Moves cursor to the top-left position
|
|
8673
|
-
// More info: https://www.real-world-systems.com/docs/ANSIcode.html
|
|
8674
|
-
`${ansiEscapes.eraseScreen}${ESC$1}3J${ESC$1}H`;
|
|
8675
|
-
|
|
8676
|
-
ansiEscapes.beep = BEL;
|
|
8677
|
-
|
|
8678
|
-
ansiEscapes.link = (text, url) => {
|
|
8679
|
-
return [
|
|
8680
|
-
OSC,
|
|
8681
|
-
'8',
|
|
8682
|
-
SEP,
|
|
8683
|
-
SEP,
|
|
8684
|
-
url,
|
|
8685
|
-
BEL,
|
|
8686
|
-
text,
|
|
8687
|
-
OSC,
|
|
8688
|
-
'8',
|
|
8689
|
-
SEP,
|
|
8690
|
-
SEP,
|
|
8691
|
-
BEL
|
|
8692
|
-
].join('');
|
|
8651
|
+
const fakeTimersDefaults = {
|
|
8652
|
+
loopLimit: 1e4,
|
|
8653
|
+
shouldClearNativeTimers: true,
|
|
8654
|
+
toFake: [
|
|
8655
|
+
"setTimeout",
|
|
8656
|
+
"clearTimeout",
|
|
8657
|
+
"setInterval",
|
|
8658
|
+
"clearInterval",
|
|
8659
|
+
"setImmediate",
|
|
8660
|
+
"clearImmediate",
|
|
8661
|
+
"Date"
|
|
8662
|
+
]
|
|
8693
8663
|
};
|
|
8694
|
-
|
|
8695
|
-
|
|
8696
|
-
|
|
8697
|
-
|
|
8698
|
-
|
|
8699
|
-
|
|
8700
|
-
|
|
8701
|
-
|
|
8702
|
-
|
|
8703
|
-
|
|
8704
|
-
|
|
8705
|
-
|
|
8706
|
-
|
|
8707
|
-
|
|
8708
|
-
|
|
8709
|
-
|
|
8710
|
-
|
|
8664
|
+
const config = {
|
|
8665
|
+
allowOnly: !isCI,
|
|
8666
|
+
watch: !isCI,
|
|
8667
|
+
globals: false,
|
|
8668
|
+
environment: "node",
|
|
8669
|
+
pool: "threads",
|
|
8670
|
+
clearMocks: false,
|
|
8671
|
+
restoreMocks: false,
|
|
8672
|
+
mockReset: false,
|
|
8673
|
+
include: defaultInclude,
|
|
8674
|
+
exclude: defaultExclude,
|
|
8675
|
+
testTimeout: 5e3,
|
|
8676
|
+
hookTimeout: 1e4,
|
|
8677
|
+
teardownTimeout: 1e4,
|
|
8678
|
+
watchExclude: ["**/node_modules/**", "**/dist/**"],
|
|
8679
|
+
forceRerunTriggers: [
|
|
8680
|
+
"**/package.json/**",
|
|
8681
|
+
"**/{vitest,vite}.config.*/**"
|
|
8682
|
+
],
|
|
8683
|
+
update: false,
|
|
8684
|
+
reporters: [],
|
|
8685
|
+
silent: false,
|
|
8686
|
+
hideSkippedTests: false,
|
|
8687
|
+
api: false,
|
|
8688
|
+
ui: false,
|
|
8689
|
+
uiBase: "/__vitest__/",
|
|
8690
|
+
open: true,
|
|
8691
|
+
css: {
|
|
8692
|
+
include: []
|
|
8693
|
+
},
|
|
8694
|
+
coverage: coverageConfigDefaults,
|
|
8695
|
+
fakeTimers: fakeTimersDefaults,
|
|
8696
|
+
maxConcurrency: 5,
|
|
8697
|
+
dangerouslyIgnoreUnhandledErrors: false,
|
|
8698
|
+
typecheck: {
|
|
8699
|
+
checker: "tsc",
|
|
8700
|
+
include: ["**/*.{test,spec}-d.?(c|m)[jt]s?(x)"],
|
|
8701
|
+
exclude: defaultExclude
|
|
8702
|
+
},
|
|
8703
|
+
slowTestThreshold: 300
|
|
8711
8704
|
};
|
|
8705
|
+
const configDefaults = Object.freeze(config);
|
|
8712
8706
|
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
|
|
8719
|
-
|
|
8720
|
-
|
|
8721
|
-
|
|
8722
|
-
|
|
8723
|
-
|
|
8707
|
+
class FilesStatsCache {
|
|
8708
|
+
cache = /* @__PURE__ */ new Map();
|
|
8709
|
+
getStats(key) {
|
|
8710
|
+
return this.cache.get(key);
|
|
8711
|
+
}
|
|
8712
|
+
async populateStats(root, specs) {
|
|
8713
|
+
const promises = specs.map((spec) => {
|
|
8714
|
+
const key = `${spec[0].getName()}:${relative(root, spec[1])}`;
|
|
8715
|
+
return this.updateStats(spec[1], key);
|
|
8716
|
+
});
|
|
8717
|
+
await Promise.all(promises);
|
|
8718
|
+
}
|
|
8719
|
+
async updateStats(fsPath, key) {
|
|
8720
|
+
if (!fs$8.existsSync(fsPath))
|
|
8721
|
+
return;
|
|
8722
|
+
const stats = await fs$8.promises.stat(fsPath);
|
|
8723
|
+
this.cache.set(key, { size: stats.size });
|
|
8724
|
+
}
|
|
8725
|
+
removeStats(fsPath) {
|
|
8726
|
+
this.cache.forEach((_, key) => {
|
|
8727
|
+
if (key.endsWith(fsPath))
|
|
8728
|
+
this.cache.delete(key);
|
|
8729
|
+
});
|
|
8730
|
+
}
|
|
8731
|
+
}
|
|
8724
8732
|
|
|
8725
|
-
|
|
8733
|
+
class ResultsCache {
|
|
8734
|
+
cache = /* @__PURE__ */ new Map();
|
|
8735
|
+
workspacesKeyMap = /* @__PURE__ */ new Map();
|
|
8736
|
+
cachePath = null;
|
|
8737
|
+
version = version$1;
|
|
8738
|
+
root = "/";
|
|
8739
|
+
getCachePath() {
|
|
8740
|
+
return this.cachePath;
|
|
8741
|
+
}
|
|
8742
|
+
setConfig(root, config) {
|
|
8743
|
+
this.root = root;
|
|
8744
|
+
if (config)
|
|
8745
|
+
this.cachePath = resolve(config.dir, "results.json");
|
|
8746
|
+
}
|
|
8747
|
+
getResults(key) {
|
|
8748
|
+
return this.cache.get(key);
|
|
8749
|
+
}
|
|
8750
|
+
async readFromCache() {
|
|
8751
|
+
if (!this.cachePath)
|
|
8752
|
+
return;
|
|
8753
|
+
if (!fs$8.existsSync(this.cachePath))
|
|
8754
|
+
return;
|
|
8755
|
+
const resultsCache = await fs$8.promises.readFile(this.cachePath, "utf8");
|
|
8756
|
+
const { results, version: version2 } = JSON.parse(resultsCache || "[]");
|
|
8757
|
+
if (Number(version2.split(".")[1]) >= 30) {
|
|
8758
|
+
this.cache = new Map(results);
|
|
8759
|
+
this.version = version2;
|
|
8760
|
+
results.forEach(([spec]) => {
|
|
8761
|
+
const [projectName, relativePath] = spec.split(":");
|
|
8762
|
+
const keyMap = this.workspacesKeyMap.get(relativePath) || [];
|
|
8763
|
+
keyMap.push(projectName);
|
|
8764
|
+
this.workspacesKeyMap.set(relativePath, keyMap);
|
|
8765
|
+
});
|
|
8766
|
+
}
|
|
8767
|
+
}
|
|
8768
|
+
updateResults(files) {
|
|
8769
|
+
files.forEach((file) => {
|
|
8770
|
+
const result = file.result;
|
|
8771
|
+
if (!result)
|
|
8772
|
+
return;
|
|
8773
|
+
const duration = result.duration || 0;
|
|
8774
|
+
const relativePath = relative(this.root, file.filepath);
|
|
8775
|
+
this.cache.set(`${file.projectName || ""}:${relativePath}`, {
|
|
8776
|
+
duration: duration >= 0 ? duration : 0,
|
|
8777
|
+
failed: result.state === "fail"
|
|
8778
|
+
});
|
|
8779
|
+
});
|
|
8780
|
+
}
|
|
8781
|
+
removeFromCache(filepath) {
|
|
8782
|
+
this.cache.forEach((_, key) => {
|
|
8783
|
+
if (key.endsWith(filepath))
|
|
8784
|
+
this.cache.delete(key);
|
|
8785
|
+
});
|
|
8786
|
+
}
|
|
8787
|
+
async writeToCache() {
|
|
8788
|
+
if (!this.cachePath)
|
|
8789
|
+
return;
|
|
8790
|
+
const results = Array.from(this.cache.entries());
|
|
8791
|
+
const cacheDirname = dirname(this.cachePath);
|
|
8792
|
+
if (!fs$8.existsSync(cacheDirname))
|
|
8793
|
+
await fs$8.promises.mkdir(cacheDirname, { recursive: true });
|
|
8794
|
+
const cache = JSON.stringify({
|
|
8795
|
+
version: this.version,
|
|
8796
|
+
results
|
|
8797
|
+
});
|
|
8798
|
+
await fs$8.promises.writeFile(this.cachePath, cache);
|
|
8799
|
+
}
|
|
8800
|
+
}
|
|
8726
8801
|
|
|
8727
|
-
|
|
8802
|
+
class VitestCache {
|
|
8803
|
+
results = new ResultsCache();
|
|
8804
|
+
stats = new FilesStatsCache();
|
|
8805
|
+
getFileTestResults(key) {
|
|
8806
|
+
return this.results.getResults(key);
|
|
8807
|
+
}
|
|
8808
|
+
getFileStats(key) {
|
|
8809
|
+
return this.stats.getStats(key);
|
|
8810
|
+
}
|
|
8811
|
+
static resolveCacheDir(root, dir, projectName) {
|
|
8812
|
+
const baseDir = slash$1(dir || "node_modules/.vitest");
|
|
8813
|
+
return projectName ? resolve(root, baseDir, crypto.createHash("md5").update(projectName, "utf-8").digest("hex")) : resolve(root, baseDir);
|
|
8814
|
+
}
|
|
8815
|
+
static async clearCache(options) {
|
|
8816
|
+
var _a, _b, _c;
|
|
8817
|
+
const root = resolve(options.root || process.cwd());
|
|
8818
|
+
const configPath = options.config === false ? false : options.config ? resolve(root, options.config) : await findUp(configFiles, { cwd: root });
|
|
8819
|
+
const config = configPath ? (_a = await loadConfigFromFile({ command: "serve", mode: "test" }, configPath)) == null ? void 0 : _a.config : void 0;
|
|
8820
|
+
const cache = (_b = config == null ? void 0 : config.test) == null ? void 0 : _b.cache;
|
|
8821
|
+
const projectName = (_c = config == null ? void 0 : config.test) == null ? void 0 : _c.name;
|
|
8822
|
+
if (cache === false)
|
|
8823
|
+
throw new Error("Cache is disabled");
|
|
8824
|
+
const cachePath = VitestCache.resolveCacheDir(root, cache == null ? void 0 : cache.dir, projectName);
|
|
8825
|
+
let cleared = false;
|
|
8826
|
+
if (fs$8.existsSync(cachePath)) {
|
|
8827
|
+
fs$8.rmSync(cachePath, { recursive: true, force: true });
|
|
8828
|
+
cleared = true;
|
|
8829
|
+
}
|
|
8830
|
+
return { dir: cachePath, cleared };
|
|
8831
|
+
}
|
|
8832
|
+
}
|
|
8728
8833
|
|
|
8729
|
-
|
|
8730
|
-
|
|
8731
|
-
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
|
|
8735
|
-
|
|
8736
|
-
|
|
8737
|
-
|
|
8738
|
-
|
|
8739
|
-
|
|
8740
|
-
|
|
8741
|
-
|
|
8742
|
-
|
|
8743
|
-
|
|
8744
|
-
|
|
8745
|
-
|
|
8746
|
-
|
|
8747
|
-
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
|
|
8754
|
-
|
|
8755
|
-
|
|
8756
|
-
|
|
8757
|
-
|
|
8758
|
-
|
|
8759
|
-
|
|
8760
|
-
const
|
|
8761
|
-
|
|
8762
|
-
|
|
8763
|
-
|
|
8764
|
-
|
|
8765
|
-
|
|
8766
|
-
|
|
8767
|
-
|
|
8768
|
-
|
|
8769
|
-
|
|
8770
|
-
|
|
8771
|
-
|
|
8772
|
-
|
|
8773
|
-
const onetime = function (...arguments_) {
|
|
8774
|
-
calledFunctions.set(onetime, ++callCount);
|
|
8775
|
-
|
|
8776
|
-
if (callCount === 1) {
|
|
8777
|
-
returnValue = function_.apply(this, arguments_);
|
|
8778
|
-
function_ = null;
|
|
8779
|
-
} else if (options.throw === true) {
|
|
8780
|
-
throw new Error(`Function \`${functionName}\` can only be called once`);
|
|
8781
|
-
}
|
|
8782
|
-
|
|
8783
|
-
return returnValue;
|
|
8784
|
-
};
|
|
8785
|
-
|
|
8786
|
-
mimicFn(onetime, function_);
|
|
8787
|
-
calledFunctions.set(onetime, callCount);
|
|
8788
|
-
|
|
8789
|
-
return onetime;
|
|
8790
|
-
};
|
|
8791
|
-
|
|
8792
|
-
onetime$2.exports = onetime;
|
|
8793
|
-
// TODO: Remove this for the next major release
|
|
8794
|
-
onetime$2.exports.default = onetime;
|
|
8795
|
-
|
|
8796
|
-
onetime$2.exports.callCount = function_ => {
|
|
8797
|
-
if (!calledFunctions.has(function_)) {
|
|
8798
|
-
throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
|
|
8799
|
-
}
|
|
8800
|
-
|
|
8801
|
-
return calledFunctions.get(function_);
|
|
8802
|
-
};
|
|
8803
|
-
|
|
8804
|
-
var onetimeExports = onetime$2.exports;
|
|
8805
|
-
var onetime$1 = /*@__PURE__*/getDefaultExportFromCjs(onetimeExports);
|
|
8806
|
-
|
|
8807
|
-
const restoreCursor = onetime$1(() => {
|
|
8808
|
-
onExit(() => {
|
|
8809
|
-
process$1.stderr.write('\u001B[?25h');
|
|
8810
|
-
}, {alwaysLast: true});
|
|
8811
|
-
});
|
|
8812
|
-
|
|
8813
|
-
let isHidden = false;
|
|
8814
|
-
|
|
8815
|
-
const cliCursor = {};
|
|
8816
|
-
|
|
8817
|
-
cliCursor.show = (writableStream = process$1.stderr) => {
|
|
8818
|
-
if (!writableStream.isTTY) {
|
|
8819
|
-
return;
|
|
8820
|
-
}
|
|
8821
|
-
|
|
8822
|
-
isHidden = false;
|
|
8823
|
-
writableStream.write('\u001B[?25h');
|
|
8824
|
-
};
|
|
8825
|
-
|
|
8826
|
-
cliCursor.hide = (writableStream = process$1.stderr) => {
|
|
8827
|
-
if (!writableStream.isTTY) {
|
|
8828
|
-
return;
|
|
8829
|
-
}
|
|
8830
|
-
|
|
8831
|
-
restoreCursor();
|
|
8832
|
-
isHidden = true;
|
|
8833
|
-
writableStream.write('\u001B[?25l');
|
|
8834
|
-
};
|
|
8835
|
-
|
|
8836
|
-
cliCursor.toggle = (force, writableStream) => {
|
|
8837
|
-
if (force !== undefined) {
|
|
8838
|
-
isHidden = force;
|
|
8839
|
-
}
|
|
8840
|
-
|
|
8841
|
-
if (isHidden) {
|
|
8842
|
-
cliCursor.show(writableStream);
|
|
8843
|
-
} else {
|
|
8844
|
-
cliCursor.hide(writableStream);
|
|
8845
|
-
}
|
|
8846
|
-
};
|
|
8847
|
-
|
|
8848
|
-
const ESCAPES = new Set([
|
|
8849
|
-
'\u001B',
|
|
8850
|
-
'\u009B',
|
|
8851
|
-
]);
|
|
8852
|
-
|
|
8853
|
-
const END_CODE = 39;
|
|
8854
|
-
const ANSI_ESCAPE_BELL = '\u0007';
|
|
8855
|
-
const ANSI_CSI = '[';
|
|
8856
|
-
const ANSI_OSC = ']';
|
|
8857
|
-
const ANSI_SGR_TERMINATOR = 'm';
|
|
8858
|
-
const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
8859
|
-
|
|
8860
|
-
const wrapAnsiCode = code => `${ESCAPES.values().next().value}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
8861
|
-
const wrapAnsiHyperlink = uri => `${ESCAPES.values().next().value}${ANSI_ESCAPE_LINK}${uri}${ANSI_ESCAPE_BELL}`;
|
|
8862
|
-
|
|
8863
|
-
// Calculate the length of words split on ' ', ignoring
|
|
8864
|
-
// the extra characters added by ansi escape codes
|
|
8865
|
-
const wordLengths = string => string.split(' ').map(character => stringWidth(character));
|
|
8866
|
-
|
|
8867
|
-
// Wrap a long word across multiple rows
|
|
8868
|
-
// Ansi escape codes do not count towards length
|
|
8869
|
-
const wrapWord = (rows, word, columns) => {
|
|
8870
|
-
const characters = [...word];
|
|
8871
|
-
|
|
8872
|
-
let isInsideEscape = false;
|
|
8873
|
-
let isInsideLinkEscape = false;
|
|
8874
|
-
let visible = stringWidth(stripAnsi(rows[rows.length - 1]));
|
|
8875
|
-
|
|
8876
|
-
for (const [index, character] of characters.entries()) {
|
|
8877
|
-
const characterLength = stringWidth(character);
|
|
8878
|
-
|
|
8879
|
-
if (visible + characterLength <= columns) {
|
|
8880
|
-
rows[rows.length - 1] += character;
|
|
8881
|
-
} else {
|
|
8882
|
-
rows.push(character);
|
|
8883
|
-
visible = 0;
|
|
8884
|
-
}
|
|
8885
|
-
|
|
8886
|
-
if (ESCAPES.has(character)) {
|
|
8887
|
-
isInsideEscape = true;
|
|
8888
|
-
isInsideLinkEscape = characters.slice(index + 1).join('').startsWith(ANSI_ESCAPE_LINK);
|
|
8889
|
-
}
|
|
8890
|
-
|
|
8891
|
-
if (isInsideEscape) {
|
|
8892
|
-
if (isInsideLinkEscape) {
|
|
8893
|
-
if (character === ANSI_ESCAPE_BELL) {
|
|
8894
|
-
isInsideEscape = false;
|
|
8895
|
-
isInsideLinkEscape = false;
|
|
8896
|
-
}
|
|
8897
|
-
} else if (character === ANSI_SGR_TERMINATOR) {
|
|
8898
|
-
isInsideEscape = false;
|
|
8899
|
-
}
|
|
8900
|
-
|
|
8901
|
-
continue;
|
|
8902
|
-
}
|
|
8903
|
-
|
|
8904
|
-
visible += characterLength;
|
|
8905
|
-
|
|
8906
|
-
if (visible === columns && index < characters.length - 1) {
|
|
8907
|
-
rows.push('');
|
|
8908
|
-
visible = 0;
|
|
8909
|
-
}
|
|
8910
|
-
}
|
|
8911
|
-
|
|
8912
|
-
// It's possible that the last row we copy over is only
|
|
8913
|
-
// ansi escape characters, handle this edge-case
|
|
8914
|
-
if (!visible && rows[rows.length - 1].length > 0 && rows.length > 1) {
|
|
8915
|
-
rows[rows.length - 2] += rows.pop();
|
|
8916
|
-
}
|
|
8917
|
-
};
|
|
8918
|
-
|
|
8919
|
-
// Trims spaces from a string ignoring invisible sequences
|
|
8920
|
-
const stringVisibleTrimSpacesRight = string => {
|
|
8921
|
-
const words = string.split(' ');
|
|
8922
|
-
let last = words.length;
|
|
8923
|
-
|
|
8924
|
-
while (last > 0) {
|
|
8925
|
-
if (stringWidth(words[last - 1]) > 0) {
|
|
8926
|
-
break;
|
|
8927
|
-
}
|
|
8928
|
-
|
|
8929
|
-
last--;
|
|
8930
|
-
}
|
|
8931
|
-
|
|
8932
|
-
if (last === words.length) {
|
|
8933
|
-
return string;
|
|
8934
|
-
}
|
|
8834
|
+
class BaseSequencer {
|
|
8835
|
+
ctx;
|
|
8836
|
+
constructor(ctx) {
|
|
8837
|
+
this.ctx = ctx;
|
|
8838
|
+
}
|
|
8839
|
+
// async so it can be extended by other sequelizers
|
|
8840
|
+
async shard(files) {
|
|
8841
|
+
const { config } = this.ctx;
|
|
8842
|
+
const { index, count } = config.shard;
|
|
8843
|
+
const shardSize = Math.ceil(files.length / count);
|
|
8844
|
+
const shardStart = shardSize * (index - 1);
|
|
8845
|
+
const shardEnd = shardSize * index;
|
|
8846
|
+
return [...files].map((spec) => {
|
|
8847
|
+
const fullPath = resolve(slash$2(config.root), slash$2(spec[1]));
|
|
8848
|
+
const specPath = fullPath == null ? void 0 : fullPath.slice(config.root.length);
|
|
8849
|
+
return {
|
|
8850
|
+
spec,
|
|
8851
|
+
hash: createHash("sha1").update(specPath).digest("hex")
|
|
8852
|
+
};
|
|
8853
|
+
}).sort((a, b) => a.hash < b.hash ? -1 : a.hash > b.hash ? 1 : 0).slice(shardStart, shardEnd).map(({ spec }) => spec);
|
|
8854
|
+
}
|
|
8855
|
+
// async so it can be extended by other sequelizers
|
|
8856
|
+
async sort(files) {
|
|
8857
|
+
const cache = this.ctx.cache;
|
|
8858
|
+
return [...files].sort((a, b) => {
|
|
8859
|
+
const keyA = `${a[0].getName()}:${relative(this.ctx.config.root, a[1])}`;
|
|
8860
|
+
const keyB = `${b[0].getName()}:${relative(this.ctx.config.root, b[1])}`;
|
|
8861
|
+
const aState = cache.getFileTestResults(keyA);
|
|
8862
|
+
const bState = cache.getFileTestResults(keyB);
|
|
8863
|
+
if (!aState || !bState) {
|
|
8864
|
+
const statsA = cache.getFileStats(keyA);
|
|
8865
|
+
const statsB = cache.getFileStats(keyB);
|
|
8866
|
+
if (!statsA || !statsB)
|
|
8867
|
+
return !statsA && statsB ? -1 : !statsB && statsA ? 1 : 0;
|
|
8868
|
+
return statsB.size - statsA.size;
|
|
8869
|
+
}
|
|
8870
|
+
if (aState.failed && !bState.failed)
|
|
8871
|
+
return -1;
|
|
8872
|
+
if (!aState.failed && bState.failed)
|
|
8873
|
+
return 1;
|
|
8874
|
+
return bState.duration - aState.duration;
|
|
8875
|
+
});
|
|
8876
|
+
}
|
|
8877
|
+
}
|
|
8935
8878
|
|
|
8936
|
-
|
|
8937
|
-
|
|
8879
|
+
class RandomSequencer extends BaseSequencer {
|
|
8880
|
+
async sort(files) {
|
|
8881
|
+
const { sequence } = this.ctx.config;
|
|
8882
|
+
return shuffle(files, sequence.seed);
|
|
8883
|
+
}
|
|
8884
|
+
}
|
|
8938
8885
|
|
|
8939
|
-
|
|
8940
|
-
|
|
8941
|
-
|
|
8942
|
-
//
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
|
|
8886
|
+
const extraInlineDeps = [
|
|
8887
|
+
/^(?!.*(?:node_modules)).*\.mjs$/,
|
|
8888
|
+
/^(?!.*(?:node_modules)).*\.cjs\.js$/,
|
|
8889
|
+
// Vite client
|
|
8890
|
+
/vite\w*\/dist\/client\/env.mjs/,
|
|
8891
|
+
// Nuxt
|
|
8892
|
+
"@nuxt/test-utils"
|
|
8893
|
+
];
|
|
8894
|
+
function resolveApiServerConfig(options) {
|
|
8895
|
+
let api;
|
|
8896
|
+
if (options.ui && !options.api)
|
|
8897
|
+
api = { port: defaultPort };
|
|
8898
|
+
else if (options.api === true)
|
|
8899
|
+
api = { port: defaultPort };
|
|
8900
|
+
else if (typeof options.api === "number")
|
|
8901
|
+
api = { port: options.api };
|
|
8902
|
+
if (typeof options.api === "object") {
|
|
8903
|
+
if (api) {
|
|
8904
|
+
if (options.api.port)
|
|
8905
|
+
api.port = options.api.port;
|
|
8906
|
+
if (options.api.strictPort)
|
|
8907
|
+
api.strictPort = options.api.strictPort;
|
|
8908
|
+
if (options.api.host)
|
|
8909
|
+
api.host = options.api.host;
|
|
8910
|
+
} else {
|
|
8911
|
+
api = { ...options.api };
|
|
8912
|
+
}
|
|
8913
|
+
}
|
|
8914
|
+
if (api) {
|
|
8915
|
+
if (!api.port && !api.middlewareMode)
|
|
8916
|
+
api.port = defaultPort;
|
|
8917
|
+
} else {
|
|
8918
|
+
api = { middlewareMode: true };
|
|
8919
|
+
}
|
|
8920
|
+
return api;
|
|
8921
|
+
}
|
|
8922
|
+
function resolveConfig(mode, options, viteConfig) {
|
|
8923
|
+
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;
|
|
8924
|
+
if (options.dom) {
|
|
8925
|
+
if (((_a = viteConfig.test) == null ? void 0 : _a.environment) != null && viteConfig.test.environment !== "happy-dom") {
|
|
8926
|
+
console.warn(
|
|
8927
|
+
c.yellow(
|
|
8928
|
+
`${c.inverse(c.yellow(" Vitest "))} Your config.test.environment ("${viteConfig.test.environment}") conflicts with --dom flag ("happy-dom"), ignoring "${viteConfig.test.environment}"`
|
|
8929
|
+
)
|
|
8930
|
+
);
|
|
8931
|
+
}
|
|
8932
|
+
options.environment = "happy-dom";
|
|
8933
|
+
}
|
|
8934
|
+
const resolved = {
|
|
8935
|
+
...configDefaults,
|
|
8936
|
+
...options,
|
|
8937
|
+
root: viteConfig.root,
|
|
8938
|
+
mode
|
|
8939
|
+
};
|
|
8940
|
+
resolved.inspect = Boolean(resolved.inspect);
|
|
8941
|
+
resolved.inspectBrk = Boolean(resolved.inspectBrk);
|
|
8942
|
+
if (viteConfig.base !== "/")
|
|
8943
|
+
resolved.base = viteConfig.base;
|
|
8944
|
+
if (options.shard) {
|
|
8945
|
+
if (resolved.watch)
|
|
8946
|
+
throw new Error("You cannot use --shard option with enabled watch");
|
|
8947
|
+
const [indexString, countString] = options.shard.split("/");
|
|
8948
|
+
const index = Math.abs(Number.parseInt(indexString, 10));
|
|
8949
|
+
const count = Math.abs(Number.parseInt(countString, 10));
|
|
8950
|
+
if (Number.isNaN(count) || count <= 0)
|
|
8951
|
+
throw new Error("--shard <count> must be a positive number");
|
|
8952
|
+
if (Number.isNaN(index) || index <= 0 || index > count)
|
|
8953
|
+
throw new Error("--shard <index> must be a positive number less then <count>");
|
|
8954
|
+
resolved.shard = { index, count };
|
|
8955
|
+
}
|
|
8956
|
+
if (resolved.inspect || resolved.inspectBrk) {
|
|
8957
|
+
const isSingleThread = resolved.pool === "threads" && ((_c = (_b = resolved.poolOptions) == null ? void 0 : _b.threads) == null ? void 0 : _c.singleThread);
|
|
8958
|
+
const isSingleFork = resolved.pool === "forks" && ((_e = (_d = resolved.poolOptions) == null ? void 0 : _d.forks) == null ? void 0 : _e.singleFork);
|
|
8959
|
+
if (!isSingleThread && !isSingleFork) {
|
|
8960
|
+
const inspectOption = `--inspect${resolved.inspectBrk ? "-brk" : ""}`;
|
|
8961
|
+
throw new Error(`You cannot use ${inspectOption} without "poolOptions.threads.singleThread" or "poolOptions.forks.singleFork"`);
|
|
8962
|
+
}
|
|
8963
|
+
}
|
|
8964
|
+
if (resolved.coverage.provider === "c8")
|
|
8965
|
+
throw new Error('"coverage.provider: c8" is not supported anymore. Use "coverage.provider: v8" instead');
|
|
8966
|
+
if (resolved.coverage.provider === "v8" && resolved.coverage.enabled && isBrowserEnabled(resolved))
|
|
8967
|
+
throw new Error("@vitest/coverage-v8 does not work with --browser. Use @vitest/coverage-istanbul instead");
|
|
8968
|
+
resolved.deps ?? (resolved.deps = {});
|
|
8969
|
+
(_f = resolved.deps).moduleDirectories ?? (_f.moduleDirectories = []);
|
|
8970
|
+
resolved.deps.moduleDirectories = resolved.deps.moduleDirectories.map((dir) => {
|
|
8971
|
+
if (!dir.startsWith("/"))
|
|
8972
|
+
dir = `/${dir}`;
|
|
8973
|
+
if (!dir.endsWith("/"))
|
|
8974
|
+
dir += "/";
|
|
8975
|
+
return normalize(dir);
|
|
8976
|
+
});
|
|
8977
|
+
if (!resolved.deps.moduleDirectories.includes("/node_modules/"))
|
|
8978
|
+
resolved.deps.moduleDirectories.push("/node_modules/");
|
|
8979
|
+
(_g = resolved.deps).optimizer ?? (_g.optimizer = {});
|
|
8980
|
+
(_h = resolved.deps.optimizer).ssr ?? (_h.ssr = {});
|
|
8981
|
+
(_i = resolved.deps.optimizer.ssr).enabled ?? (_i.enabled = true);
|
|
8982
|
+
(_j = resolved.deps.optimizer).web ?? (_j.web = {});
|
|
8983
|
+
(_k = resolved.deps.optimizer.web).enabled ?? (_k.enabled = true);
|
|
8984
|
+
(_l = resolved.deps).web ?? (_l.web = {});
|
|
8985
|
+
(_m = resolved.deps.web).transformAssets ?? (_m.transformAssets = true);
|
|
8986
|
+
(_n = resolved.deps.web).transformCss ?? (_n.transformCss = true);
|
|
8987
|
+
(_o = resolved.deps.web).transformGlobPattern ?? (_o.transformGlobPattern = []);
|
|
8988
|
+
resolved.server ?? (resolved.server = {});
|
|
8989
|
+
(_p = resolved.server).deps ?? (_p.deps = {});
|
|
8990
|
+
const deprecatedDepsOptions = ["inline", "external", "fallbackCJS"];
|
|
8991
|
+
deprecatedDepsOptions.forEach((option) => {
|
|
8992
|
+
if (resolved.deps[option] === void 0)
|
|
8993
|
+
return;
|
|
8994
|
+
if (option === "fallbackCJS") {
|
|
8995
|
+
console.warn(c.yellow(`${c.inverse(c.yellow(" Vitest "))} "deps.${option}" is deprecated. Use "server.deps.${option}" instead`));
|
|
8996
|
+
} else {
|
|
8997
|
+
const transformMode = resolved.environment === "happy-dom" || resolved.environment === "jsdom" ? "web" : "ssr";
|
|
8998
|
+
console.warn(
|
|
8999
|
+
c.yellow(
|
|
9000
|
+
`${c.inverse(c.yellow(" Vitest "))} "deps.${option}" is deprecated. If you rely on vite-node directly, use "server.deps.${option}" instead. Otherwise, consider using "deps.optimizer.${transformMode}.${option === "external" ? "exclude" : "include"}"`
|
|
9001
|
+
)
|
|
9002
|
+
);
|
|
9003
|
+
}
|
|
9004
|
+
if (resolved.server.deps[option] === void 0)
|
|
9005
|
+
resolved.server.deps[option] = resolved.deps[option];
|
|
9006
|
+
});
|
|
9007
|
+
if (resolved.server.deps.inline !== true) {
|
|
9008
|
+
const ssrOptions = viteConfig.ssr;
|
|
9009
|
+
if ((ssrOptions == null ? void 0 : ssrOptions.noExternal) === true && resolved.server.deps.inline == null) {
|
|
9010
|
+
resolved.server.deps.inline = true;
|
|
9011
|
+
} else {
|
|
9012
|
+
(_q = resolved.server.deps).inline ?? (_q.inline = []);
|
|
9013
|
+
resolved.server.deps.inline.push(...extraInlineDeps);
|
|
9014
|
+
}
|
|
9015
|
+
}
|
|
9016
|
+
(_r = resolved.server.deps).moduleDirectories ?? (_r.moduleDirectories = []);
|
|
9017
|
+
resolved.server.deps.moduleDirectories.push(...resolved.deps.moduleDirectories);
|
|
9018
|
+
if (resolved.runner) {
|
|
9019
|
+
resolved.runner = resolveModule(resolved.runner, { paths: [resolved.root] }) ?? resolve(resolved.root, resolved.runner);
|
|
9020
|
+
}
|
|
9021
|
+
resolved.testNamePattern = resolved.testNamePattern ? resolved.testNamePattern instanceof RegExp ? resolved.testNamePattern : new RegExp(resolved.testNamePattern) : void 0;
|
|
9022
|
+
if (resolved.snapshotFormat && "plugins" in resolved.snapshotFormat)
|
|
9023
|
+
resolved.snapshotFormat.plugins = [];
|
|
9024
|
+
const UPDATE_SNAPSHOT = resolved.update || process.env.UPDATE_SNAPSHOT;
|
|
9025
|
+
resolved.snapshotOptions = {
|
|
9026
|
+
snapshotFormat: resolved.snapshotFormat || {},
|
|
9027
|
+
updateSnapshot: isCI && !UPDATE_SNAPSHOT ? "none" : UPDATE_SNAPSHOT ? "all" : "new",
|
|
9028
|
+
resolveSnapshotPath: options.resolveSnapshotPath,
|
|
9029
|
+
// resolved inside the worker
|
|
9030
|
+
snapshotEnvironment: null
|
|
9031
|
+
};
|
|
9032
|
+
if (options.resolveSnapshotPath)
|
|
9033
|
+
delete resolved.resolveSnapshotPath;
|
|
9034
|
+
if (process.env.VITEST_MAX_THREADS) {
|
|
9035
|
+
resolved.poolOptions = {
|
|
9036
|
+
...resolved.poolOptions,
|
|
9037
|
+
threads: {
|
|
9038
|
+
...(_s = resolved.poolOptions) == null ? void 0 : _s.threads,
|
|
9039
|
+
maxThreads: Number.parseInt(process.env.VITEST_MAX_THREADS)
|
|
9040
|
+
},
|
|
9041
|
+
vmThreads: {
|
|
9042
|
+
...(_t = resolved.poolOptions) == null ? void 0 : _t.vmThreads,
|
|
9043
|
+
maxThreads: Number.parseInt(process.env.VITEST_MAX_THREADS)
|
|
9044
|
+
}
|
|
9045
|
+
};
|
|
9046
|
+
}
|
|
9047
|
+
if (process.env.VITEST_MIN_THREADS) {
|
|
9048
|
+
resolved.poolOptions = {
|
|
9049
|
+
...resolved.poolOptions,
|
|
9050
|
+
threads: {
|
|
9051
|
+
...(_u = resolved.poolOptions) == null ? void 0 : _u.threads,
|
|
9052
|
+
minThreads: Number.parseInt(process.env.VITEST_MIN_THREADS)
|
|
9053
|
+
},
|
|
9054
|
+
vmThreads: {
|
|
9055
|
+
...(_v = resolved.poolOptions) == null ? void 0 : _v.vmThreads,
|
|
9056
|
+
minThreads: Number.parseInt(process.env.VITEST_MIN_THREADS)
|
|
9057
|
+
}
|
|
9058
|
+
};
|
|
9059
|
+
}
|
|
9060
|
+
if (process.env.VITEST_MAX_FORKS) {
|
|
9061
|
+
resolved.poolOptions = {
|
|
9062
|
+
...resolved.poolOptions,
|
|
9063
|
+
forks: {
|
|
9064
|
+
...(_w = resolved.poolOptions) == null ? void 0 : _w.forks,
|
|
9065
|
+
maxForks: Number.parseInt(process.env.VITEST_MAX_FORKS)
|
|
9066
|
+
}
|
|
9067
|
+
};
|
|
9068
|
+
}
|
|
9069
|
+
if (process.env.VITEST_MIN_FORKS) {
|
|
9070
|
+
resolved.poolOptions = {
|
|
9071
|
+
...resolved.poolOptions,
|
|
9072
|
+
forks: {
|
|
9073
|
+
...(_x = resolved.poolOptions) == null ? void 0 : _x.forks,
|
|
9074
|
+
minForks: Number.parseInt(process.env.VITEST_MIN_FORKS)
|
|
9075
|
+
}
|
|
9076
|
+
};
|
|
9077
|
+
}
|
|
9078
|
+
if (mode === "benchmark") {
|
|
9079
|
+
resolved.benchmark = {
|
|
9080
|
+
...benchmarkConfigDefaults,
|
|
9081
|
+
...resolved.benchmark
|
|
9082
|
+
};
|
|
9083
|
+
resolved.coverage.enabled = false;
|
|
9084
|
+
resolved.include = resolved.benchmark.include;
|
|
9085
|
+
resolved.exclude = resolved.benchmark.exclude;
|
|
9086
|
+
resolved.includeSource = resolved.benchmark.includeSource;
|
|
9087
|
+
const reporters = Array.from(/* @__PURE__ */ new Set([
|
|
9088
|
+
...toArray(resolved.benchmark.reporters),
|
|
9089
|
+
// @ts-expect-error reporter is CLI flag
|
|
9090
|
+
...toArray(options.reporter)
|
|
9091
|
+
])).filter(Boolean);
|
|
9092
|
+
if (reporters.length)
|
|
9093
|
+
resolved.benchmark.reporters = reporters;
|
|
9094
|
+
else
|
|
9095
|
+
resolved.benchmark.reporters = ["default"];
|
|
9096
|
+
if (options.outputFile)
|
|
9097
|
+
resolved.benchmark.outputFile = options.outputFile;
|
|
9098
|
+
}
|
|
9099
|
+
resolved.setupFiles = toArray(resolved.setupFiles || []).map(
|
|
9100
|
+
(file) => normalize(
|
|
9101
|
+
resolveModule(file, { paths: [resolved.root] }) ?? resolve(resolved.root, file)
|
|
9102
|
+
)
|
|
9103
|
+
);
|
|
9104
|
+
resolved.coverage.exclude.push(...resolved.setupFiles.map((file) => `${resolved.coverage.allowExternal ? "**/" : ""}${relative(resolved.root, file)}`));
|
|
9105
|
+
resolved.forceRerunTriggers = [
|
|
9106
|
+
...resolved.forceRerunTriggers,
|
|
9107
|
+
...resolved.setupFiles
|
|
9108
|
+
];
|
|
9109
|
+
if (resolved.diff) {
|
|
9110
|
+
resolved.diff = normalize(
|
|
9111
|
+
resolveModule(resolved.diff, { paths: [resolved.root] }) ?? resolve(resolved.root, resolved.diff)
|
|
9112
|
+
);
|
|
9113
|
+
resolved.forceRerunTriggers.push(resolved.diff);
|
|
9114
|
+
}
|
|
9115
|
+
resolved.api = resolveApiServerConfig(options);
|
|
9116
|
+
if (options.related)
|
|
9117
|
+
resolved.related = toArray(options.related).map((file) => resolve(resolved.root, file));
|
|
9118
|
+
if (mode !== "benchmark") {
|
|
9119
|
+
const cliReporters = toArray(resolved.reporter || []).map((reporter) => {
|
|
9120
|
+
if (/^\.\.?\//.test(reporter))
|
|
9121
|
+
return resolve(process.cwd(), reporter);
|
|
9122
|
+
return reporter;
|
|
9123
|
+
});
|
|
9124
|
+
const reporters = cliReporters.length ? cliReporters : resolved.reporters;
|
|
9125
|
+
resolved.reporters = Array.from(new Set(toArray(reporters))).filter(Boolean);
|
|
9126
|
+
}
|
|
9127
|
+
if (!resolved.reporters.length)
|
|
9128
|
+
resolved.reporters.push("default");
|
|
9129
|
+
if (resolved.changed)
|
|
9130
|
+
resolved.passWithNoTests ?? (resolved.passWithNoTests = true);
|
|
9131
|
+
resolved.css ?? (resolved.css = {});
|
|
9132
|
+
if (typeof resolved.css === "object") {
|
|
9133
|
+
(_y = resolved.css).modules ?? (_y.modules = {});
|
|
9134
|
+
(_z = resolved.css.modules).classNameStrategy ?? (_z.classNameStrategy = "stable");
|
|
9135
|
+
}
|
|
9136
|
+
resolved.cache ?? (resolved.cache = { dir: "" });
|
|
9137
|
+
if (resolved.cache)
|
|
9138
|
+
resolved.cache.dir = VitestCache.resolveCacheDir(resolved.root, resolved.cache.dir, resolved.name);
|
|
9139
|
+
resolved.sequence ?? (resolved.sequence = {});
|
|
9140
|
+
if (!((_A = resolved.sequence) == null ? void 0 : _A.sequencer)) {
|
|
9141
|
+
resolved.sequence.sequencer = resolved.sequence.shuffle ? RandomSequencer : BaseSequencer;
|
|
9142
|
+
}
|
|
9143
|
+
(_B = resolved.sequence).hooks ?? (_B.hooks = "parallel");
|
|
9144
|
+
if (resolved.sequence.sequencer === RandomSequencer)
|
|
9145
|
+
(_C = resolved.sequence).seed ?? (_C.seed = Date.now());
|
|
9146
|
+
resolved.typecheck = {
|
|
9147
|
+
...configDefaults.typecheck,
|
|
9148
|
+
...resolved.typecheck
|
|
9149
|
+
};
|
|
9150
|
+
resolved.environmentMatchGlobs = (resolved.environmentMatchGlobs || []).map((i) => [resolve(resolved.root, i[0]), i[1]]);
|
|
9151
|
+
resolved.typecheck ?? (resolved.typecheck = {});
|
|
9152
|
+
(_D = resolved.typecheck).enabled ?? (_D.enabled = false);
|
|
9153
|
+
if (resolved.typecheck.enabled)
|
|
9154
|
+
console.warn(c.yellow("Testing types with tsc and vue-tsc is an experimental feature.\nBreaking changes might not follow semver, please pin Vitest's version when using it."));
|
|
9155
|
+
resolved.browser ?? (resolved.browser = {});
|
|
9156
|
+
(_E = resolved.browser).enabled ?? (_E.enabled = false);
|
|
9157
|
+
(_F = resolved.browser).headless ?? (_F.headless = isCI);
|
|
9158
|
+
(_G = resolved.browser).slowHijackESM ?? (_G.slowHijackESM = true);
|
|
9159
|
+
(_H = resolved.browser).isolate ?? (_H.isolate = true);
|
|
9160
|
+
resolved.browser.api = resolveApiServerConfig(resolved.browser) || {
|
|
9161
|
+
port: defaultBrowserPort
|
|
9162
|
+
};
|
|
9163
|
+
resolved.testTransformMode ?? (resolved.testTransformMode = {});
|
|
9164
|
+
return resolved;
|
|
9165
|
+
}
|
|
9166
|
+
function isBrowserEnabled(config) {
|
|
9167
|
+
var _a;
|
|
9168
|
+
return Boolean((_a = config.browser) == null ? void 0 : _a.enabled);
|
|
9169
|
+
}
|
|
9170
|
+
|
|
9171
|
+
const ESC$1 = '\u001B[';
|
|
9172
|
+
const OSC = '\u001B]';
|
|
9173
|
+
const BEL = '\u0007';
|
|
9174
|
+
const SEP = ';';
|
|
9175
|
+
const isTerminalApp = process.env.TERM_PROGRAM === 'Apple_Terminal';
|
|
9176
|
+
|
|
9177
|
+
const ansiEscapes = {};
|
|
9178
|
+
|
|
9179
|
+
ansiEscapes.cursorTo = (x, y) => {
|
|
9180
|
+
if (typeof x !== 'number') {
|
|
9181
|
+
throw new TypeError('The `x` argument is required');
|
|
9182
|
+
}
|
|
9183
|
+
|
|
9184
|
+
if (typeof y !== 'number') {
|
|
9185
|
+
return ESC$1 + (x + 1) + 'G';
|
|
9186
|
+
}
|
|
9187
|
+
|
|
9188
|
+
return ESC$1 + (y + 1) + ';' + (x + 1) + 'H';
|
|
9189
|
+
};
|
|
9190
|
+
|
|
9191
|
+
ansiEscapes.cursorMove = (x, y) => {
|
|
9192
|
+
if (typeof x !== 'number') {
|
|
9193
|
+
throw new TypeError('The `x` argument is required');
|
|
8947
9194
|
}
|
|
8948
9195
|
|
|
8949
9196
|
let returnValue = '';
|
|
8950
|
-
let escapeCode;
|
|
8951
|
-
let escapeUrl;
|
|
8952
9197
|
|
|
8953
|
-
|
|
8954
|
-
|
|
9198
|
+
if (x < 0) {
|
|
9199
|
+
returnValue += ESC$1 + (-x) + 'D';
|
|
9200
|
+
} else if (x > 0) {
|
|
9201
|
+
returnValue += ESC$1 + x + 'C';
|
|
9202
|
+
}
|
|
8955
9203
|
|
|
8956
|
-
|
|
8957
|
-
|
|
8958
|
-
|
|
8959
|
-
|
|
9204
|
+
if (y < 0) {
|
|
9205
|
+
returnValue += ESC$1 + (-y) + 'A';
|
|
9206
|
+
} else if (y > 0) {
|
|
9207
|
+
returnValue += ESC$1 + y + 'B';
|
|
9208
|
+
}
|
|
8960
9209
|
|
|
8961
|
-
|
|
9210
|
+
return returnValue;
|
|
9211
|
+
};
|
|
8962
9212
|
|
|
8963
|
-
|
|
8964
|
-
|
|
8965
|
-
|
|
8966
|
-
|
|
8967
|
-
rowLength = 0;
|
|
8968
|
-
}
|
|
9213
|
+
ansiEscapes.cursorUp = (count = 1) => ESC$1 + count + 'A';
|
|
9214
|
+
ansiEscapes.cursorDown = (count = 1) => ESC$1 + count + 'B';
|
|
9215
|
+
ansiEscapes.cursorForward = (count = 1) => ESC$1 + count + 'C';
|
|
9216
|
+
ansiEscapes.cursorBackward = (count = 1) => ESC$1 + count + 'D';
|
|
8969
9217
|
|
|
8970
|
-
|
|
8971
|
-
|
|
8972
|
-
|
|
8973
|
-
|
|
8974
|
-
|
|
9218
|
+
ansiEscapes.cursorLeft = ESC$1 + 'G';
|
|
9219
|
+
ansiEscapes.cursorSavePosition = isTerminalApp ? '\u001B7' : ESC$1 + 's';
|
|
9220
|
+
ansiEscapes.cursorRestorePosition = isTerminalApp ? '\u001B8' : ESC$1 + 'u';
|
|
9221
|
+
ansiEscapes.cursorGetPosition = ESC$1 + '6n';
|
|
9222
|
+
ansiEscapes.cursorNextLine = ESC$1 + 'E';
|
|
9223
|
+
ansiEscapes.cursorPrevLine = ESC$1 + 'F';
|
|
9224
|
+
ansiEscapes.cursorHide = ESC$1 + '?25l';
|
|
9225
|
+
ansiEscapes.cursorShow = ESC$1 + '?25h';
|
|
8975
9226
|
|
|
8976
|
-
|
|
8977
|
-
|
|
8978
|
-
|
|
8979
|
-
|
|
8980
|
-
|
|
8981
|
-
|
|
8982
|
-
|
|
8983
|
-
|
|
9227
|
+
ansiEscapes.eraseLines = count => {
|
|
9228
|
+
let clear = '';
|
|
9229
|
+
|
|
9230
|
+
for (let i = 0; i < count; i++) {
|
|
9231
|
+
clear += ansiEscapes.eraseLine + (i < count - 1 ? ansiEscapes.cursorUp() : '');
|
|
9232
|
+
}
|
|
9233
|
+
|
|
9234
|
+
if (count) {
|
|
9235
|
+
clear += ansiEscapes.cursorLeft;
|
|
9236
|
+
}
|
|
9237
|
+
|
|
9238
|
+
return clear;
|
|
9239
|
+
};
|
|
9240
|
+
|
|
9241
|
+
ansiEscapes.eraseEndLine = ESC$1 + 'K';
|
|
9242
|
+
ansiEscapes.eraseStartLine = ESC$1 + '1K';
|
|
9243
|
+
ansiEscapes.eraseLine = ESC$1 + '2K';
|
|
9244
|
+
ansiEscapes.eraseDown = ESC$1 + 'J';
|
|
9245
|
+
ansiEscapes.eraseUp = ESC$1 + '1J';
|
|
9246
|
+
ansiEscapes.eraseScreen = ESC$1 + '2J';
|
|
9247
|
+
ansiEscapes.scrollUp = ESC$1 + 'S';
|
|
9248
|
+
ansiEscapes.scrollDown = ESC$1 + 'T';
|
|
9249
|
+
|
|
9250
|
+
ansiEscapes.clearScreen = '\u001Bc';
|
|
9251
|
+
|
|
9252
|
+
ansiEscapes.clearTerminal = process.platform === 'win32' ?
|
|
9253
|
+
`${ansiEscapes.eraseScreen}${ESC$1}0f` :
|
|
9254
|
+
// 1. Erases the screen (Only done in case `2` is not supported)
|
|
9255
|
+
// 2. Erases the whole screen including scrollback buffer
|
|
9256
|
+
// 3. Moves cursor to the top-left position
|
|
9257
|
+
// More info: https://www.real-world-systems.com/docs/ANSIcode.html
|
|
9258
|
+
`${ansiEscapes.eraseScreen}${ESC$1}3J${ESC$1}H`;
|
|
9259
|
+
|
|
9260
|
+
ansiEscapes.beep = BEL;
|
|
9261
|
+
|
|
9262
|
+
ansiEscapes.link = (text, url) => {
|
|
9263
|
+
return [
|
|
9264
|
+
OSC,
|
|
9265
|
+
'8',
|
|
9266
|
+
SEP,
|
|
9267
|
+
SEP,
|
|
9268
|
+
url,
|
|
9269
|
+
BEL,
|
|
9270
|
+
text,
|
|
9271
|
+
OSC,
|
|
9272
|
+
'8',
|
|
9273
|
+
SEP,
|
|
9274
|
+
SEP,
|
|
9275
|
+
BEL
|
|
9276
|
+
].join('');
|
|
9277
|
+
};
|
|
9278
|
+
|
|
9279
|
+
ansiEscapes.image = (buffer, options = {}) => {
|
|
9280
|
+
let returnValue = `${OSC}1337;File=inline=1`;
|
|
9281
|
+
|
|
9282
|
+
if (options.width) {
|
|
9283
|
+
returnValue += `;width=${options.width}`;
|
|
9284
|
+
}
|
|
9285
|
+
|
|
9286
|
+
if (options.height) {
|
|
9287
|
+
returnValue += `;height=${options.height}`;
|
|
9288
|
+
}
|
|
9289
|
+
|
|
9290
|
+
if (options.preserveAspectRatio === false) {
|
|
9291
|
+
returnValue += ';preserveAspectRatio=0';
|
|
9292
|
+
}
|
|
9293
|
+
|
|
9294
|
+
return returnValue + ':' + buffer.toString('base64') + BEL;
|
|
9295
|
+
};
|
|
9296
|
+
|
|
9297
|
+
ansiEscapes.iTerm = {
|
|
9298
|
+
setCwd: (cwd = process.cwd()) => `${OSC}50;CurrentDir=${cwd}${BEL}`,
|
|
9299
|
+
|
|
9300
|
+
annotation: (message, options = {}) => {
|
|
9301
|
+
let returnValue = `${OSC}1337;`;
|
|
8984
9302
|
|
|
8985
|
-
|
|
8986
|
-
|
|
9303
|
+
const hasX = typeof options.x !== 'undefined';
|
|
9304
|
+
const hasY = typeof options.y !== 'undefined';
|
|
9305
|
+
if ((hasX || hasY) && !(hasX && hasY && typeof options.length !== 'undefined')) {
|
|
9306
|
+
throw new Error('`x`, `y` and `length` must be defined when `x` or `y` is defined');
|
|
8987
9307
|
}
|
|
8988
9308
|
|
|
8989
|
-
|
|
8990
|
-
if (options.wordWrap === false && rowLength < columns) {
|
|
8991
|
-
wrapWord(rows, word, columns);
|
|
8992
|
-
continue;
|
|
8993
|
-
}
|
|
9309
|
+
message = message.replace(/\|/g, '');
|
|
8994
9310
|
|
|
8995
|
-
|
|
8996
|
-
}
|
|
9311
|
+
returnValue += options.isHidden ? 'AddHiddenAnnotation=' : 'AddAnnotation=';
|
|
8997
9312
|
|
|
8998
|
-
if (
|
|
8999
|
-
|
|
9000
|
-
|
|
9313
|
+
if (options.length > 0) {
|
|
9314
|
+
returnValue +=
|
|
9315
|
+
(hasX ?
|
|
9316
|
+
[message, options.length, options.x, options.y] :
|
|
9317
|
+
[options.length, message]).join('|');
|
|
9318
|
+
} else {
|
|
9319
|
+
returnValue += message;
|
|
9001
9320
|
}
|
|
9002
9321
|
|
|
9003
|
-
|
|
9322
|
+
return returnValue + BEL;
|
|
9004
9323
|
}
|
|
9324
|
+
};
|
|
9005
9325
|
|
|
9006
|
-
|
|
9007
|
-
|
|
9326
|
+
var onetime$2 = {exports: {}};
|
|
9327
|
+
|
|
9328
|
+
var mimicFn$2 = {exports: {}};
|
|
9329
|
+
|
|
9330
|
+
const mimicFn$1 = (to, from) => {
|
|
9331
|
+
for (const prop of Reflect.ownKeys(from)) {
|
|
9332
|
+
Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(from, prop));
|
|
9008
9333
|
}
|
|
9009
9334
|
|
|
9010
|
-
|
|
9335
|
+
return to;
|
|
9336
|
+
};
|
|
9011
9337
|
|
|
9012
|
-
|
|
9013
|
-
|
|
9338
|
+
mimicFn$2.exports = mimicFn$1;
|
|
9339
|
+
// TODO: Remove this for the next major release
|
|
9340
|
+
mimicFn$2.exports.default = mimicFn$1;
|
|
9014
9341
|
|
|
9015
|
-
|
|
9016
|
-
const {groups} = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`).exec(pre.slice(index).join('')) || {groups: {}};
|
|
9017
|
-
if (groups.code !== undefined) {
|
|
9018
|
-
const code = Number.parseFloat(groups.code);
|
|
9019
|
-
escapeCode = code === END_CODE ? undefined : code;
|
|
9020
|
-
} else if (groups.uri !== undefined) {
|
|
9021
|
-
escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
|
|
9022
|
-
}
|
|
9023
|
-
}
|
|
9342
|
+
var mimicFnExports = mimicFn$2.exports;
|
|
9024
9343
|
|
|
9025
|
-
|
|
9344
|
+
const mimicFn = mimicFnExports;
|
|
9026
9345
|
|
|
9027
|
-
|
|
9028
|
-
if (escapeUrl) {
|
|
9029
|
-
returnValue += wrapAnsiHyperlink('');
|
|
9030
|
-
}
|
|
9346
|
+
const calledFunctions = new WeakMap();
|
|
9031
9347
|
|
|
9032
|
-
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
if (escapeCode && code) {
|
|
9037
|
-
returnValue += wrapAnsiCode(escapeCode);
|
|
9038
|
-
}
|
|
9348
|
+
const onetime = (function_, options = {}) => {
|
|
9349
|
+
if (typeof function_ !== 'function') {
|
|
9350
|
+
throw new TypeError('Expected a function');
|
|
9351
|
+
}
|
|
9039
9352
|
|
|
9040
|
-
|
|
9041
|
-
|
|
9042
|
-
|
|
9353
|
+
let returnValue;
|
|
9354
|
+
let callCount = 0;
|
|
9355
|
+
const functionName = function_.displayName || function_.name || '<anonymous>';
|
|
9356
|
+
|
|
9357
|
+
const onetime = function (...arguments_) {
|
|
9358
|
+
calledFunctions.set(onetime, ++callCount);
|
|
9359
|
+
|
|
9360
|
+
if (callCount === 1) {
|
|
9361
|
+
returnValue = function_.apply(this, arguments_);
|
|
9362
|
+
function_ = null;
|
|
9363
|
+
} else if (options.throw === true) {
|
|
9364
|
+
throw new Error(`Function \`${functionName}\` can only be called once`);
|
|
9043
9365
|
}
|
|
9366
|
+
|
|
9367
|
+
return returnValue;
|
|
9368
|
+
};
|
|
9369
|
+
|
|
9370
|
+
mimicFn(onetime, function_);
|
|
9371
|
+
calledFunctions.set(onetime, callCount);
|
|
9372
|
+
|
|
9373
|
+
return onetime;
|
|
9374
|
+
};
|
|
9375
|
+
|
|
9376
|
+
onetime$2.exports = onetime;
|
|
9377
|
+
// TODO: Remove this for the next major release
|
|
9378
|
+
onetime$2.exports.default = onetime;
|
|
9379
|
+
|
|
9380
|
+
onetime$2.exports.callCount = function_ => {
|
|
9381
|
+
if (!calledFunctions.has(function_)) {
|
|
9382
|
+
throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
|
|
9044
9383
|
}
|
|
9045
9384
|
|
|
9046
|
-
return
|
|
9385
|
+
return calledFunctions.get(function_);
|
|
9047
9386
|
};
|
|
9048
9387
|
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
return String(string)
|
|
9052
|
-
.normalize()
|
|
9053
|
-
.replace(/\r\n/g, '\n')
|
|
9054
|
-
.split('\n')
|
|
9055
|
-
.map(line => exec(line, columns, options))
|
|
9056
|
-
.join('\n');
|
|
9057
|
-
}
|
|
9388
|
+
var onetimeExports = onetime$2.exports;
|
|
9389
|
+
var onetime$1 = /*@__PURE__*/getDefaultExportFromCjs(onetimeExports);
|
|
9058
9390
|
|
|
9059
|
-
const
|
|
9391
|
+
const restoreCursor = onetime$1(() => {
|
|
9392
|
+
signalExit(() => {
|
|
9393
|
+
process$1.stderr.write('\u001B[?25h');
|
|
9394
|
+
}, {alwaysLast: true});
|
|
9395
|
+
});
|
|
9060
9396
|
|
|
9061
|
-
|
|
9062
|
-
const {columns} = stream;
|
|
9397
|
+
let isHidden = false;
|
|
9063
9398
|
|
|
9064
|
-
|
|
9065
|
-
|
|
9399
|
+
const cliCursor = {};
|
|
9400
|
+
|
|
9401
|
+
cliCursor.show = (writableStream = process$1.stderr) => {
|
|
9402
|
+
if (!writableStream.isTTY) {
|
|
9403
|
+
return;
|
|
9066
9404
|
}
|
|
9067
9405
|
|
|
9068
|
-
|
|
9406
|
+
isHidden = false;
|
|
9407
|
+
writableStream.write('\u001B[?25h');
|
|
9069
9408
|
};
|
|
9070
9409
|
|
|
9071
|
-
|
|
9072
|
-
|
|
9073
|
-
|
|
9410
|
+
cliCursor.hide = (writableStream = process$1.stderr) => {
|
|
9411
|
+
if (!writableStream.isTTY) {
|
|
9412
|
+
return;
|
|
9413
|
+
}
|
|
9074
9414
|
|
|
9075
|
-
|
|
9076
|
-
|
|
9077
|
-
|
|
9415
|
+
restoreCursor();
|
|
9416
|
+
isHidden = true;
|
|
9417
|
+
writableStream.write('\u001B[?25l');
|
|
9418
|
+
};
|
|
9419
|
+
|
|
9420
|
+
cliCursor.toggle = (force, writableStream) => {
|
|
9421
|
+
if (force !== undefined) {
|
|
9422
|
+
isHidden = force;
|
|
9078
9423
|
}
|
|
9079
9424
|
|
|
9080
|
-
|
|
9081
|
-
|
|
9082
|
-
|
|
9083
|
-
|
|
9425
|
+
if (isHidden) {
|
|
9426
|
+
cliCursor.show(writableStream);
|
|
9427
|
+
} else {
|
|
9428
|
+
cliCursor.hide(writableStream);
|
|
9429
|
+
}
|
|
9084
9430
|
};
|
|
9085
9431
|
|
|
9086
|
-
|
|
9087
|
-
|
|
9088
|
-
|
|
9089
|
-
|
|
9432
|
+
const ESCAPES = new Set([
|
|
9433
|
+
'\u001B',
|
|
9434
|
+
'\u009B',
|
|
9435
|
+
]);
|
|
9090
9436
|
|
|
9091
|
-
|
|
9092
|
-
|
|
9093
|
-
|
|
9437
|
+
const END_CODE = 39;
|
|
9438
|
+
const ANSI_ESCAPE_BELL = '\u0007';
|
|
9439
|
+
const ANSI_CSI = '[';
|
|
9440
|
+
const ANSI_OSC = ']';
|
|
9441
|
+
const ANSI_SGR_TERMINATOR = 'm';
|
|
9442
|
+
const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
9443
|
+
|
|
9444
|
+
const wrapAnsiCode = code => `${ESCAPES.values().next().value}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
9445
|
+
const wrapAnsiHyperlink = uri => `${ESCAPES.values().next().value}${ANSI_ESCAPE_LINK}${uri}${ANSI_ESCAPE_BELL}`;
|
|
9446
|
+
|
|
9447
|
+
// Calculate the length of words split on ' ', ignoring
|
|
9448
|
+
// the extra characters added by ansi escape codes
|
|
9449
|
+
const wordLengths = string => string.split(' ').map(character => stringWidth(character));
|
|
9450
|
+
|
|
9451
|
+
// Wrap a long word across multiple rows
|
|
9452
|
+
// Ansi escape codes do not count towards length
|
|
9453
|
+
const wrapWord = (rows, word, columns) => {
|
|
9454
|
+
const characters = [...word];
|
|
9455
|
+
|
|
9456
|
+
let isInsideEscape = false;
|
|
9457
|
+
let isInsideLinkEscape = false;
|
|
9458
|
+
let visible = stringWidth(stripAnsi(rows[rows.length - 1]));
|
|
9459
|
+
|
|
9460
|
+
for (const [index, character] of characters.entries()) {
|
|
9461
|
+
const characterLength = stringWidth(character);
|
|
9462
|
+
|
|
9463
|
+
if (visible + characterLength <= columns) {
|
|
9464
|
+
rows[rows.length - 1] += character;
|
|
9465
|
+
} else {
|
|
9466
|
+
rows.push(character);
|
|
9467
|
+
visible = 0;
|
|
9094
9468
|
}
|
|
9095
9469
|
|
|
9096
|
-
|
|
9097
|
-
|
|
9098
|
-
|
|
9099
|
-
if (output === previousOutput && previousWidth === width) {
|
|
9100
|
-
return;
|
|
9470
|
+
if (ESCAPES.has(character)) {
|
|
9471
|
+
isInsideEscape = true;
|
|
9472
|
+
isInsideLinkEscape = characters.slice(index + 1).join('').startsWith(ANSI_ESCAPE_LINK);
|
|
9101
9473
|
}
|
|
9102
9474
|
|
|
9103
|
-
|
|
9104
|
-
|
|
9105
|
-
|
|
9106
|
-
|
|
9107
|
-
|
|
9108
|
-
|
|
9109
|
-
|
|
9110
|
-
|
|
9111
|
-
|
|
9112
|
-
};
|
|
9475
|
+
if (isInsideEscape) {
|
|
9476
|
+
if (isInsideLinkEscape) {
|
|
9477
|
+
if (character === ANSI_ESCAPE_BELL) {
|
|
9478
|
+
isInsideEscape = false;
|
|
9479
|
+
isInsideLinkEscape = false;
|
|
9480
|
+
}
|
|
9481
|
+
} else if (character === ANSI_SGR_TERMINATOR) {
|
|
9482
|
+
isInsideEscape = false;
|
|
9483
|
+
}
|
|
9113
9484
|
|
|
9114
|
-
|
|
9115
|
-
|
|
9116
|
-
previousOutput = '';
|
|
9117
|
-
previousWidth = getWidth(stream);
|
|
9118
|
-
previousLineCount = 0;
|
|
9119
|
-
};
|
|
9485
|
+
continue;
|
|
9486
|
+
}
|
|
9120
9487
|
|
|
9121
|
-
|
|
9122
|
-
previousOutput = '';
|
|
9123
|
-
previousWidth = getWidth(stream);
|
|
9124
|
-
previousLineCount = 0;
|
|
9488
|
+
visible += characterLength;
|
|
9125
9489
|
|
|
9126
|
-
if (
|
|
9127
|
-
|
|
9490
|
+
if (visible === columns && index < characters.length - 1) {
|
|
9491
|
+
rows.push('');
|
|
9492
|
+
visible = 0;
|
|
9128
9493
|
}
|
|
9129
|
-
}
|
|
9130
|
-
|
|
9131
|
-
return render;
|
|
9132
|
-
}
|
|
9494
|
+
}
|
|
9133
9495
|
|
|
9134
|
-
|
|
9496
|
+
// It's possible that the last row we copy over is only
|
|
9497
|
+
// ansi escape characters, handle this edge-case
|
|
9498
|
+
if (!visible && rows[rows.length - 1].length > 0 && rows.length > 1) {
|
|
9499
|
+
rows[rows.length - 2] += rows.pop();
|
|
9500
|
+
}
|
|
9501
|
+
};
|
|
9135
9502
|
|
|
9136
|
-
|
|
9503
|
+
// Trims spaces from a string ignoring invisible sequences
|
|
9504
|
+
const stringVisibleTrimSpacesRight = string => {
|
|
9505
|
+
const words = string.split(' ');
|
|
9506
|
+
let last = words.length;
|
|
9137
9507
|
|
|
9138
|
-
|
|
9508
|
+
while (last > 0) {
|
|
9509
|
+
if (stringWidth(words[last - 1]) > 0) {
|
|
9510
|
+
break;
|
|
9511
|
+
}
|
|
9139
9512
|
|
|
9140
|
-
|
|
9513
|
+
last--;
|
|
9514
|
+
}
|
|
9141
9515
|
|
|
9142
|
-
|
|
9143
|
-
|
|
9144
|
-
`),m++,L=n,c=14;switch(o){case 123:return n++,c=1;case 125:return n++,c=2;case 91:return n++,c=3;case 93:return n++,c=4;case 58:return n++,c=6;case 44:return n++,c=5;case 34:return n++,t=b(),c=10;case 47:const r=n-1;if(e.charCodeAt(n+1)===47){for(n+=2;n<i&&!F(e.charCodeAt(n));)n++;return t=e.substring(r,n),c=12}if(e.charCodeAt(n+1)===42){n+=2;const u=i-1;let E=!1;for(;n<u;){const v=e.charCodeAt(n);if(v===42&&e.charCodeAt(n+1)===47){n+=2,E=!0;break}n++,F(v)&&(v===13&&e.charCodeAt(n)===10&&n++,m++,L=n);}return E||(n++,T=1),t=e.substring(r,n),c=13}return t+=String.fromCharCode(o),n++,c=16;case 45:if(t+=String.fromCharCode(o),n++,n===i||!_(e.charCodeAt(n)))return c=16;case 48:case 49:case 50:case 51:case 52:case 53:case 54:case 55:case 56:case 57:return t+=w(),c=11;default:for(;n<i&&N(o);)n++,o=e.charCodeAt(n);if(l!==n){switch(t=e.substring(l,n),t){case"true":return c=8;case"false":return c=9;case"null":return c=7}return c=16}return t+=String.fromCharCode(o),n++,c=16}}function N(o){if(W(o)||F(o))return !1;switch(o){case 125:case 93:case 123:case 91:case 34:case 58:case 44:case 47:return !1}return !0}function h(){let o;do o=A();while(o>=12&&o<=15);return o}return {setPosition:j,getPosition:()=>n,scan:s?h:A,getToken:()=>c,getTokenValue:()=>t,getTokenOffset:()=>l,getTokenLength:()=>n-l,getTokenStartLine:()=>p,getTokenStartCharacter:()=>l-g,getTokenError:()=>T}}function W(e){return e===32||e===9}function F(e){return e===10||e===13}function _(e){return e>=48&&e<=57}var Z;(function(e){e[e.lineFeed=10]="lineFeed",e[e.carriageReturn=13]="carriageReturn",e[e.space=32]="space",e[e._0=48]="_0",e[e._1=49]="_1",e[e._2=50]="_2",e[e._3=51]="_3",e[e._4=52]="_4",e[e._5=53]="_5",e[e._6=54]="_6",e[e._7=55]="_7",e[e._8=56]="_8",e[e._9=57]="_9",e[e.a=97]="a",e[e.b=98]="b",e[e.c=99]="c",e[e.d=100]="d",e[e.e=101]="e",e[e.f=102]="f",e[e.g=103]="g",e[e.h=104]="h",e[e.i=105]="i",e[e.j=106]="j",e[e.k=107]="k",e[e.l=108]="l",e[e.m=109]="m",e[e.n=110]="n",e[e.o=111]="o",e[e.p=112]="p",e[e.q=113]="q",e[e.r=114]="r",e[e.s=115]="s",e[e.t=116]="t",e[e.u=117]="u",e[e.v=118]="v",e[e.w=119]="w",e[e.x=120]="x",e[e.y=121]="y",e[e.z=122]="z",e[e.A=65]="A",e[e.B=66]="B",e[e.C=67]="C",e[e.D=68]="D",e[e.E=69]="E",e[e.F=70]="F",e[e.G=71]="G",e[e.H=72]="H",e[e.I=73]="I",e[e.J=74]="J",e[e.K=75]="K",e[e.L=76]="L",e[e.M=77]="M",e[e.N=78]="N",e[e.O=79]="O",e[e.P=80]="P",e[e.Q=81]="Q",e[e.R=82]="R",e[e.S=83]="S",e[e.T=84]="T",e[e.U=85]="U",e[e.V=86]="V",e[e.W=87]="W",e[e.X=88]="X",e[e.Y=89]="Y",e[e.Z=90]="Z",e[e.asterisk=42]="asterisk",e[e.backslash=92]="backslash",e[e.closeBrace=125]="closeBrace",e[e.closeBracket=93]="closeBracket",e[e.colon=58]="colon",e[e.comma=44]="comma",e[e.dot=46]="dot",e[e.doubleQuote=34]="doubleQuote",e[e.minus=45]="minus",e[e.openBrace=123]="openBrace",e[e.openBracket=91]="openBracket",e[e.plus=43]="plus",e[e.slash=47]="slash",e[e.formFeed=12]="formFeed",e[e.tab=9]="tab";})(Z||(Z={}));var x;(function(e){e.DEFAULT={allowTrailingComma:!1};})(x||(x={}));function pe(e,s=[],i=x.DEFAULT){let n=null,t=[];const l=[];function c(p){Array.isArray(t)?t.push(p):n!==null&&(t[n]=p);}return ge(e,{onObjectBegin:()=>{const p={};c(p),l.push(t),t=p,n=null;},onObjectProperty:p=>{n=p;},onObjectEnd:()=>{t=l.pop();},onArrayBegin:()=>{const p=[];c(p),l.push(t),t=p,n=null;},onArrayEnd:()=>{t=l.pop();},onLiteralValue:c,onError:(p,L,g)=>{s.push({error:p,offset:L,length:g});}},i),t[0]}function ge(e,s,i=x.DEFAULT){const n=re(e,!1),t=[];function l(a){return a?()=>a(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function c(a){return a?()=>a(n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>t.slice()):()=>!0}function m(a){return a?O=>a(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter()):()=>!0}function p(a){return a?O=>a(O,n.getTokenOffset(),n.getTokenLength(),n.getTokenStartLine(),n.getTokenStartCharacter(),()=>t.slice()):()=>!0}const L=c(s.onObjectBegin),g=p(s.onObjectProperty),T=l(s.onObjectEnd),k=c(s.onArrayBegin),j=l(s.onArrayEnd),w=p(s.onLiteralValue),b=m(s.onSeparator),A=l(s.onComment),N=m(s.onError),h=i&&i.disallowComments,o=i&&i.allowTrailingComma;function r(){for(;;){const a=n.scan();switch(n.getTokenError()){case 4:u(14);break;case 5:u(15);break;case 3:u(13);break;case 1:h||u(11);break;case 2:u(12);break;case 6:u(16);break}switch(a){case 12:case 13:h?u(10):A();break;case 16:u(1);break;case 15:case 14:break;default:return a}}}function u(a,O=[],X=[]){if(N(a),O.length+X.length>0){let y=n.getToken();for(;y!==17;){if(O.indexOf(y)!==-1){r();break}else if(X.indexOf(y)!==-1)break;y=r();}}}function E(a){const O=n.getTokenValue();return a?w(O):(g(O),t.push(O)),r(),!0}function v(){switch(n.getToken()){case 11:const a=n.getTokenValue();let O=Number(a);isNaN(O)&&(u(2),O=0),w(O);break;case 7:w(null);break;case 8:w(!0);break;case 9:w(!1);break;default:return !1}return r(),!0}function oe(){return n.getToken()!==10?(u(3,[],[2,5]),!1):(E(!1),n.getToken()===6?(b(":"),r(),P()||u(4,[],[2,5])):u(5,[],[2,5]),t.pop(),!0)}function le(){L(),r();let a=!1;for(;n.getToken()!==2&&n.getToken()!==17;){if(n.getToken()===5){if(a||u(4,[],[]),b(","),r(),n.getToken()===2&&o)break}else a&&u(6,[],[]);oe()||u(4,[],[2,5]),a=!0;}return T(),n.getToken()!==2?u(7,[2],[]):r(),!0}function ce(){k(),r();let a=!0,O=!1;for(;n.getToken()!==4&&n.getToken()!==17;){if(n.getToken()===5){if(O||u(4,[],[]),b(","),r(),n.getToken()===4&&o)break}else O&&u(6,[],[]);a?(t.push(0),a=!1):t[t.length-1]++,P()||u(4,[],[4,5]),O=!0;}return j(),a||t.pop(),n.getToken()!==4?u(8,[4],[]):r(),!0}function P(){switch(n.getToken()){case 3:return ce();case 1:return le();case 10:return E(!0);default:return v()}}return r(),n.getToken()===17?i.allowEmptyContent?!0:(u(4,[],[]),!1):P()?(n.getToken()!==17&&u(9,[],[]),!0):(u(4,[],[]),!1)}var d;(function(e){e[e.None=0]="None",e[e.UnexpectedEndOfComment=1]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=2]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=3]="UnexpectedEndOfNumber",e[e.InvalidUnicode=4]="InvalidUnicode",e[e.InvalidEscapeCharacter=5]="InvalidEscapeCharacter",e[e.InvalidCharacter=6]="InvalidCharacter";})(d||(d={}));var q;(function(e){e[e.OpenBraceToken=1]="OpenBraceToken",e[e.CloseBraceToken=2]="CloseBraceToken",e[e.OpenBracketToken=3]="OpenBracketToken",e[e.CloseBracketToken=4]="CloseBracketToken",e[e.CommaToken=5]="CommaToken",e[e.ColonToken=6]="ColonToken",e[e.NullKeyword=7]="NullKeyword",e[e.TrueKeyword=8]="TrueKeyword",e[e.FalseKeyword=9]="FalseKeyword",e[e.StringLiteral=10]="StringLiteral",e[e.NumericLiteral=11]="NumericLiteral",e[e.LineCommentTrivia=12]="LineCommentTrivia",e[e.BlockCommentTrivia=13]="BlockCommentTrivia",e[e.LineBreakTrivia=14]="LineBreakTrivia",e[e.Trivia=15]="Trivia",e[e.Unknown=16]="Unknown",e[e.EOF=17]="EOF";})(q||(q={}));const ae=pe;var K;(function(e){e[e.InvalidSymbol=1]="InvalidSymbol",e[e.InvalidNumberFormat=2]="InvalidNumberFormat",e[e.PropertyNameExpected=3]="PropertyNameExpected",e[e.ValueExpected=4]="ValueExpected",e[e.ColonExpected=5]="ColonExpected",e[e.CommaExpected=6]="CommaExpected",e[e.CloseBraceExpected=7]="CloseBraceExpected",e[e.CloseBracketExpected=8]="CloseBracketExpected",e[e.EndOfFileExpected=9]="EndOfFileExpected",e[e.InvalidCommentToken=10]="InvalidCommentToken",e[e.UnexpectedEndOfComment=11]="UnexpectedEndOfComment",e[e.UnexpectedEndOfString=12]="UnexpectedEndOfString",e[e.UnexpectedEndOfNumber=13]="UnexpectedEndOfNumber",e[e.InvalidUnicode=14]="InvalidUnicode",e[e.InvalidEscapeCharacter=15]="InvalidEscapeCharacter",e[e.InvalidCharacter=16]="InvalidCharacter";})(K||(K={}));const C=e=>ae($.readFileSync(e,"utf8")),{existsSync:B}=$,me=()=>{const{findPnpApi:e}=ue;return e&&e(process.cwd())},J=(e,s,i)=>{let n="tsconfig.json";const t=C(e);if(t)if(!i&&t.exports)try{const[l]=v(t.exports,s,["require","types"]);n=l;}catch{return}else !s&&t.tsconfig&&(n=t.tsconfig);return f$1.join(e,"..",n)},M="package.json",R="tsconfig.json",ke=(e,s)=>{let i=e;if(e===".."&&(i=f$1.join(i,R)),e[0]==="."&&(i=f$1.resolve(s,i)),f$1.isAbsolute(i)){if(B(i)){if($.statSync(i).isFile())return i}else if(!i.endsWith(".json")){const k=`${i}.json`;if(B(k))return k}return}const[n,...t]=e.split("/"),l=n[0]==="@"?`${n}/${t.shift()}`:n,c=t.join("/"),m=me();if(m){const{resolveRequest:k}=m;try{if(l===e){const j=k(f$1.join(l,M),s);if(j){const w=J(j,c);if(w&&B(w))return w}}else {let j;try{j=k(e,s,{extensions:[".json"]});}catch{j=k(f$1.join(e,R),s);}if(j)return j}}catch{}}const p=Y(s,f$1.join("node_modules",l));if(!p||!$.statSync(p).isDirectory())return;const L=f$1.join(p,M);if(B(L)){const k=J(L,c);if(!k)return;if(B(k))return k}const g=f$1.join(p,c),T=g.endsWith(".json");if(!T){const k=`${g}.json`;if(B(k))return k}if(B(g)){if($.statSync(g).isDirectory()){const k=f$1.join(g,M);if(B(k)){const w=J(k,"",!0);if(w&&B(w))return w}const j=f$1.join(g,R);if(B(j))return j}else if(T)return g}},be=(e,s)=>{var i;const n=ke(e,s);if(!n)throw new Error(`File '${e}' not found.`);const t=G(n);if(delete t.references,(i=t.compilerOptions)!=null&&i.baseUrl){const{compilerOptions:l}=t;l.baseUrl=f$1.relative(s,f$1.join(f$1.dirname(n),l.baseUrl))||"./";}return t.files&&(t.files=t.files.map(l=>f$1.relative(s,f$1.join(f$1.dirname(n),l)))),t.include&&(t.include=t.include.map(l=>f$1.relative(s,f$1.join(f$1.dirname(n),l)))),t},G=e=>{let s;try{s=$.realpathSync(e);}catch{throw new Error(`Cannot resolve tsconfig at path: ${e}`)}const i=f$1.dirname(s);let n=C(s)||{};if(typeof n!="object")throw new SyntaxError(`Failed to parse tsconfig at: ${e}`);if(n.extends){const t=Array.isArray(n.extends)?n.extends:[n.extends];delete n.extends;for(const l of t.reverse()){const c=be(l,i),m={...c,...n,compilerOptions:{...c.compilerOptions,...n.compilerOptions}};c.watchOptions&&(m.watchOptions={...c.watchOptions,...n.watchOptions}),n=m;}}if(n.compilerOptions){const{compilerOptions:t}=n;if(t.baseUrl){const l=f$1.resolve(i,t.baseUrl),c=V(f$1.relative(i,l));t.baseUrl=c;}t.outDir&&(Array.isArray(n.exclude)||(n.exclude=[]),n.exclude.push(t.outDir),t.outDir=V(t.outDir));}else n.compilerOptions={};if(n.files&&(n.files=n.files.map(V)),n.include&&(n.include=n.include.map(U)),n.watchOptions){const{watchOptions:t}=n;t.excludeDirectories&&(t.excludeDirectories=t.excludeDirectories.map(l=>U(f$1.resolve(i,l))));}return n},Te=(e=process.cwd(),s="tsconfig.json")=>{const i=Y(U(e),s);if(!i)return null;const n=G(i);return {path:i,config:n}};f$1.posix;process.platform==="win32";
|
|
9516
|
+
if (last === words.length) {
|
|
9517
|
+
return string;
|
|
9518
|
+
}
|
|
9145
9519
|
|
|
9146
|
-
|
|
9147
|
-
|
|
9148
|
-
const errCodeRegExp = /error TS(?<errCode>\d+)/;
|
|
9149
|
-
async function makeTscErrorInfo(errInfo) {
|
|
9150
|
-
var _a;
|
|
9151
|
-
const [errFilePathPos = "", ...errMsgRawArr] = errInfo.split(":");
|
|
9152
|
-
if (!errFilePathPos || errMsgRawArr.length === 0 || errMsgRawArr.join("").length === 0)
|
|
9153
|
-
return ["unknown filepath", null];
|
|
9154
|
-
const errMsgRaw = errMsgRawArr.join("").trim();
|
|
9155
|
-
const [errFilePath, errPos] = errFilePathPos.slice(0, -1).split("(");
|
|
9156
|
-
if (!errFilePath || !errPos)
|
|
9157
|
-
return ["unknown filepath", null];
|
|
9158
|
-
const [errLine, errCol] = errPos.split(",");
|
|
9159
|
-
if (!errLine || !errCol)
|
|
9160
|
-
return [errFilePath, null];
|
|
9161
|
-
const execArr = errCodeRegExp.exec(errMsgRaw);
|
|
9162
|
-
if (!execArr)
|
|
9163
|
-
return [errFilePath, null];
|
|
9164
|
-
const errCodeStr = ((_a = execArr.groups) == null ? void 0 : _a.errCode) ?? "";
|
|
9165
|
-
if (!errCodeStr)
|
|
9166
|
-
return [errFilePath, null];
|
|
9167
|
-
const line = Number(errLine);
|
|
9168
|
-
const col = Number(errCol);
|
|
9169
|
-
const errCode = Number(errCodeStr);
|
|
9170
|
-
return [
|
|
9171
|
-
errFilePath,
|
|
9172
|
-
{
|
|
9173
|
-
filePath: errFilePath,
|
|
9174
|
-
errCode,
|
|
9175
|
-
line,
|
|
9176
|
-
column: col,
|
|
9177
|
-
errMsg: errMsgRaw.slice(`error TS${errCode} `.length)
|
|
9178
|
-
}
|
|
9179
|
-
];
|
|
9180
|
-
}
|
|
9181
|
-
async function getTsconfig(root, config) {
|
|
9182
|
-
const configName = config.tsconfig ? basename(config.tsconfig) : void 0;
|
|
9183
|
-
const configSearchPath = config.tsconfig ? dirname(resolve(root, config.tsconfig)) : root;
|
|
9184
|
-
const tsconfig = Te(configSearchPath, configName);
|
|
9185
|
-
if (!tsconfig)
|
|
9186
|
-
throw new Error("no tsconfig.json found");
|
|
9187
|
-
const tempConfigPath = join(dirname(tsconfig.path), "tsconfig.vitest-temp.json");
|
|
9188
|
-
try {
|
|
9189
|
-
const tmpTsConfig = { ...tsconfig.config };
|
|
9190
|
-
tmpTsConfig.compilerOptions = tmpTsConfig.compilerOptions || {};
|
|
9191
|
-
tmpTsConfig.compilerOptions.emitDeclarationOnly = false;
|
|
9192
|
-
tmpTsConfig.compilerOptions.incremental = true;
|
|
9193
|
-
tmpTsConfig.compilerOptions.tsBuildInfoFile = join(
|
|
9194
|
-
__dirname,
|
|
9195
|
-
"tsconfig.tmp.tsbuildinfo"
|
|
9196
|
-
);
|
|
9197
|
-
const tsconfigFinalContent = JSON.stringify(tmpTsConfig, null, 2);
|
|
9198
|
-
await writeFile(tempConfigPath, tsconfigFinalContent);
|
|
9199
|
-
return { path: tempConfigPath, config: tmpTsConfig };
|
|
9200
|
-
} catch (err) {
|
|
9201
|
-
throw new Error("failed to write tsconfig.temp.json", { cause: err });
|
|
9202
|
-
}
|
|
9203
|
-
}
|
|
9204
|
-
async function getRawErrsMapFromTsCompile(tscErrorStdout) {
|
|
9205
|
-
const rawErrsMap = /* @__PURE__ */ new Map();
|
|
9206
|
-
const infos = await Promise.all(
|
|
9207
|
-
tscErrorStdout.split(newLineRegExp).reduce((prev, next) => {
|
|
9208
|
-
if (!next)
|
|
9209
|
-
return prev;
|
|
9210
|
-
else if (!next.startsWith(" "))
|
|
9211
|
-
prev.push(next);
|
|
9212
|
-
else
|
|
9213
|
-
prev[prev.length - 1] += `
|
|
9214
|
-
${next}`;
|
|
9215
|
-
return prev;
|
|
9216
|
-
}, []).map((errInfoLine) => makeTscErrorInfo(errInfoLine))
|
|
9217
|
-
);
|
|
9218
|
-
infos.forEach(([errFilePath, errInfo]) => {
|
|
9219
|
-
var _a;
|
|
9220
|
-
if (!errInfo)
|
|
9221
|
-
return;
|
|
9222
|
-
if (!rawErrsMap.has(errFilePath))
|
|
9223
|
-
rawErrsMap.set(errFilePath, [errInfo]);
|
|
9224
|
-
else
|
|
9225
|
-
(_a = rawErrsMap.get(errFilePath)) == null ? void 0 : _a.push(errInfo);
|
|
9226
|
-
});
|
|
9227
|
-
return rawErrsMap;
|
|
9228
|
-
}
|
|
9520
|
+
return words.slice(0, last).join(' ') + words.slice(last).join('');
|
|
9521
|
+
};
|
|
9229
9522
|
|
|
9230
|
-
|
|
9231
|
-
|
|
9232
|
-
|
|
9233
|
-
|
|
9234
|
-
|
|
9235
|
-
|
|
9236
|
-
|
|
9237
|
-
|
|
9238
|
-
|
|
9239
|
-
column = 0;
|
|
9240
|
-
} else {
|
|
9241
|
-
column++;
|
|
9242
|
-
}
|
|
9243
|
-
}
|
|
9244
|
-
return map;
|
|
9245
|
-
}
|
|
9523
|
+
// The wrap-ansi module can be invoked in either 'hard' or 'soft' wrap mode
|
|
9524
|
+
//
|
|
9525
|
+
// 'hard' will never allow a string to take up more than columns characters
|
|
9526
|
+
//
|
|
9527
|
+
// 'soft' allows long words to expand past the column length
|
|
9528
|
+
const exec = (string, columns, options = {}) => {
|
|
9529
|
+
if (options.trim !== false && string.trim() === '') {
|
|
9530
|
+
return '';
|
|
9531
|
+
}
|
|
9246
9532
|
|
|
9247
|
-
|
|
9248
|
-
|
|
9249
|
-
|
|
9250
|
-
return null;
|
|
9251
|
-
const ast = parse$4(request.code, {
|
|
9252
|
-
ecmaVersion: "latest",
|
|
9253
|
-
allowAwaitOutsideFunction: true
|
|
9254
|
-
});
|
|
9255
|
-
const testFilepath = relative(ctx.config.root, filepath);
|
|
9256
|
-
const file = {
|
|
9257
|
-
filepath,
|
|
9258
|
-
type: "suite",
|
|
9259
|
-
id: generateHash(`${testFilepath}${ctx.config.name || ""}`),
|
|
9260
|
-
name: testFilepath,
|
|
9261
|
-
mode: "run",
|
|
9262
|
-
tasks: [],
|
|
9263
|
-
start: ast.start,
|
|
9264
|
-
end: ast.end,
|
|
9265
|
-
meta: { typecheck: true }
|
|
9266
|
-
};
|
|
9267
|
-
const definitions = [];
|
|
9268
|
-
const getName = (callee) => {
|
|
9269
|
-
var _a, _b, _c;
|
|
9270
|
-
if (!callee)
|
|
9271
|
-
return null;
|
|
9272
|
-
if (callee.type === "Identifier")
|
|
9273
|
-
return callee.name;
|
|
9274
|
-
if (callee.type === "MemberExpression") {
|
|
9275
|
-
if ((_b = (_a = callee.object) == null ? void 0 : _a.name) == null ? void 0 : _b.startsWith("__vite_ssr_"))
|
|
9276
|
-
return getName(callee.property);
|
|
9277
|
-
return getName((_c = callee.object) == null ? void 0 : _c.property);
|
|
9278
|
-
}
|
|
9279
|
-
return null;
|
|
9280
|
-
};
|
|
9281
|
-
ancestor(ast, {
|
|
9282
|
-
CallExpression(node) {
|
|
9283
|
-
var _a;
|
|
9284
|
-
const { callee } = node;
|
|
9285
|
-
const name = getName(callee);
|
|
9286
|
-
if (!name)
|
|
9287
|
-
return;
|
|
9288
|
-
if (!["it", "test", "describe", "suite"].includes(name))
|
|
9289
|
-
return;
|
|
9290
|
-
const { arguments: [{ value: message }] } = node;
|
|
9291
|
-
const property = (_a = callee == null ? void 0 : callee.property) == null ? void 0 : _a.name;
|
|
9292
|
-
let mode = !property || property === name ? "run" : property;
|
|
9293
|
-
if (!["run", "skip", "todo", "only", "skipIf", "runIf"].includes(mode))
|
|
9294
|
-
throw new Error(`${name}.${mode} syntax is not supported when testing types`);
|
|
9295
|
-
if (mode === "skipIf" || mode === "runIf")
|
|
9296
|
-
mode = "skip";
|
|
9297
|
-
definitions.push({
|
|
9298
|
-
start: node.start,
|
|
9299
|
-
end: node.end,
|
|
9300
|
-
name: message,
|
|
9301
|
-
type: name === "it" || name === "test" ? "test" : "suite",
|
|
9302
|
-
mode
|
|
9303
|
-
});
|
|
9304
|
-
}
|
|
9305
|
-
});
|
|
9306
|
-
let lastSuite = file;
|
|
9307
|
-
const updateLatestSuite = (index) => {
|
|
9308
|
-
const suite = lastSuite;
|
|
9309
|
-
while (lastSuite !== file && lastSuite.end < index)
|
|
9310
|
-
lastSuite = suite.suite;
|
|
9311
|
-
return lastSuite;
|
|
9312
|
-
};
|
|
9313
|
-
definitions.sort((a, b) => a.start - b.start).forEach((definition) => {
|
|
9314
|
-
const latestSuite = updateLatestSuite(definition.start);
|
|
9315
|
-
let mode = definition.mode;
|
|
9316
|
-
if (latestSuite.mode !== "run")
|
|
9317
|
-
mode = latestSuite.mode;
|
|
9318
|
-
if (definition.type === "suite") {
|
|
9319
|
-
const task2 = {
|
|
9320
|
-
type: definition.type,
|
|
9321
|
-
id: "",
|
|
9322
|
-
suite: latestSuite,
|
|
9323
|
-
file,
|
|
9324
|
-
tasks: [],
|
|
9325
|
-
mode,
|
|
9326
|
-
name: definition.name,
|
|
9327
|
-
end: definition.end,
|
|
9328
|
-
start: definition.start,
|
|
9329
|
-
meta: {
|
|
9330
|
-
typecheck: true
|
|
9331
|
-
}
|
|
9332
|
-
};
|
|
9333
|
-
definition.task = task2;
|
|
9334
|
-
latestSuite.tasks.push(task2);
|
|
9335
|
-
lastSuite = task2;
|
|
9336
|
-
return;
|
|
9337
|
-
}
|
|
9338
|
-
const task = {
|
|
9339
|
-
type: definition.type,
|
|
9340
|
-
id: "",
|
|
9341
|
-
suite: latestSuite,
|
|
9342
|
-
file,
|
|
9343
|
-
mode,
|
|
9344
|
-
context: {},
|
|
9345
|
-
// not used in typecheck
|
|
9346
|
-
name: definition.name,
|
|
9347
|
-
end: definition.end,
|
|
9348
|
-
start: definition.start,
|
|
9349
|
-
meta: {
|
|
9350
|
-
typecheck: true
|
|
9351
|
-
}
|
|
9352
|
-
};
|
|
9353
|
-
definition.task = task;
|
|
9354
|
-
latestSuite.tasks.push(task);
|
|
9355
|
-
});
|
|
9356
|
-
calculateSuiteHash(file);
|
|
9357
|
-
const hasOnly = someTasksAreOnly(file);
|
|
9358
|
-
interpretTaskModes(file, ctx.config.testNamePattern, hasOnly, false, ctx.config.allowOnly);
|
|
9359
|
-
return {
|
|
9360
|
-
file,
|
|
9361
|
-
parsed: request.code,
|
|
9362
|
-
filepath,
|
|
9363
|
-
map: request.map,
|
|
9364
|
-
definitions
|
|
9365
|
-
};
|
|
9366
|
-
}
|
|
9533
|
+
let returnValue = '';
|
|
9534
|
+
let escapeCode;
|
|
9535
|
+
let escapeUrl;
|
|
9367
9536
|
|
|
9368
|
-
|
|
9369
|
-
|
|
9370
|
-
|
|
9371
|
-
|
|
9372
|
-
|
|
9373
|
-
|
|
9374
|
-
|
|
9375
|
-
|
|
9376
|
-
|
|
9377
|
-
|
|
9378
|
-
|
|
9379
|
-
|
|
9380
|
-
|
|
9381
|
-
|
|
9382
|
-
|
|
9383
|
-
|
|
9384
|
-
|
|
9385
|
-
|
|
9386
|
-
|
|
9387
|
-
|
|
9388
|
-
|
|
9389
|
-
|
|
9390
|
-
|
|
9391
|
-
|
|
9392
|
-
|
|
9393
|
-
|
|
9394
|
-
|
|
9395
|
-
|
|
9396
|
-
|
|
9397
|
-
|
|
9398
|
-
|
|
9399
|
-
|
|
9400
|
-
|
|
9401
|
-
|
|
9402
|
-
|
|
9403
|
-
|
|
9404
|
-
|
|
9405
|
-
|
|
9406
|
-
|
|
9407
|
-
|
|
9408
|
-
|
|
9409
|
-
|
|
9410
|
-
|
|
9411
|
-
|
|
9412
|
-
|
|
9413
|
-
|
|
9414
|
-
|
|
9415
|
-
|
|
9416
|
-
|
|
9417
|
-
|
|
9418
|
-
|
|
9419
|
-
|
|
9420
|
-
|
|
9421
|
-
|
|
9422
|
-
|
|
9423
|
-
|
|
9424
|
-
|
|
9425
|
-
|
|
9426
|
-
|
|
9427
|
-
|
|
9428
|
-
|
|
9429
|
-
|
|
9430
|
-
|
|
9431
|
-
|
|
9432
|
-
|
|
9433
|
-
|
|
9434
|
-
|
|
9435
|
-
|
|
9436
|
-
|
|
9437
|
-
|
|
9438
|
-
|
|
9439
|
-
|
|
9440
|
-
|
|
9441
|
-
|
|
9442
|
-
|
|
9443
|
-
|
|
9444
|
-
|
|
9445
|
-
|
|
9446
|
-
|
|
9447
|
-
|
|
9448
|
-
|
|
9449
|
-
|
|
9450
|
-
|
|
9451
|
-
|
|
9452
|
-
|
|
9453
|
-
|
|
9454
|
-
|
|
9455
|
-
|
|
9456
|
-
|
|
9457
|
-
|
|
9458
|
-
|
|
9459
|
-
|
|
9460
|
-
|
|
9461
|
-
|
|
9462
|
-
|
|
9463
|
-
|
|
9464
|
-
|
|
9465
|
-
|
|
9466
|
-
|
|
9467
|
-
|
|
9468
|
-
|
|
9469
|
-
|
|
9470
|
-
|
|
9471
|
-
|
|
9472
|
-
|
|
9473
|
-
|
|
9474
|
-
|
|
9475
|
-
|
|
9476
|
-
|
|
9477
|
-
|
|
9478
|
-
|
|
9479
|
-
|
|
9480
|
-
|
|
9481
|
-
|
|
9482
|
-
|
|
9483
|
-
|
|
9484
|
-
|
|
9485
|
-
|
|
9486
|
-
|
|
9487
|
-
|
|
9488
|
-
|
|
9489
|
-
|
|
9490
|
-
|
|
9491
|
-
|
|
9492
|
-
|
|
9493
|
-
|
|
9494
|
-
|
|
9495
|
-
|
|
9496
|
-
|
|
9497
|
-
|
|
9498
|
-
|
|
9499
|
-
|
|
9500
|
-
|
|
9501
|
-
|
|
9502
|
-
|
|
9503
|
-
|
|
9504
|
-
|
|
9505
|
-
|
|
9506
|
-
|
|
9507
|
-
|
|
9508
|
-
|
|
9509
|
-
|
|
9510
|
-
|
|
9511
|
-
|
|
9512
|
-
|
|
9513
|
-
|
|
9514
|
-
|
|
9515
|
-
|
|
9516
|
-
|
|
9517
|
-
|
|
9518
|
-
|
|
9519
|
-
|
|
9520
|
-
|
|
9521
|
-
|
|
9522
|
-
|
|
9523
|
-
|
|
9524
|
-
|
|
9525
|
-
|
|
9526
|
-
|
|
9527
|
-
|
|
9528
|
-
|
|
9529
|
-
|
|
9530
|
-
|
|
9531
|
-
|
|
9532
|
-
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
|
|
9537
|
-
|
|
9538
|
-
|
|
9539
|
-
|
|
9540
|
-
|
|
9541
|
-
|
|
9542
|
-
|
|
9543
|
-
|
|
9544
|
-
|
|
9545
|
-
|
|
9546
|
-
|
|
9547
|
-
this.tempConfigPath = path;
|
|
9548
|
-
this.allowJs = typecheck.allowJs || config.allowJs || false;
|
|
9549
|
-
}
|
|
9550
|
-
getExitCode() {
|
|
9551
|
-
var _a;
|
|
9552
|
-
return ((_a = this.process) == null ? void 0 : _a.exitCode) != null && this.process.exitCode;
|
|
9553
|
-
}
|
|
9554
|
-
getOutput() {
|
|
9555
|
-
return this._output;
|
|
9556
|
-
}
|
|
9557
|
-
async start() {
|
|
9558
|
-
var _a, _b, _c;
|
|
9559
|
-
if (!this.tempConfigPath)
|
|
9560
|
-
throw new Error("tsconfig was not initialized");
|
|
9561
|
-
const { root, watch, typecheck } = this.ctx.config;
|
|
9562
|
-
const args = ["--noEmit", "--pretty", "false", "-p", this.tempConfigPath];
|
|
9563
|
-
if (watch)
|
|
9564
|
-
args.push("--watch");
|
|
9565
|
-
if (typecheck.allowJs)
|
|
9566
|
-
args.push("--allowJs", "--checkJs");
|
|
9567
|
-
this._output = "";
|
|
9568
|
-
const child = execa(typecheck.checker, args, {
|
|
9569
|
-
cwd: root,
|
|
9570
|
-
stdout: "pipe",
|
|
9571
|
-
reject: false
|
|
9572
|
-
});
|
|
9573
|
-
this.process = child;
|
|
9574
|
-
await ((_a = this._onParseStart) == null ? void 0 : _a.call(this));
|
|
9575
|
-
let rerunTriggered = false;
|
|
9576
|
-
(_b = child.stdout) == null ? void 0 : _b.on("data", (chunk) => {
|
|
9577
|
-
var _a2;
|
|
9578
|
-
this._output += chunk;
|
|
9579
|
-
if (!watch)
|
|
9580
|
-
return;
|
|
9581
|
-
if (this._output.includes("File change detected") && !rerunTriggered) {
|
|
9582
|
-
(_a2 = this._onWatcherRerun) == null ? void 0 : _a2.call(this);
|
|
9583
|
-
this._result.sourceErrors = [];
|
|
9584
|
-
this._result.files = [];
|
|
9585
|
-
this._tests = null;
|
|
9586
|
-
rerunTriggered = true;
|
|
9587
|
-
}
|
|
9588
|
-
if (/Found \w+ errors*. Watching for/.test(this._output)) {
|
|
9589
|
-
rerunTriggered = false;
|
|
9590
|
-
this.prepareResults(this._output).then((result) => {
|
|
9591
|
-
var _a3;
|
|
9592
|
-
this._result = result;
|
|
9593
|
-
(_a3 = this._onParseEnd) == null ? void 0 : _a3.call(this, result);
|
|
9594
|
-
});
|
|
9595
|
-
this._output = "";
|
|
9596
|
-
}
|
|
9597
|
-
});
|
|
9598
|
-
if (!watch) {
|
|
9599
|
-
await child;
|
|
9600
|
-
this._result = await this.prepareResults(this._output);
|
|
9601
|
-
await ((_c = this._onParseEnd) == null ? void 0 : _c.call(this, this._result));
|
|
9602
|
-
}
|
|
9603
|
-
}
|
|
9604
|
-
getResult() {
|
|
9605
|
-
return this._result;
|
|
9606
|
-
}
|
|
9607
|
-
getTestFiles() {
|
|
9608
|
-
return Object.values(this._tests || {}).map((i) => i.file);
|
|
9609
|
-
}
|
|
9610
|
-
getTestPacks() {
|
|
9611
|
-
return Object.values(this._tests || {}).map(({ file }) => getTasks(file)).flat().map((i) => [i.id, void 0, { typecheck: true }]);
|
|
9612
|
-
}
|
|
9537
|
+
const lengths = wordLengths(string);
|
|
9538
|
+
let rows = [''];
|
|
9539
|
+
|
|
9540
|
+
for (const [index, word] of string.split(' ').entries()) {
|
|
9541
|
+
if (options.trim !== false) {
|
|
9542
|
+
rows[rows.length - 1] = rows[rows.length - 1].trimStart();
|
|
9543
|
+
}
|
|
9544
|
+
|
|
9545
|
+
let rowLength = stringWidth(rows[rows.length - 1]);
|
|
9546
|
+
|
|
9547
|
+
if (index !== 0) {
|
|
9548
|
+
if (rowLength >= columns && (options.wordWrap === false || options.trim === false)) {
|
|
9549
|
+
// If we start with a new word but the current row length equals the length of the columns, add a new row
|
|
9550
|
+
rows.push('');
|
|
9551
|
+
rowLength = 0;
|
|
9552
|
+
}
|
|
9553
|
+
|
|
9554
|
+
if (rowLength > 0 || options.trim === false) {
|
|
9555
|
+
rows[rows.length - 1] += ' ';
|
|
9556
|
+
rowLength++;
|
|
9557
|
+
}
|
|
9558
|
+
}
|
|
9559
|
+
|
|
9560
|
+
// In 'hard' wrap mode, the length of a line is never allowed to extend past 'columns'
|
|
9561
|
+
if (options.hard && lengths[index] > columns) {
|
|
9562
|
+
const remainingColumns = (columns - rowLength);
|
|
9563
|
+
const breaksStartingThisLine = 1 + Math.floor((lengths[index] - remainingColumns - 1) / columns);
|
|
9564
|
+
const breaksStartingNextLine = Math.floor((lengths[index] - 1) / columns);
|
|
9565
|
+
if (breaksStartingNextLine < breaksStartingThisLine) {
|
|
9566
|
+
rows.push('');
|
|
9567
|
+
}
|
|
9568
|
+
|
|
9569
|
+
wrapWord(rows, word, columns);
|
|
9570
|
+
continue;
|
|
9571
|
+
}
|
|
9572
|
+
|
|
9573
|
+
if (rowLength + lengths[index] > columns && rowLength > 0 && lengths[index] > 0) {
|
|
9574
|
+
if (options.wordWrap === false && rowLength < columns) {
|
|
9575
|
+
wrapWord(rows, word, columns);
|
|
9576
|
+
continue;
|
|
9577
|
+
}
|
|
9578
|
+
|
|
9579
|
+
rows.push('');
|
|
9580
|
+
}
|
|
9581
|
+
|
|
9582
|
+
if (rowLength + lengths[index] > columns && options.wordWrap === false) {
|
|
9583
|
+
wrapWord(rows, word, columns);
|
|
9584
|
+
continue;
|
|
9585
|
+
}
|
|
9586
|
+
|
|
9587
|
+
rows[rows.length - 1] += word;
|
|
9588
|
+
}
|
|
9589
|
+
|
|
9590
|
+
if (options.trim !== false) {
|
|
9591
|
+
rows = rows.map(row => stringVisibleTrimSpacesRight(row));
|
|
9592
|
+
}
|
|
9593
|
+
|
|
9594
|
+
const pre = [...rows.join('\n')];
|
|
9595
|
+
|
|
9596
|
+
for (const [index, character] of pre.entries()) {
|
|
9597
|
+
returnValue += character;
|
|
9598
|
+
|
|
9599
|
+
if (ESCAPES.has(character)) {
|
|
9600
|
+
const {groups} = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`).exec(pre.slice(index).join('')) || {groups: {}};
|
|
9601
|
+
if (groups.code !== undefined) {
|
|
9602
|
+
const code = Number.parseFloat(groups.code);
|
|
9603
|
+
escapeCode = code === END_CODE ? undefined : code;
|
|
9604
|
+
} else if (groups.uri !== undefined) {
|
|
9605
|
+
escapeUrl = groups.uri.length === 0 ? undefined : groups.uri;
|
|
9606
|
+
}
|
|
9607
|
+
}
|
|
9608
|
+
|
|
9609
|
+
const code = ansiStyles.codes.get(Number(escapeCode));
|
|
9610
|
+
|
|
9611
|
+
if (pre[index + 1] === '\n') {
|
|
9612
|
+
if (escapeUrl) {
|
|
9613
|
+
returnValue += wrapAnsiHyperlink('');
|
|
9614
|
+
}
|
|
9615
|
+
|
|
9616
|
+
if (escapeCode && code) {
|
|
9617
|
+
returnValue += wrapAnsiCode(code);
|
|
9618
|
+
}
|
|
9619
|
+
} else if (character === '\n') {
|
|
9620
|
+
if (escapeCode && code) {
|
|
9621
|
+
returnValue += wrapAnsiCode(escapeCode);
|
|
9622
|
+
}
|
|
9623
|
+
|
|
9624
|
+
if (escapeUrl) {
|
|
9625
|
+
returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
9626
|
+
}
|
|
9627
|
+
}
|
|
9628
|
+
}
|
|
9629
|
+
|
|
9630
|
+
return returnValue;
|
|
9631
|
+
};
|
|
9632
|
+
|
|
9633
|
+
// For each newline, invoke the method separately
|
|
9634
|
+
function wrapAnsi(string, columns, options) {
|
|
9635
|
+
return String(string)
|
|
9636
|
+
.normalize()
|
|
9637
|
+
.replace(/\r\n/g, '\n')
|
|
9638
|
+
.split('\n')
|
|
9639
|
+
.map(line => exec(line, columns, options))
|
|
9640
|
+
.join('\n');
|
|
9641
|
+
}
|
|
9642
|
+
|
|
9643
|
+
const defaultTerminalHeight = 24;
|
|
9644
|
+
|
|
9645
|
+
const getWidth = stream => {
|
|
9646
|
+
const {columns} = stream;
|
|
9647
|
+
|
|
9648
|
+
if (!columns) {
|
|
9649
|
+
return 80;
|
|
9650
|
+
}
|
|
9651
|
+
|
|
9652
|
+
return columns;
|
|
9653
|
+
};
|
|
9654
|
+
|
|
9655
|
+
const fitToTerminalHeight = (stream, text) => {
|
|
9656
|
+
const terminalHeight = stream.rows || defaultTerminalHeight;
|
|
9657
|
+
const lines = text.split('\n');
|
|
9658
|
+
|
|
9659
|
+
const toRemove = lines.length - terminalHeight;
|
|
9660
|
+
if (toRemove <= 0) {
|
|
9661
|
+
return text;
|
|
9662
|
+
}
|
|
9663
|
+
|
|
9664
|
+
return sliceAnsi(
|
|
9665
|
+
text,
|
|
9666
|
+
stripAnsi(lines.slice(0, toRemove).join('\n')).length + 1,
|
|
9667
|
+
);
|
|
9668
|
+
};
|
|
9669
|
+
|
|
9670
|
+
function createLogUpdate(stream, {showCursor = false} = {}) {
|
|
9671
|
+
let previousLineCount = 0;
|
|
9672
|
+
let previousWidth = getWidth(stream);
|
|
9673
|
+
let previousOutput = '';
|
|
9674
|
+
|
|
9675
|
+
const render = (...arguments_) => {
|
|
9676
|
+
if (!showCursor) {
|
|
9677
|
+
cliCursor.hide();
|
|
9678
|
+
}
|
|
9679
|
+
|
|
9680
|
+
let output = arguments_.join(' ') + '\n';
|
|
9681
|
+
output = fitToTerminalHeight(stream, output);
|
|
9682
|
+
const width = getWidth(stream);
|
|
9683
|
+
if (output === previousOutput && previousWidth === width) {
|
|
9684
|
+
return;
|
|
9685
|
+
}
|
|
9686
|
+
|
|
9687
|
+
previousOutput = output;
|
|
9688
|
+
previousWidth = width;
|
|
9689
|
+
output = wrapAnsi(output, width, {
|
|
9690
|
+
trim: false,
|
|
9691
|
+
hard: true,
|
|
9692
|
+
wordWrap: false,
|
|
9693
|
+
});
|
|
9694
|
+
stream.write(ansiEscapes.eraseLines(previousLineCount) + output);
|
|
9695
|
+
previousLineCount = output.split('\n').length;
|
|
9696
|
+
};
|
|
9697
|
+
|
|
9698
|
+
render.clear = () => {
|
|
9699
|
+
stream.write(ansiEscapes.eraseLines(previousLineCount));
|
|
9700
|
+
previousOutput = '';
|
|
9701
|
+
previousWidth = getWidth(stream);
|
|
9702
|
+
previousLineCount = 0;
|
|
9703
|
+
};
|
|
9704
|
+
|
|
9705
|
+
render.done = () => {
|
|
9706
|
+
previousOutput = '';
|
|
9707
|
+
previousWidth = getWidth(stream);
|
|
9708
|
+
previousLineCount = 0;
|
|
9709
|
+
|
|
9710
|
+
if (!showCursor) {
|
|
9711
|
+
cliCursor.show();
|
|
9712
|
+
}
|
|
9713
|
+
};
|
|
9714
|
+
|
|
9715
|
+
return render;
|
|
9613
9716
|
}
|
|
9614
9717
|
|
|
9718
|
+
createLogUpdate(process$1.stdout);
|
|
9719
|
+
|
|
9720
|
+
createLogUpdate(process$1.stderr);
|
|
9721
|
+
|
|
9722
|
+
var version = "1.0.0-beta.3";
|
|
9723
|
+
|
|
9615
9724
|
async function printError(error, project, options) {
|
|
9616
9725
|
const { showCodeFrame = true, fullStack = false, type } = options;
|
|
9617
9726
|
const logger = options.logger;
|
|
@@ -9633,7 +9742,8 @@ async function printError(error, project, options) {
|
|
|
9633
9742
|
return printErrorMessage(e, logger);
|
|
9634
9743
|
const parserOptions = {
|
|
9635
9744
|
// only browser stack traces require remapping
|
|
9636
|
-
getSourceMap: (file) => project.getBrowserSourceMapModuleById(file)
|
|
9745
|
+
getSourceMap: (file) => project.getBrowserSourceMapModuleById(file),
|
|
9746
|
+
frameFilter: project.config.onStackTrace
|
|
9637
9747
|
};
|
|
9638
9748
|
if (fullStack)
|
|
9639
9749
|
parserOptions.ignoreStackEntries = [];
|
|
@@ -9892,10 +10002,21 @@ class Logger {
|
|
|
9892
10002
|
const comma = c.dim(", ");
|
|
9893
10003
|
if (filters == null ? void 0 : filters.length)
|
|
9894
10004
|
this.console.error(c.dim("filter: ") + c.yellow(filters.join(comma)));
|
|
9895
|
-
|
|
9896
|
-
|
|
9897
|
-
|
|
9898
|
-
|
|
10005
|
+
this.ctx.projects.forEach((project) => {
|
|
10006
|
+
const config2 = project.config;
|
|
10007
|
+
const name = project.getName();
|
|
10008
|
+
const output = project.isCore() || !name ? "" : `[${name}]`;
|
|
10009
|
+
if (output)
|
|
10010
|
+
this.console.error(c.bgCyan(`${output} Config`));
|
|
10011
|
+
if (config2.include)
|
|
10012
|
+
this.console.error(c.dim("include: ") + c.yellow(config2.include.join(comma)));
|
|
10013
|
+
if (config2.exclude)
|
|
10014
|
+
this.console.error(c.dim("exclude: ") + c.yellow(config2.exclude.join(comma)));
|
|
10015
|
+
if (config2.typecheck.enabled) {
|
|
10016
|
+
this.console.error(c.dim("typecheck include: ") + c.yellow(config2.typecheck.include.join(comma)));
|
|
10017
|
+
this.console.error(c.dim("typecheck exclude: ") + c.yellow(config2.typecheck.exclude.join(comma)));
|
|
10018
|
+
}
|
|
10019
|
+
});
|
|
9899
10020
|
if (config.watchExclude)
|
|
9900
10021
|
this.console.error(c.dim("watch exclude: ") + c.yellow(config.watchExclude.join(comma)));
|
|
9901
10022
|
if (config.watch && (config.changed || ((_a = config.related) == null ? void 0 : _a.length))) {
|
|
@@ -10000,10 +10121,11 @@ function transformImportSpecifiers(node) {
|
|
|
10000
10121
|
return `{ ${dynamicImports} }`;
|
|
10001
10122
|
}
|
|
10002
10123
|
const regexpHoistable = /^[ \t]*\b(vi|vitest)\s*\.\s*(mock|unmock|hoisted)\(/m;
|
|
10124
|
+
const regexpAssignedHoisted = /=[ \t]*(\bawait|)[ \t]*\b(vi|vitest)\s*\.\s*hoisted\(/;
|
|
10003
10125
|
const hashbangRE = /^#!.*\n/;
|
|
10004
10126
|
function hoistMocks(code, id, parse) {
|
|
10005
10127
|
var _a;
|
|
10006
|
-
const hasMocks = regexpHoistable.test(code);
|
|
10128
|
+
const hasMocks = regexpHoistable.test(code) || regexpAssignedHoisted.test(code);
|
|
10007
10129
|
if (!hasMocks)
|
|
10008
10130
|
return;
|
|
10009
10131
|
const s = new MagicString(code);
|
|
@@ -10097,7 +10219,7 @@ ${err.message}`);
|
|
|
10097
10219
|
return {
|
|
10098
10220
|
ast,
|
|
10099
10221
|
code: s.toString(),
|
|
10100
|
-
map: s.generateMap({ hires:
|
|
10222
|
+
map: s.generateMap({ hires: "boundary", source: id })
|
|
10101
10223
|
};
|
|
10102
10224
|
}
|
|
10103
10225
|
|
|
@@ -10197,8 +10319,8 @@ function hijackVitePluginInject(viteConfig) {
|
|
|
10197
10319
|
}
|
|
10198
10320
|
function resolveFsAllow(projectRoot, rootConfigFile) {
|
|
10199
10321
|
if (!rootConfigFile)
|
|
10200
|
-
return [searchForWorkspaceRoot(projectRoot)];
|
|
10201
|
-
return [dirname(rootConfigFile), searchForWorkspaceRoot(projectRoot)];
|
|
10322
|
+
return [searchForWorkspaceRoot(projectRoot), rootDir];
|
|
10323
|
+
return [dirname(rootConfigFile), searchForWorkspaceRoot(projectRoot), rootDir];
|
|
10202
10324
|
}
|
|
10203
10325
|
|
|
10204
10326
|
async function createBrowserServer(project, configFile) {
|
|
@@ -10249,125 +10371,16 @@ async function createBrowserServer(project, configFile) {
|
|
|
10249
10371
|
});
|
|
10250
10372
|
await server.listen();
|
|
10251
10373
|
await server.watcher.close();
|
|
10252
|
-
(await import('./chunk-api-setup.
|
|
10374
|
+
(await import('./chunk-api-setup.37a43981.js')).setup(project, server);
|
|
10253
10375
|
return server;
|
|
10254
10376
|
}
|
|
10255
10377
|
|
|
10256
|
-
const playwrightBrowsers = ["firefox", "webkit", "chromium"];
|
|
10257
|
-
class PlaywrightBrowserProvider {
|
|
10258
|
-
name = "playwright";
|
|
10259
|
-
cachedBrowser = null;
|
|
10260
|
-
browser;
|
|
10261
|
-
ctx;
|
|
10262
|
-
getSupportedBrowsers() {
|
|
10263
|
-
return playwrightBrowsers;
|
|
10264
|
-
}
|
|
10265
|
-
async initialize(ctx, { browser }) {
|
|
10266
|
-
this.ctx = ctx;
|
|
10267
|
-
this.browser = browser;
|
|
10268
|
-
const root = this.ctx.config.root;
|
|
10269
|
-
if (!await ensurePackageInstalled("playwright", root))
|
|
10270
|
-
throw new Error('Cannot find "playwright" package. Please install it manually.');
|
|
10271
|
-
}
|
|
10272
|
-
async openBrowser() {
|
|
10273
|
-
if (this.cachedBrowser)
|
|
10274
|
-
return this.cachedBrowser;
|
|
10275
|
-
const options = this.ctx.config.browser;
|
|
10276
|
-
const playwright = await import('playwright');
|
|
10277
|
-
const playwrightInstance = await playwright[this.browser].launch({ headless: options.headless });
|
|
10278
|
-
this.cachedBrowser = await playwrightInstance.newPage();
|
|
10279
|
-
this.cachedBrowser.on("close", () => {
|
|
10280
|
-
playwrightInstance.close();
|
|
10281
|
-
});
|
|
10282
|
-
return this.cachedBrowser;
|
|
10283
|
-
}
|
|
10284
|
-
catchError(cb) {
|
|
10285
|
-
var _a;
|
|
10286
|
-
(_a = this.cachedBrowser) == null ? void 0 : _a.on("pageerror", cb);
|
|
10287
|
-
return () => {
|
|
10288
|
-
var _a2;
|
|
10289
|
-
(_a2 = this.cachedBrowser) == null ? void 0 : _a2.off("pageerror", cb);
|
|
10290
|
-
};
|
|
10291
|
-
}
|
|
10292
|
-
async openPage(url) {
|
|
10293
|
-
const browserInstance = await this.openBrowser();
|
|
10294
|
-
await browserInstance.goto(url);
|
|
10295
|
-
}
|
|
10296
|
-
async close() {
|
|
10297
|
-
var _a;
|
|
10298
|
-
await ((_a = this.cachedBrowser) == null ? void 0 : _a.close());
|
|
10299
|
-
process.exit();
|
|
10300
|
-
}
|
|
10301
|
-
}
|
|
10302
|
-
|
|
10303
|
-
const webdriverBrowsers = ["firefox", "chrome", "edge", "safari"];
|
|
10304
|
-
class WebdriverBrowserProvider {
|
|
10305
|
-
name = "webdriverio";
|
|
10306
|
-
cachedBrowser = null;
|
|
10307
|
-
stopSafari = () => {
|
|
10308
|
-
};
|
|
10309
|
-
browser;
|
|
10310
|
-
ctx;
|
|
10311
|
-
getSupportedBrowsers() {
|
|
10312
|
-
return webdriverBrowsers;
|
|
10313
|
-
}
|
|
10314
|
-
async initialize(ctx, { browser }) {
|
|
10315
|
-
this.ctx = ctx;
|
|
10316
|
-
this.browser = browser;
|
|
10317
|
-
const root = this.ctx.config.root;
|
|
10318
|
-
if (!await ensurePackageInstalled("webdriverio", root))
|
|
10319
|
-
throw new Error('Cannot find "webdriverio" package. Please install it manually.');
|
|
10320
|
-
if (browser === "safari" && !await ensurePackageInstalled("safaridriver", root))
|
|
10321
|
-
throw new Error('Cannot find "safaridriver" package. Please install it manually.');
|
|
10322
|
-
}
|
|
10323
|
-
async openBrowser() {
|
|
10324
|
-
if (this.cachedBrowser)
|
|
10325
|
-
return this.cachedBrowser;
|
|
10326
|
-
const options = this.ctx.config.browser;
|
|
10327
|
-
if (this.browser === "safari") {
|
|
10328
|
-
const safaridriver = await import('safaridriver');
|
|
10329
|
-
safaridriver.start({ diagnose: true });
|
|
10330
|
-
this.stopSafari = () => safaridriver.stop();
|
|
10331
|
-
process.on("beforeExit", () => {
|
|
10332
|
-
safaridriver.stop();
|
|
10333
|
-
});
|
|
10334
|
-
}
|
|
10335
|
-
const { remote } = await import('webdriverio');
|
|
10336
|
-
this.cachedBrowser = await remote({
|
|
10337
|
-
logLevel: "error",
|
|
10338
|
-
capabilities: {
|
|
10339
|
-
"browserName": this.browser,
|
|
10340
|
-
"wdio:devtoolsOptions": { headless: options.headless }
|
|
10341
|
-
}
|
|
10342
|
-
});
|
|
10343
|
-
return this.cachedBrowser;
|
|
10344
|
-
}
|
|
10345
|
-
async openPage(url) {
|
|
10346
|
-
const browserInstance = await this.openBrowser();
|
|
10347
|
-
await browserInstance.url(url);
|
|
10348
|
-
}
|
|
10349
|
-
// TODO
|
|
10350
|
-
catchError(_cb) {
|
|
10351
|
-
return () => {
|
|
10352
|
-
};
|
|
10353
|
-
}
|
|
10354
|
-
async close() {
|
|
10355
|
-
var _a, _b, _c;
|
|
10356
|
-
await Promise.all([
|
|
10357
|
-
this.stopSafari(),
|
|
10358
|
-
((_a = this.cachedBrowser) == null ? void 0 : _a.sessionId) ? (_c = (_b = this.cachedBrowser) == null ? void 0 : _b.deleteSession) == null ? void 0 : _c.call(_b) : null
|
|
10359
|
-
]);
|
|
10360
|
-
process.exit();
|
|
10361
|
-
}
|
|
10362
|
-
}
|
|
10363
|
-
|
|
10364
10378
|
async function getBrowserProvider(options, loader) {
|
|
10365
|
-
|
|
10366
|
-
|
|
10367
|
-
|
|
10368
|
-
|
|
10369
|
-
|
|
10370
|
-
return PlaywrightBrowserProvider;
|
|
10379
|
+
if (options.provider == null || options.provider === "webdriverio" || options.provider === "playwright") {
|
|
10380
|
+
await ensurePackageInstalled("@vitest/browser", loader.root);
|
|
10381
|
+
const providers = await loader.executeId("@vitest/browser/providers");
|
|
10382
|
+
const provider = options.provider || "webdriverio";
|
|
10383
|
+
return providers[provider];
|
|
10371
10384
|
}
|
|
10372
10385
|
let customProviderModule;
|
|
10373
10386
|
try {
|
|
@@ -10461,7 +10474,7 @@ function SsrReplacerPlugin() {
|
|
|
10461
10474
|
name: "vitest:ssr-replacer",
|
|
10462
10475
|
enforce: "pre",
|
|
10463
10476
|
transform(code, id) {
|
|
10464
|
-
if (!/\bimport\.meta\.env\b/.test(code)
|
|
10477
|
+
if (!/\bimport\.meta\.env\b/.test(code))
|
|
10465
10478
|
return null;
|
|
10466
10479
|
let s = null;
|
|
10467
10480
|
const cleanCode = stripLiteral(code);
|
|
@@ -10476,7 +10489,7 @@ function SsrReplacerPlugin() {
|
|
|
10476
10489
|
return {
|
|
10477
10490
|
code: s.toString(),
|
|
10478
10491
|
map: s.generateMap({
|
|
10479
|
-
hires:
|
|
10492
|
+
hires: "boundary",
|
|
10480
10493
|
// Remove possible query parameters, e.g. vue's "?vue&type=script&src=true&lang.ts"
|
|
10481
10494
|
source: cleanUrl(id)
|
|
10482
10495
|
})
|
|
@@ -10521,6 +10534,33 @@ function VitestOptimizer() {
|
|
|
10521
10534
|
};
|
|
10522
10535
|
}
|
|
10523
10536
|
|
|
10537
|
+
const metaUrlLength = "import.meta.url".length;
|
|
10538
|
+
const locationString = "self.location".padEnd(metaUrlLength, " ");
|
|
10539
|
+
function NormalizeURLPlugin() {
|
|
10540
|
+
return {
|
|
10541
|
+
name: "vitest:normalize-url",
|
|
10542
|
+
enforce: "post",
|
|
10543
|
+
transform(code, id, options) {
|
|
10544
|
+
const ssr = (options == null ? void 0 : options.ssr) === true;
|
|
10545
|
+
if (ssr || !code.includes("new URL") || !code.includes("import.meta.url"))
|
|
10546
|
+
return;
|
|
10547
|
+
const cleanString = stripLiteral(code);
|
|
10548
|
+
const assetImportMetaUrlRE = /\bnew\s+URL\s*\(\s*('[^']+'|"[^"]+"|`[^`]+`)\s*,\s*import\.meta\.url\s*(?:,\s*)?\)/g;
|
|
10549
|
+
let updatedCode = code;
|
|
10550
|
+
let match;
|
|
10551
|
+
while (match = assetImportMetaUrlRE.exec(cleanString)) {
|
|
10552
|
+
const { 0: exp, index } = match;
|
|
10553
|
+
const metaUrlIndex = index + exp.indexOf("import.meta.url");
|
|
10554
|
+
updatedCode = updatedCode.slice(0, metaUrlIndex) + locationString + updatedCode.slice(metaUrlIndex + metaUrlLength);
|
|
10555
|
+
}
|
|
10556
|
+
return {
|
|
10557
|
+
code: updatedCode,
|
|
10558
|
+
map: null
|
|
10559
|
+
};
|
|
10560
|
+
}
|
|
10561
|
+
};
|
|
10562
|
+
}
|
|
10563
|
+
|
|
10524
10564
|
function WorkspaceVitestPlugin(project, options) {
|
|
10525
10565
|
return [
|
|
10526
10566
|
{
|
|
@@ -10618,7 +10658,8 @@ function WorkspaceVitestPlugin(project, options) {
|
|
|
10618
10658
|
CoverageTransform(project.ctx),
|
|
10619
10659
|
MocksPlugin(),
|
|
10620
10660
|
VitestResolver(project.ctx),
|
|
10621
|
-
VitestOptimizer()
|
|
10661
|
+
VitestOptimizer(),
|
|
10662
|
+
NormalizeURLPlugin()
|
|
10622
10663
|
];
|
|
10623
10664
|
}
|
|
10624
10665
|
|
|
@@ -10637,10 +10678,9 @@ async function createViteServer(inlineConfig) {
|
|
|
10637
10678
|
return server;
|
|
10638
10679
|
}
|
|
10639
10680
|
|
|
10640
|
-
async function loadGlobalSetupFiles(
|
|
10641
|
-
|
|
10642
|
-
|
|
10643
|
-
return Promise.all(globalSetupFiles.map((file) => loadGlobalSetupFile(file, project.runner)));
|
|
10681
|
+
async function loadGlobalSetupFiles(runner, globalSetup) {
|
|
10682
|
+
const globalSetupFiles = toArray$1(globalSetup);
|
|
10683
|
+
return Promise.all(globalSetupFiles.map((file) => loadGlobalSetupFile(file, runner)));
|
|
10644
10684
|
}
|
|
10645
10685
|
async function loadGlobalSetupFile(file, runner) {
|
|
10646
10686
|
const m = await runner.executeFile(file);
|
|
@@ -10711,7 +10751,7 @@ class WorkspaceProject {
|
|
|
10711
10751
|
if (this._globalSetupInit)
|
|
10712
10752
|
return;
|
|
10713
10753
|
this._globalSetupInit = true;
|
|
10714
|
-
this._globalSetups = await loadGlobalSetupFiles(this);
|
|
10754
|
+
this._globalSetups = await loadGlobalSetupFiles(this.runner, this.config.globalSetup);
|
|
10715
10755
|
try {
|
|
10716
10756
|
for (const globalSetupFile of this._globalSetups) {
|
|
10717
10757
|
const teardown = await ((_a = globalSetupFile.setup) == null ? void 0 : _a.call(globalSetupFile));
|
|
@@ -10732,7 +10772,7 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
|
|
|
10732
10772
|
var _a;
|
|
10733
10773
|
if (!this._globalSetupInit || !this._globalSetups.length)
|
|
10734
10774
|
return;
|
|
10735
|
-
for (const globalSetupFile of this._globalSetups.reverse()) {
|
|
10775
|
+
for (const globalSetupFile of [...this._globalSetups].reverse()) {
|
|
10736
10776
|
try {
|
|
10737
10777
|
await ((_a = globalSetupFile.teardown) == null ? void 0 : _a.call(globalSetupFile));
|
|
10738
10778
|
} catch (error) {
|
|
@@ -10769,8 +10809,12 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
|
|
|
10769
10809
|
}
|
|
10770
10810
|
async globTestFiles(filters = []) {
|
|
10771
10811
|
const dir = this.config.dir || this.config.root;
|
|
10772
|
-
const
|
|
10773
|
-
|
|
10812
|
+
const typecheck = this.config.typecheck;
|
|
10813
|
+
const [testFiles, typecheckTestFiles] = await Promise.all([
|
|
10814
|
+
typecheck.enabled && typecheck.only ? [] : this.globAllTestFiles(this.config, dir),
|
|
10815
|
+
typecheck.enabled ? this.globFiles(typecheck.include, typecheck.exclude, dir) : []
|
|
10816
|
+
]);
|
|
10817
|
+
return this.filterFiles([...testFiles, ...typecheckTestFiles], filters, dir);
|
|
10774
10818
|
}
|
|
10775
10819
|
async globAllTestFiles(config, cwd) {
|
|
10776
10820
|
const { include, exclude, includeSource } = config;
|
|
@@ -10838,12 +10882,16 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
|
|
|
10838
10882
|
await ((_a = this.browser) == null ? void 0 : _a.close());
|
|
10839
10883
|
this.browser = await createBrowserServer(this, configFile);
|
|
10840
10884
|
}
|
|
10841
|
-
static
|
|
10885
|
+
static createBasicProject(ctx) {
|
|
10842
10886
|
const project = new WorkspaceProject(ctx.config.name || ctx.config.root, ctx);
|
|
10843
10887
|
project.vitenode = ctx.vitenode;
|
|
10844
10888
|
project.server = ctx.server;
|
|
10845
10889
|
project.runner = ctx.runner;
|
|
10846
10890
|
project.config = ctx.config;
|
|
10891
|
+
return project;
|
|
10892
|
+
}
|
|
10893
|
+
static async createCoreProject(ctx) {
|
|
10894
|
+
const project = WorkspaceProject.createBasicProject(ctx);
|
|
10847
10895
|
await project.initBrowserServer(ctx.server.config.configFile);
|
|
10848
10896
|
return project;
|
|
10849
10897
|
}
|
|
@@ -10867,63 +10915,6 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
|
|
|
10867
10915
|
async report(name, ...args) {
|
|
10868
10916
|
return this.ctx.report(name, ...args);
|
|
10869
10917
|
}
|
|
10870
|
-
async typecheck(filters = []) {
|
|
10871
|
-
const dir = this.config.dir || this.config.root;
|
|
10872
|
-
const { include, exclude } = this.config.typecheck;
|
|
10873
|
-
const testFiles = await this.globFiles(include, exclude, dir);
|
|
10874
|
-
const testsFilesList = this.filterFiles(testFiles, filters, dir);
|
|
10875
|
-
const checker = new Typechecker(this, testsFilesList);
|
|
10876
|
-
this.typechecker = checker;
|
|
10877
|
-
checker.onParseEnd(async ({ files, sourceErrors }) => {
|
|
10878
|
-
this.ctx.state.collectFiles(checker.getTestFiles());
|
|
10879
|
-
await this.report("onTaskUpdate", checker.getTestPacks());
|
|
10880
|
-
await this.report("onCollected");
|
|
10881
|
-
const failedTests = hasFailed(files);
|
|
10882
|
-
const exitCode = !failedTests && checker.getExitCode();
|
|
10883
|
-
if (exitCode) {
|
|
10884
|
-
const error = new Error(checker.getOutput());
|
|
10885
|
-
error.stack = "";
|
|
10886
|
-
this.ctx.state.catchError(error, "Typecheck Error");
|
|
10887
|
-
}
|
|
10888
|
-
if (!files.length) {
|
|
10889
|
-
this.ctx.logger.printNoTestFound();
|
|
10890
|
-
} else {
|
|
10891
|
-
if (failedTests)
|
|
10892
|
-
process.exitCode = 1;
|
|
10893
|
-
await this.report("onFinished", files);
|
|
10894
|
-
}
|
|
10895
|
-
if (sourceErrors.length && !this.config.typecheck.ignoreSourceErrors) {
|
|
10896
|
-
process.exitCode = 1;
|
|
10897
|
-
await this.ctx.logger.printSourceTypeErrors(sourceErrors);
|
|
10898
|
-
}
|
|
10899
|
-
if (!files.length) {
|
|
10900
|
-
const exitCode2 = this.config.passWithNoTests ? process.exitCode ?? 0 : 1;
|
|
10901
|
-
await this.close();
|
|
10902
|
-
process.exit(exitCode2);
|
|
10903
|
-
}
|
|
10904
|
-
if (this.config.watch) {
|
|
10905
|
-
await this.report("onWatcherStart", files, [
|
|
10906
|
-
...this.config.typecheck.ignoreSourceErrors ? [] : sourceErrors,
|
|
10907
|
-
...this.ctx.state.getUnhandledErrors()
|
|
10908
|
-
]);
|
|
10909
|
-
}
|
|
10910
|
-
});
|
|
10911
|
-
checker.onParseStart(async () => {
|
|
10912
|
-
await this.report("onInit", this.ctx);
|
|
10913
|
-
this.ctx.state.collectFiles(checker.getTestFiles());
|
|
10914
|
-
await this.report("onCollected");
|
|
10915
|
-
});
|
|
10916
|
-
checker.onWatcherRerun(async () => {
|
|
10917
|
-
await this.report("onWatcherRerun", testsFilesList, "File change detected. Triggering rerun.");
|
|
10918
|
-
await checker.collectTests();
|
|
10919
|
-
this.ctx.state.collectFiles(checker.getTestFiles());
|
|
10920
|
-
await this.report("onTaskUpdate", checker.getTestPacks());
|
|
10921
|
-
await this.report("onCollected");
|
|
10922
|
-
});
|
|
10923
|
-
await checker.prepare();
|
|
10924
|
-
await checker.collectTests();
|
|
10925
|
-
await checker.start();
|
|
10926
|
-
}
|
|
10927
10918
|
isBrowserEnabled() {
|
|
10928
10919
|
return isBrowserEnabled(this.config);
|
|
10929
10920
|
}
|
|
@@ -10953,6 +10944,7 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
|
|
|
10953
10944
|
resolveSnapshotPath: void 0
|
|
10954
10945
|
},
|
|
10955
10946
|
onConsoleLog: void 0,
|
|
10947
|
+
onStackTrace: void 0,
|
|
10956
10948
|
sequence: {
|
|
10957
10949
|
...this.ctx.config.sequence,
|
|
10958
10950
|
sequencer: void 0
|
|
@@ -10993,7 +10985,8 @@ ${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
|
|
|
10993
10985
|
throw new Error(`[${this.getName()}] Browser name is required. Please, set \`test.browser.name\` option manually.`);
|
|
10994
10986
|
if (!supportedBrowsers.includes(browser))
|
|
10995
10987
|
throw new Error(`[${this.getName()}] Browser "${browser}" is not supported by the browser provider "${this.browserProvider.name}". Supported browsers: ${supportedBrowsers.join(", ")}.`);
|
|
10996
|
-
|
|
10988
|
+
const providerOptions = this.config.browser.providerOptions;
|
|
10989
|
+
await this.browserProvider.initialize(this, { browser, options: providerOptions });
|
|
10997
10990
|
}
|
|
10998
10991
|
}
|
|
10999
10992
|
|
|
@@ -11027,7 +11020,9 @@ class Vitest {
|
|
|
11027
11020
|
coreWorkspaceProject;
|
|
11028
11021
|
projects = [];
|
|
11029
11022
|
projectsTestFiles = /* @__PURE__ */ new Map();
|
|
11023
|
+
projectFiles;
|
|
11030
11024
|
_onRestartListeners = [];
|
|
11025
|
+
_onClose = [];
|
|
11031
11026
|
_onSetServer = [];
|
|
11032
11027
|
_onCancelListeners = [];
|
|
11033
11028
|
async setServer(options, server, cliOptions) {
|
|
@@ -11046,9 +11041,16 @@ class Vitest {
|
|
|
11046
11041
|
this.state = new StateManager();
|
|
11047
11042
|
this.cache = new VitestCache();
|
|
11048
11043
|
this.snapshot = new SnapshotManager({ ...resolved.snapshotOptions });
|
|
11049
|
-
if (this.config.watch
|
|
11044
|
+
if (this.config.watch)
|
|
11050
11045
|
this.registerWatcher();
|
|
11051
11046
|
this.vitenode = new ViteNodeServer(server, this.config.server);
|
|
11047
|
+
const projectVitestPath = await this.vitenode.resolveId("vitest");
|
|
11048
|
+
const vitestDir = projectVitestPath ? resolve(projectVitestPath.id, "../..") : rootDir;
|
|
11049
|
+
this.projectFiles = {
|
|
11050
|
+
workerPath: join(vitestDir, "dist/worker.js"),
|
|
11051
|
+
forksPath: join(vitestDir, "dist/child.js"),
|
|
11052
|
+
vmPath: join(vitestDir, "dist/vm.js")
|
|
11053
|
+
};
|
|
11052
11054
|
const node = this.vitenode;
|
|
11053
11055
|
this.runner = new ViteNodeRunner({
|
|
11054
11056
|
root: server.config.root,
|
|
@@ -11083,6 +11085,8 @@ class Vitest {
|
|
|
11083
11085
|
}
|
|
11084
11086
|
await Promise.all(this._onSetServer.map((fn) => fn()));
|
|
11085
11087
|
this.projects = await this.resolveWorkspace(cliOptions);
|
|
11088
|
+
if (!this.coreWorkspaceProject)
|
|
11089
|
+
this.coreWorkspaceProject = WorkspaceProject.createBasicProject(this);
|
|
11086
11090
|
if (this.config.testNamePattern)
|
|
11087
11091
|
this.configOverride.testNamePattern = this.config.testNamePattern;
|
|
11088
11092
|
}
|
|
@@ -11091,7 +11095,7 @@ class Vitest {
|
|
|
11091
11095
|
return this.coreWorkspaceProject;
|
|
11092
11096
|
}
|
|
11093
11097
|
getCoreWorkspaceProject() {
|
|
11094
|
-
return this.coreWorkspaceProject
|
|
11098
|
+
return this.coreWorkspaceProject;
|
|
11095
11099
|
}
|
|
11096
11100
|
getProjectByTaskId(taskId) {
|
|
11097
11101
|
var _a;
|
|
@@ -11204,15 +11208,9 @@ class Vitest {
|
|
|
11204
11208
|
async initBrowserProviders() {
|
|
11205
11209
|
return Promise.all(this.projects.map((w) => w.initBrowserProvider()));
|
|
11206
11210
|
}
|
|
11207
|
-
typecheck(filters) {
|
|
11208
|
-
return Promise.all(this.projects.map((project) => project.typecheck(filters)));
|
|
11209
|
-
}
|
|
11210
11211
|
async start(filters) {
|
|
11211
11212
|
var _a, _b;
|
|
11212
|
-
|
|
11213
|
-
await this.typecheck(filters);
|
|
11214
|
-
return;
|
|
11215
|
-
}
|
|
11213
|
+
this._onClose = [];
|
|
11216
11214
|
try {
|
|
11217
11215
|
await this.initCoverageProvider();
|
|
11218
11216
|
await ((_a = this.coverageProvider) == null ? void 0 : _a.clean(this.config.coverage.clean));
|
|
@@ -11264,7 +11262,7 @@ class Vitest {
|
|
|
11264
11262
|
}
|
|
11265
11263
|
async filterTestsBySource(specs) {
|
|
11266
11264
|
if (this.config.changed && !this.config.related) {
|
|
11267
|
-
const { VitestGit } = await import('./chunk-node-git.
|
|
11265
|
+
const { VitestGit } = await import('./chunk-node-git.6c12e560.js');
|
|
11268
11266
|
const vitestGit = new VitestGit(this.config.root);
|
|
11269
11267
|
const related2 = await vitestGit.findChangedFiles({
|
|
11270
11268
|
changedSince: this.config.changed
|
|
@@ -11303,7 +11301,13 @@ class Vitest {
|
|
|
11303
11301
|
return Array.from(projects).map((project) => [project, file]);
|
|
11304
11302
|
}
|
|
11305
11303
|
async initializeGlobalSetup(paths) {
|
|
11306
|
-
|
|
11304
|
+
const projects = new Set(paths.map(([project]) => project));
|
|
11305
|
+
const coreProject = this.getCoreWorkspaceProject();
|
|
11306
|
+
if (!projects.has(coreProject))
|
|
11307
|
+
projects.add(coreProject);
|
|
11308
|
+
await Promise.all(
|
|
11309
|
+
Array.from(projects).map((project) => project.initializeGlobalSetup())
|
|
11310
|
+
);
|
|
11307
11311
|
}
|
|
11308
11312
|
async runFiles(paths) {
|
|
11309
11313
|
const filepaths = paths.map(([, file]) => file);
|
|
@@ -11535,10 +11539,11 @@ class Vitest {
|
|
|
11535
11539
|
async close() {
|
|
11536
11540
|
if (!this.closingPromise) {
|
|
11537
11541
|
const closePromises = this.projects.map((w) => w.close().then(() => w.server = void 0));
|
|
11538
|
-
if (!this.
|
|
11539
|
-
closePromises.push(this.
|
|
11542
|
+
if (!this.projects.includes(this.coreWorkspaceProject))
|
|
11543
|
+
closePromises.push(this.coreWorkspaceProject.close().then(() => this.server = void 0));
|
|
11540
11544
|
if (this.pool)
|
|
11541
11545
|
closePromises.push(this.pool.close().then(() => this.pool = void 0));
|
|
11546
|
+
closePromises.push(...this._onClose.map((fn) => fn()));
|
|
11542
11547
|
this.closingPromise = Promise.allSettled(closePromises).then((results) => {
|
|
11543
11548
|
results.filter((r) => r.status === "rejected").forEach((err) => {
|
|
11544
11549
|
this.logger.error("error during close", err.reason);
|
|
@@ -11608,6 +11613,9 @@ class Vitest {
|
|
|
11608
11613
|
onCancel(fn) {
|
|
11609
11614
|
this._onCancelListeners.push(fn);
|
|
11610
11615
|
}
|
|
11616
|
+
onClose(fn) {
|
|
11617
|
+
this._onClose.push(fn);
|
|
11618
|
+
}
|
|
11611
11619
|
}
|
|
11612
11620
|
|
|
11613
11621
|
async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
@@ -11728,7 +11736,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
11728
11736
|
try {
|
|
11729
11737
|
await ctx.setServer(options, server, userConfig);
|
|
11730
11738
|
if (options.api && options.watch)
|
|
11731
|
-
(await import('./chunk-api-setup.
|
|
11739
|
+
(await import('./chunk-api-setup.37a43981.js')).setup(ctx);
|
|
11732
11740
|
} catch (err) {
|
|
11733
11741
|
await ctx.logger.printError(err, { fullStack: true });
|
|
11734
11742
|
process.exit(1);
|
|
@@ -11743,7 +11751,8 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
11743
11751
|
options.ui ? await UIPlugin() : null,
|
|
11744
11752
|
MocksPlugin(),
|
|
11745
11753
|
VitestResolver(ctx),
|
|
11746
|
-
VitestOptimizer()
|
|
11754
|
+
VitestOptimizer(),
|
|
11755
|
+
NormalizeURLPlugin()
|
|
11747
11756
|
].filter(notNullish);
|
|
11748
11757
|
}
|
|
11749
11758
|
|
|
@@ -12258,12 +12267,12 @@ function requirePrompt$1 () {
|
|
|
12258
12267
|
if (hasRequiredPrompt$1) return prompt$2;
|
|
12259
12268
|
hasRequiredPrompt$1 = 1;
|
|
12260
12269
|
|
|
12261
|
-
const readline = require$$0$
|
|
12270
|
+
const readline = require$$0$3;
|
|
12262
12271
|
|
|
12263
12272
|
const _require = requireUtil$1(),
|
|
12264
12273
|
action = _require.action;
|
|
12265
12274
|
|
|
12266
|
-
const EventEmitter = require$$2
|
|
12275
|
+
const EventEmitter = require$$2;
|
|
12267
12276
|
|
|
12268
12277
|
const _require2 = requireSrc(),
|
|
12269
12278
|
beep = _require2.beep,
|
|
@@ -15423,9 +15432,9 @@ function requirePrompt () {
|
|
|
15423
15432
|
if (hasRequiredPrompt) return prompt$1;
|
|
15424
15433
|
hasRequiredPrompt = 1;
|
|
15425
15434
|
|
|
15426
|
-
const readline = require$$0$
|
|
15435
|
+
const readline = require$$0$3;
|
|
15427
15436
|
const { action } = requireUtil();
|
|
15428
|
-
const EventEmitter = require$$2
|
|
15437
|
+
const EventEmitter = require$$2;
|
|
15429
15438
|
const { beep, cursor } = requireSrc();
|
|
15430
15439
|
const color = requireKleur();
|
|
15431
15440
|
|
|
@@ -18076,8 +18085,6 @@ function registerConsoleShortcuts(ctx) {
|
|
|
18076
18085
|
process.kill(process.pid, "SIGTSTP");
|
|
18077
18086
|
return;
|
|
18078
18087
|
}
|
|
18079
|
-
if (!ctx.config.watch)
|
|
18080
|
-
return;
|
|
18081
18088
|
const name = key == null ? void 0 : key.name;
|
|
18082
18089
|
if (ctx.runningPromise) {
|
|
18083
18090
|
if (cancelKeys.includes(name))
|
|
@@ -18086,8 +18093,6 @@ function registerConsoleShortcuts(ctx) {
|
|
|
18086
18093
|
}
|
|
18087
18094
|
if (name === "q")
|
|
18088
18095
|
return ctx.exit(true);
|
|
18089
|
-
if (ctx.mode === "typecheck")
|
|
18090
|
-
return;
|
|
18091
18096
|
if (name === "h")
|
|
18092
18097
|
return printShortcutsHelp();
|
|
18093
18098
|
if (name === "u")
|
|
@@ -18153,7 +18158,7 @@ function registerConsoleShortcuts(ctx) {
|
|
|
18153
18158
|
}
|
|
18154
18159
|
|
|
18155
18160
|
async function startVitest(mode, cliFilters = [], options = {}, viteOverrides) {
|
|
18156
|
-
var _a;
|
|
18161
|
+
var _a, _b;
|
|
18157
18162
|
process.env.TEST = "true";
|
|
18158
18163
|
process.env.VITEST = "true";
|
|
18159
18164
|
(_a = process.env).NODE_ENV ?? (_a.NODE_ENV = options.mode || "test");
|
|
@@ -18172,6 +18177,13 @@ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides) {
|
|
|
18172
18177
|
options.browser = { enabled: true, name: options.browser };
|
|
18173
18178
|
if (typeof options.browser === "object" && !("enabled" in options.browser))
|
|
18174
18179
|
options.browser.enabled = true;
|
|
18180
|
+
if (typeof options.typecheck === "boolean")
|
|
18181
|
+
options.typecheck = { enabled: true };
|
|
18182
|
+
if (typeof ((_b = options.typecheck) == null ? void 0 : _b.only) === "boolean") {
|
|
18183
|
+
options.typecheck ?? (options.typecheck = {});
|
|
18184
|
+
options.typecheck.only = true;
|
|
18185
|
+
options.typecheck.enabled = true;
|
|
18186
|
+
}
|
|
18175
18187
|
const ctx = await createVitest(mode, options, viteOverrides);
|
|
18176
18188
|
if (mode === "test" && ctx.config.coverage.enabled) {
|
|
18177
18189
|
const provider = ctx.config.coverage.provider || "v8";
|
|
@@ -18189,7 +18201,7 @@ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides) {
|
|
|
18189
18201
|
return ctx;
|
|
18190
18202
|
}
|
|
18191
18203
|
let stdinCleanup;
|
|
18192
|
-
if (process.stdin.isTTY)
|
|
18204
|
+
if (process.stdin.isTTY && ctx.config.watch)
|
|
18193
18205
|
stdinCleanup = registerConsoleShortcuts(ctx);
|
|
18194
18206
|
ctx.onServerRestart((reason) => {
|
|
18195
18207
|
ctx.report("onServerRestart", reason);
|
|
@@ -18214,4 +18226,4 @@ async function startVitest(mode, cliFilters = [], options = {}, viteOverrides) {
|
|
|
18214
18226
|
return ctx;
|
|
18215
18227
|
}
|
|
18216
18228
|
|
|
18217
|
-
export { BaseSequencer as B, VitestPlugin as V, createVitest as c, onetimeExports as o, registerConsoleShortcuts as r, startVitest as s, version$1 as v };
|
|
18229
|
+
export { BaseSequencer as B, VitestPlugin as V, createVitest as c, ensurePackageInstalled as e, onetimeExports as o, registerConsoleShortcuts as r, startVitest as s, version$1 as v };
|