vitest 0.26.2 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +2 -54
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +15 -15
- package/dist/{chunk-api-setup.46ee0021.js → chunk-api-setup.16ac28c0.js} +13 -3
- package/dist/{chunk-install-pkg.31846bc1.js → chunk-install-pkg.6dd2bae6.js} +2 -2
- package/dist/{chunk-integrations-coverage.befed097.js → chunk-integrations-coverage.44413252.js} +19 -1
- package/dist/chunk-integrations-globals.3dfaeb99.js +27 -0
- package/dist/{chunk-typecheck-constants.e478eb98.js → chunk-mock-date.a1c85759.js} +10 -28
- package/dist/{chunk-node-git.43b341db.js → chunk-node-git.543e964a.js} +3 -4
- package/dist/{chunk-runtime-chain.198631fd.js → chunk-runtime-chain.6df5a66b.js} +1192 -1028
- package/dist/{chunk-runtime-error.12631a44.js → chunk-runtime-error.fad2c32b.js} +2 -2
- package/dist/{chunk-runtime-mocker.03096876.js → chunk-runtime-mocker.a677dd28.js} +10 -8
- package/dist/{chunk-runtime-rpc.503623e9.js → chunk-runtime-rpc.7f83c8a9.js} +2 -2
- package/dist/{chunk-runtime-setup.f79addc3.js → chunk-runtime-setup.731b2b04.js} +51 -52
- package/dist/{chunk-snapshot-manager.8c94a052.js → chunk-snapshot-manager.700322bf.js} +430 -303
- package/dist/{chunk-utils-env.4afc6329.js → chunk-utils-env.b861e3a0.js} +1 -63
- package/dist/{chunk-utils-import.dc87c88c.js → chunk-utils-import.2baa69a9.js} +38 -13
- package/dist/chunk-utils-source-map.60562959.js +408 -0
- package/dist/{chunk-utils-timers.54caa12a.js → chunk-utils-timers.52534f96.js} +2977 -3458
- package/dist/cli-wrapper.js +13 -13
- package/dist/cli.js +15 -627
- package/dist/config.cjs +2 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +2 -1
- package/dist/entry.js +14 -14
- package/dist/environments.d.ts +1 -1
- package/dist/{index-40ebba2b.d.ts → index-2d10c3fd.d.ts} +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +12 -12
- package/dist/loader.js +3 -3
- package/dist/node.d.ts +6 -6
- package/dist/node.js +11 -11
- package/dist/spy.js +2 -102
- package/dist/suite.js +10 -10
- package/dist/{types-2a26f28c.d.ts → types-e1e1d1e5.d.ts} +92 -83
- package/dist/vendor-index.723a074f.js +102 -0
- package/dist/{vendor-index.62932580.js → vendor-index.7a2cebfe.js} +0 -0
- package/dist/{vendor-index.808a85a6.js → vendor-index.9c919048.js} +0 -0
- package/dist/{vendor-index.a323f2d0.js → vendor-index.b2fdde54.js} +1 -1
- package/dist/worker.js +7 -7
- package/package.json +9 -5
- package/dist/chunk-integrations-globals.5af12e76.js +0 -27
- package/dist/chunk-utils-source-map.95b8b3f0.js +0 -94
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { j as join, c as basename, d as dirname, r as relative,
|
|
2
|
-
import { p as pLimit, s as someTasksAreOnly, i as interpretTaskModes,
|
|
1
|
+
import { j as join, c as basename, d as dirname, r as relative, e as extname, b as resolve, f as distDir, g as rootDir, h as isAbsolute, i as isNode, k as configFiles, l as defaultPort, n as normalize, t as toNamespacedPath, E as EXIT_CODE_RESTART } from './chunk-utils-env.b861e3a0.js';
|
|
2
|
+
import { p as pLimit, g as generateHash, c as calculateSuiteHash, s as someTasksAreOnly, i as interpretTaskModes, a as getCoverageProvider, C as CoverageProviderMap } from './chunk-integrations-coverage.44413252.js';
|
|
3
3
|
import { g as getEnvPackageName } from './chunk-env-node.b3664da2.js';
|
|
4
|
-
import {
|
|
4
|
+
import { y as ensurePackageInstalled, A as AggregateErrorPonyfill, s as slash$1, k as relativePath, z as getTests, e as getFullName, u as hasFailed, B as hasFailedSnapshot, C as getSuites, j as notNullish, l as shuffle, t as toArray, n as noop$1, D as deepMerge, b as getCallLastIndex, E as removeUndefinedValues, F as isWindows, G as stdout } from './chunk-mock-date.a1c85759.js';
|
|
5
5
|
import { loadConfigFromFile, normalizePath, createServer, mergeConfig } from 'vite';
|
|
6
6
|
import path$a from 'node:path';
|
|
7
7
|
import url, { fileURLToPath } from 'node:url';
|
|
@@ -14,10 +14,11 @@ import require$$0$1 from 'stream';
|
|
|
14
14
|
import require$$2 from 'events';
|
|
15
15
|
import require$$0$2, { existsSync as existsSync$1, readFileSync } from 'fs';
|
|
16
16
|
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
|
|
17
|
+
import c from 'picocolors';
|
|
17
18
|
import { ViteNodeRunner } from 'vite-node/client';
|
|
18
19
|
import { ViteNodeServer } from 'vite-node/server';
|
|
19
20
|
import { writeFile, rm } from 'node:fs/promises';
|
|
20
|
-
import { e as execa } from './vendor-index.
|
|
21
|
+
import { e as execa } from './vendor-index.b2fdde54.js';
|
|
21
22
|
import { SourceMapConsumer } from 'source-map';
|
|
22
23
|
import H from 'module';
|
|
23
24
|
import { parse as parse$4 } from 'acorn';
|
|
@@ -27,20 +28,20 @@ import { cpus, hostname } from 'node:os';
|
|
|
27
28
|
import { Tinypool } from 'tinypool';
|
|
28
29
|
import { c as createBirpc } from './vendor-index.783e7f3e.js';
|
|
29
30
|
import { performance } from 'perf_hooks';
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
31
|
+
import { s as stripAnsi, c as cliTruncate, b as parseStacktrace, d as stringWidth, e as sliceAnsi, a as positionToOffset, l as lineSplitRE } from './chunk-utils-source-map.60562959.js';
|
|
32
|
+
import { g as safeSetInterval, h as safeClearInterval, s as safeSetTimeout, d as ansiStyles, c as createPatch, a as stringify$5, b as safeClearTimeout } from './chunk-utils-timers.52534f96.js';
|
|
32
33
|
import { resolveModule } from 'local-pkg';
|
|
33
34
|
import { createHash } from 'crypto';
|
|
34
|
-
import { slash as slash$2 } from 'vite-node/utils';
|
|
35
|
-
import { o as onetime } from './vendor-index.
|
|
36
|
-
import { s as signalExit } from './vendor-index.
|
|
35
|
+
import { slash as slash$2, cleanUrl } from 'vite-node/utils';
|
|
36
|
+
import { o as onetime } from './vendor-index.9c919048.js';
|
|
37
|
+
import { s as signalExit } from './vendor-index.7a2cebfe.js';
|
|
37
38
|
import { createHash as createHash$1 } from 'node:crypto';
|
|
38
39
|
import MagicString from './chunk-magic-string.3a794426.js';
|
|
39
40
|
import { stripLiteral } from 'strip-literal';
|
|
40
41
|
import require$$0$3 from 'readline';
|
|
41
42
|
import { p as prompts } from './vendor-index.9f20a9be.js';
|
|
42
43
|
|
|
43
|
-
var version$1 = "0.
|
|
44
|
+
var version$1 = "0.27.0";
|
|
44
45
|
|
|
45
46
|
class EndError extends Error {
|
|
46
47
|
constructor(value) {
|
|
@@ -6892,9 +6893,9 @@ async function makeTscErrorInfo(errInfo) {
|
|
|
6892
6893
|
}
|
|
6893
6894
|
];
|
|
6894
6895
|
}
|
|
6895
|
-
async function
|
|
6896
|
+
async function getTsconfig(root, config) {
|
|
6896
6897
|
var _a;
|
|
6897
|
-
const tempConfigPath =
|
|
6898
|
+
const tempConfigPath = join(root, "tsconfig.temp.json");
|
|
6898
6899
|
const configName = ((_a = config.tsconfig) == null ? void 0 : _a.includes("jsconfig.json")) ? "jsconfig.json" : void 0;
|
|
6899
6900
|
const tsconfig = ie(config.tsconfig || root, configName);
|
|
6900
6901
|
if (!tsconfig)
|
|
@@ -6904,13 +6905,13 @@ async function getTsconfigPath(root, config) {
|
|
|
6904
6905
|
tmpTsConfig.compilerOptions = tmpTsConfig.compilerOptions || {};
|
|
6905
6906
|
tmpTsConfig.compilerOptions.emitDeclarationOnly = false;
|
|
6906
6907
|
tmpTsConfig.compilerOptions.incremental = true;
|
|
6907
|
-
tmpTsConfig.compilerOptions.tsBuildInfoFile =
|
|
6908
|
+
tmpTsConfig.compilerOptions.tsBuildInfoFile = join(
|
|
6908
6909
|
__dirname,
|
|
6909
6910
|
"tsconfig.tmp.tsbuildinfo"
|
|
6910
6911
|
);
|
|
6911
6912
|
const tsconfigFinalContent = JSON.stringify(tmpTsConfig, null, 2);
|
|
6912
6913
|
await writeFile(tempConfigPath, tsconfigFinalContent);
|
|
6913
|
-
return tempConfigPath;
|
|
6914
|
+
return { path: tempConfigPath, config: tmpTsConfig };
|
|
6914
6915
|
} catch (err) {
|
|
6915
6916
|
throw new Error("failed to write tsconfig.temp.json", { cause: err });
|
|
6916
6917
|
}
|
|
@@ -6966,18 +6967,16 @@ async function collectTests(ctx, filepath) {
|
|
|
6966
6967
|
ecmaVersion: "latest",
|
|
6967
6968
|
allowAwaitOutsideFunction: true
|
|
6968
6969
|
});
|
|
6970
|
+
const testFilepath = relative(ctx.config.root, filepath);
|
|
6969
6971
|
const file = {
|
|
6970
6972
|
filepath,
|
|
6971
6973
|
type: "suite",
|
|
6972
|
-
id:
|
|
6973
|
-
name:
|
|
6974
|
+
id: generateHash(testFilepath),
|
|
6975
|
+
name: testFilepath,
|
|
6974
6976
|
mode: "run",
|
|
6975
6977
|
tasks: [],
|
|
6976
6978
|
start: ast.start,
|
|
6977
|
-
end: ast.end
|
|
6978
|
-
result: {
|
|
6979
|
-
state: "pass"
|
|
6980
|
-
}
|
|
6979
|
+
end: ast.end
|
|
6981
6980
|
};
|
|
6982
6981
|
const definitions = [];
|
|
6983
6982
|
const getName = (callee) => {
|
|
@@ -7004,14 +7003,16 @@ async function collectTests(ctx, filepath) {
|
|
|
7004
7003
|
return;
|
|
7005
7004
|
const { arguments: [{ value: message }] } = node;
|
|
7006
7005
|
const property = (_a = callee == null ? void 0 : callee.property) == null ? void 0 : _a.name;
|
|
7007
|
-
|
|
7008
|
-
if (!["run", "skip", "todo", "only"].includes(mode))
|
|
7006
|
+
let mode = !property || property === name ? "run" : property;
|
|
7007
|
+
if (!["run", "skip", "todo", "only", "skipIf", "runIf"].includes(mode))
|
|
7009
7008
|
throw new Error(`${name}.${mode} syntax is not supported when testing types`);
|
|
7009
|
+
if (mode === "skipIf" || mode === "runIf")
|
|
7010
|
+
mode = "skip";
|
|
7010
7011
|
definitions.push({
|
|
7011
7012
|
start: node.start,
|
|
7012
7013
|
end: node.end,
|
|
7013
7014
|
name: message,
|
|
7014
|
-
type: name,
|
|
7015
|
+
type: name === "it" || name === "test" ? "test" : "suite",
|
|
7015
7016
|
mode
|
|
7016
7017
|
});
|
|
7017
7018
|
}
|
|
@@ -7023,33 +7024,49 @@ async function collectTests(ctx, filepath) {
|
|
|
7023
7024
|
lastSuite = suite.suite;
|
|
7024
7025
|
return lastSuite;
|
|
7025
7026
|
};
|
|
7026
|
-
definitions.sort((a, b) => a.start - b.start).forEach((definition
|
|
7027
|
+
definitions.sort((a, b) => a.start - b.start).forEach((definition) => {
|
|
7027
7028
|
const latestSuite = updateLatestSuite(definition.start);
|
|
7028
7029
|
let mode = definition.mode;
|
|
7029
7030
|
if (latestSuite.mode !== "run")
|
|
7030
7031
|
mode = latestSuite.mode;
|
|
7031
|
-
|
|
7032
|
+
if (definition.type === "suite") {
|
|
7033
|
+
const task2 = {
|
|
7034
|
+
type: definition.type,
|
|
7035
|
+
id: "",
|
|
7036
|
+
suite: latestSuite,
|
|
7037
|
+
file,
|
|
7038
|
+
tasks: [],
|
|
7039
|
+
mode,
|
|
7040
|
+
name: definition.name,
|
|
7041
|
+
end: definition.end,
|
|
7042
|
+
start: definition.start,
|
|
7043
|
+
meta: {
|
|
7044
|
+
typecheck: true
|
|
7045
|
+
}
|
|
7046
|
+
};
|
|
7047
|
+
definition.task = task2;
|
|
7048
|
+
latestSuite.tasks.push(task2);
|
|
7049
|
+
lastSuite = task2;
|
|
7050
|
+
return;
|
|
7051
|
+
}
|
|
7032
7052
|
const task = {
|
|
7033
|
-
type:
|
|
7034
|
-
id:
|
|
7053
|
+
type: definition.type,
|
|
7054
|
+
id: "",
|
|
7035
7055
|
suite: latestSuite,
|
|
7036
7056
|
file,
|
|
7037
|
-
tasks: [],
|
|
7038
7057
|
mode,
|
|
7058
|
+
context: {},
|
|
7039
7059
|
name: definition.name,
|
|
7040
7060
|
end: definition.end,
|
|
7041
7061
|
start: definition.start,
|
|
7042
|
-
|
|
7043
|
-
|
|
7062
|
+
meta: {
|
|
7063
|
+
typecheck: true
|
|
7044
7064
|
}
|
|
7045
7065
|
};
|
|
7046
7066
|
definition.task = task;
|
|
7047
7067
|
latestSuite.tasks.push(task);
|
|
7048
|
-
if (definition.type === "describe" || definition.type === "suite")
|
|
7049
|
-
lastSuite = task;
|
|
7050
|
-
else
|
|
7051
|
-
Object.defineProperty(task, TYPECHECK_SUITE, { value: true });
|
|
7052
7068
|
});
|
|
7069
|
+
calculateSuiteHash(file);
|
|
7053
7070
|
const hasOnly = someTasksAreOnly(file);
|
|
7054
7071
|
interpretTaskModes(file, ctx.config.testNamePattern, hasOnly, false, ctx.config.allowOnly);
|
|
7055
7072
|
return {
|
|
@@ -7091,9 +7108,15 @@ class Typechecker {
|
|
|
7091
7108
|
async collectFileTests(filepath) {
|
|
7092
7109
|
return collectTests(this.ctx, filepath);
|
|
7093
7110
|
}
|
|
7111
|
+
getFiles() {
|
|
7112
|
+
return this.files.filter((filename) => {
|
|
7113
|
+
const extension = extname(filename);
|
|
7114
|
+
return extension !== ".js" || this.allowJs;
|
|
7115
|
+
});
|
|
7116
|
+
}
|
|
7094
7117
|
async collectTests() {
|
|
7095
7118
|
const tests = (await Promise.all(
|
|
7096
|
-
this.
|
|
7119
|
+
this.getFiles().map((filepath) => this.collectFileTests(filepath))
|
|
7097
7120
|
)).reduce((acc, data) => {
|
|
7098
7121
|
if (!data)
|
|
7099
7122
|
return acc;
|
|
@@ -7105,7 +7128,7 @@ class Typechecker {
|
|
|
7105
7128
|
}
|
|
7106
7129
|
async prepareResults(output) {
|
|
7107
7130
|
const typeErrors = await this.parseTscLikeOutput(output);
|
|
7108
|
-
const testFiles = new Set(this.
|
|
7131
|
+
const testFiles = new Set(this.getFiles());
|
|
7109
7132
|
if (!this._tests)
|
|
7110
7133
|
this._tests = await this.collectTests();
|
|
7111
7134
|
const sourceErrors = [];
|
|
@@ -7126,31 +7149,25 @@ class Typechecker {
|
|
|
7126
7149
|
if (task.suite)
|
|
7127
7150
|
markFailed(task.suite);
|
|
7128
7151
|
};
|
|
7129
|
-
errors.forEach(({ error, originalError }
|
|
7152
|
+
errors.forEach(({ error, originalError }) => {
|
|
7153
|
+
var _a;
|
|
7130
7154
|
const originalPos = (mapConsumer == null ? void 0 : mapConsumer.generatedPositionFor({
|
|
7131
7155
|
line: originalError.line,
|
|
7132
7156
|
column: originalError.column,
|
|
7133
7157
|
source: path
|
|
7134
7158
|
})) || originalError;
|
|
7135
7159
|
const index = indexMap.get(`${originalPos.line}:${originalPos.column}`);
|
|
7136
|
-
const definition = index != null && sortedDefinitions.find((def) => def.start <= index && def.end >= index)
|
|
7137
|
-
const suite =
|
|
7160
|
+
const definition = index != null && sortedDefinitions.find((def) => def.start <= index && def.end >= index);
|
|
7161
|
+
const suite = definition ? definition.task : file;
|
|
7138
7162
|
const state = suite.mode === "run" || suite.mode === "only" ? "fail" : suite.mode;
|
|
7139
|
-
const
|
|
7140
|
-
|
|
7141
|
-
|
|
7142
|
-
|
|
7143
|
-
mode: suite.mode,
|
|
7144
|
-
file,
|
|
7145
|
-
suite,
|
|
7146
|
-
result: {
|
|
7147
|
-
state,
|
|
7148
|
-
error: state === "fail" ? error : void 0
|
|
7149
|
-
}
|
|
7163
|
+
const errors2 = ((_a = suite.result) == null ? void 0 : _a.errors) || [];
|
|
7164
|
+
suite.result = {
|
|
7165
|
+
state,
|
|
7166
|
+
errors: errors2
|
|
7150
7167
|
};
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
|
|
7168
|
+
errors2.push(error);
|
|
7169
|
+
if (state === "fail" && suite.suite)
|
|
7170
|
+
markFailed(suite.suite);
|
|
7154
7171
|
});
|
|
7155
7172
|
});
|
|
7156
7173
|
typeErrors.forEach((errors, path) => {
|
|
@@ -7175,11 +7192,7 @@ class Typechecker {
|
|
|
7175
7192
|
file: filepath,
|
|
7176
7193
|
line: info.line,
|
|
7177
7194
|
column: info.column,
|
|
7178
|
-
method: ""
|
|
7179
|
-
sourcePos: {
|
|
7180
|
-
line: info.line,
|
|
7181
|
-
column: info.column
|
|
7182
|
-
}
|
|
7195
|
+
method: ""
|
|
7183
7196
|
}
|
|
7184
7197
|
]);
|
|
7185
7198
|
Error.stackTraceLimit = limit;
|
|
@@ -7207,11 +7220,18 @@ class Typechecker {
|
|
|
7207
7220
|
const packageName = checker === "tsc" ? "typescript" : "vue-tsc";
|
|
7208
7221
|
await ensurePackageInstalled(packageName, root);
|
|
7209
7222
|
}
|
|
7223
|
+
async prepare() {
|
|
7224
|
+
const { root, typecheck } = this.ctx.config;
|
|
7225
|
+
await this.ensurePackageInstalled(root, typecheck.checker);
|
|
7226
|
+
const { config, path } = await getTsconfig(root, typecheck);
|
|
7227
|
+
this.tempConfigPath = path;
|
|
7228
|
+
this.allowJs = typecheck.allowJs || config.allowJs || false;
|
|
7229
|
+
}
|
|
7210
7230
|
async start() {
|
|
7211
7231
|
var _a, _b, _c;
|
|
7232
|
+
if (!this.tempConfigPath)
|
|
7233
|
+
throw new Error("tsconfig was not initialized");
|
|
7212
7234
|
const { root, watch, typecheck } = this.ctx.config;
|
|
7213
|
-
await this.ensurePackageInstalled(root, typecheck.checker);
|
|
7214
|
-
this.tempConfigPath = await getTsconfigPath(root, typecheck);
|
|
7215
7235
|
const args = ["--noEmit", "--pretty", "false", "-p", this.tempConfigPath];
|
|
7216
7236
|
if (watch)
|
|
7217
7237
|
args.push("--watch");
|
|
@@ -7252,7 +7272,6 @@ class Typechecker {
|
|
|
7252
7272
|
await child;
|
|
7253
7273
|
this._result = await this.prepareResults(output);
|
|
7254
7274
|
await ((_c = this._onParseEnd) == null ? void 0 : _c.call(this, this._result));
|
|
7255
|
-
await this.clear();
|
|
7256
7275
|
}
|
|
7257
7276
|
}
|
|
7258
7277
|
getResult() {
|
|
@@ -7261,6 +7280,9 @@ class Typechecker {
|
|
|
7261
7280
|
getTestFiles() {
|
|
7262
7281
|
return Object.values(this._tests || {}).map((i) => i.file);
|
|
7263
7282
|
}
|
|
7283
|
+
getTestPacks() {
|
|
7284
|
+
return Object.values(this._tests || {}).map((i) => [i.file.id, void 0]);
|
|
7285
|
+
}
|
|
7264
7286
|
}
|
|
7265
7287
|
|
|
7266
7288
|
const workerPath = url.pathToFileURL(resolve(distDir, "./worker.js")).href;
|
|
@@ -7427,8 +7449,8 @@ const F_LONG_DASH = "\u23AF";
|
|
|
7427
7449
|
|
|
7428
7450
|
const spinnerMap = /* @__PURE__ */ new WeakMap();
|
|
7429
7451
|
const hookSpinnerMap = /* @__PURE__ */ new WeakMap();
|
|
7430
|
-
const pointer =
|
|
7431
|
-
const skipped =
|
|
7452
|
+
const pointer = c.yellow(F_POINTER);
|
|
7453
|
+
const skipped = c.dim(c.gray(F_DOWN));
|
|
7432
7454
|
function getCols(delta = 0) {
|
|
7433
7455
|
var _a;
|
|
7434
7456
|
let length = (_a = process.stdout) == null ? void 0 : _a.columns;
|
|
@@ -7459,44 +7481,50 @@ function formatTestPath(root, path) {
|
|
|
7459
7481
|
const dir = dirname(path);
|
|
7460
7482
|
const ext = ((_a = path.match(/(\.(spec|test)\.[cm]?[tj]sx?)$/)) == null ? void 0 : _a[0]) || "";
|
|
7461
7483
|
const base = basename(path, ext);
|
|
7462
|
-
return slash$1(
|
|
7484
|
+
return slash$1(c.dim(`${dir}/`) + c.bold(base)) + c.dim(ext);
|
|
7463
7485
|
}
|
|
7464
7486
|
function renderSnapshotSummary(rootDir, snapshots) {
|
|
7465
7487
|
const summary = [];
|
|
7466
7488
|
if (snapshots.added)
|
|
7467
|
-
summary.push(
|
|
7489
|
+
summary.push(c.bold(c.green(`${snapshots.added} written`)));
|
|
7468
7490
|
if (snapshots.unmatched)
|
|
7469
|
-
summary.push(
|
|
7491
|
+
summary.push(c.bold(c.red(`${snapshots.unmatched} failed`)));
|
|
7470
7492
|
if (snapshots.updated)
|
|
7471
|
-
summary.push(
|
|
7493
|
+
summary.push(c.bold(c.green(`${snapshots.updated} updated `)));
|
|
7472
7494
|
if (snapshots.filesRemoved) {
|
|
7473
7495
|
if (snapshots.didUpdate)
|
|
7474
|
-
summary.push(
|
|
7496
|
+
summary.push(c.bold(c.green(`${snapshots.filesRemoved} files removed `)));
|
|
7475
7497
|
else
|
|
7476
|
-
summary.push(
|
|
7498
|
+
summary.push(c.bold(c.yellow(`${snapshots.filesRemoved} files obsolete `)));
|
|
7477
7499
|
}
|
|
7478
7500
|
if (snapshots.filesRemovedList && snapshots.filesRemovedList.length) {
|
|
7479
7501
|
const [head, ...tail] = snapshots.filesRemovedList;
|
|
7480
|
-
summary.push(`${
|
|
7502
|
+
summary.push(`${c.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, head)}`);
|
|
7481
7503
|
tail.forEach((key) => {
|
|
7482
|
-
summary.push(` ${
|
|
7504
|
+
summary.push(` ${c.gray(F_DOT)} ${formatTestPath(rootDir, key)}`);
|
|
7483
7505
|
});
|
|
7484
7506
|
}
|
|
7485
7507
|
if (snapshots.unchecked) {
|
|
7486
7508
|
if (snapshots.didUpdate)
|
|
7487
|
-
summary.push(
|
|
7509
|
+
summary.push(c.bold(c.green(`${snapshots.unchecked} removed`)));
|
|
7488
7510
|
else
|
|
7489
|
-
summary.push(
|
|
7511
|
+
summary.push(c.bold(c.yellow(`${snapshots.unchecked} obsolete`)));
|
|
7490
7512
|
snapshots.uncheckedKeysByFile.forEach((uncheckedFile) => {
|
|
7491
|
-
summary.push(`${
|
|
7492
|
-
uncheckedFile.keys.forEach((key) => summary.push(` ${
|
|
7513
|
+
summary.push(`${c.gray(F_DOWN_RIGHT)} ${formatTestPath(rootDir, uncheckedFile.filePath)}`);
|
|
7514
|
+
uncheckedFile.keys.forEach((key) => summary.push(` ${c.gray(F_DOT)} ${key}`));
|
|
7493
7515
|
});
|
|
7494
7516
|
}
|
|
7495
7517
|
return summary;
|
|
7496
7518
|
}
|
|
7519
|
+
function countTestErrors(tasks) {
|
|
7520
|
+
return tasks.reduce((c2, i) => {
|
|
7521
|
+
var _a, _b;
|
|
7522
|
+
return c2 + (((_b = (_a = i.result) == null ? void 0 : _a.errors) == null ? void 0 : _b.length) || 0);
|
|
7523
|
+
}, 0);
|
|
7524
|
+
}
|
|
7497
7525
|
function getStateString(tasks, name = "tests", showTotal = true) {
|
|
7498
7526
|
if (tasks.length === 0)
|
|
7499
|
-
return
|
|
7527
|
+
return c.dim(`no ${name}`);
|
|
7500
7528
|
const passed = tasks.filter((i) => {
|
|
7501
7529
|
var _a;
|
|
7502
7530
|
return ((_a = i.result) == null ? void 0 : _a.state) === "pass";
|
|
@@ -7508,17 +7536,17 @@ function getStateString(tasks, name = "tests", showTotal = true) {
|
|
|
7508
7536
|
const skipped2 = tasks.filter((i) => i.mode === "skip");
|
|
7509
7537
|
const todo = tasks.filter((i) => i.mode === "todo");
|
|
7510
7538
|
return [
|
|
7511
|
-
failed.length ?
|
|
7512
|
-
passed.length ?
|
|
7513
|
-
skipped2.length ?
|
|
7514
|
-
todo.length ?
|
|
7515
|
-
].filter(Boolean).join(
|
|
7539
|
+
failed.length ? c.bold(c.red(`${failed.length} failed`)) : null,
|
|
7540
|
+
passed.length ? c.bold(c.green(`${passed.length} passed`)) : null,
|
|
7541
|
+
skipped2.length ? c.yellow(`${skipped2.length} skipped`) : null,
|
|
7542
|
+
todo.length ? c.gray(`${todo.length} todo`) : null
|
|
7543
|
+
].filter(Boolean).join(c.dim(" | ")) + (showTotal ? c.gray(` (${tasks.length})`) : "");
|
|
7516
7544
|
}
|
|
7517
7545
|
function getStateSymbol(task) {
|
|
7518
7546
|
if (task.mode === "skip" || task.mode === "todo")
|
|
7519
7547
|
return skipped;
|
|
7520
7548
|
if (!task.result)
|
|
7521
|
-
return
|
|
7549
|
+
return c.gray("\xB7");
|
|
7522
7550
|
if (task.result.state === "run") {
|
|
7523
7551
|
if (task.type === "suite")
|
|
7524
7552
|
return pointer;
|
|
@@ -7527,13 +7555,13 @@ function getStateSymbol(task) {
|
|
|
7527
7555
|
spinner = elegantSpinner();
|
|
7528
7556
|
spinnerMap.set(task, spinner);
|
|
7529
7557
|
}
|
|
7530
|
-
return
|
|
7558
|
+
return c.yellow(spinner());
|
|
7531
7559
|
}
|
|
7532
7560
|
if (task.result.state === "pass") {
|
|
7533
|
-
return task.type === "benchmark" ?
|
|
7561
|
+
return task.type === "benchmark" ? c.green(F_DOT) : c.green(F_CHECK);
|
|
7534
7562
|
}
|
|
7535
7563
|
if (task.result.state === "fail") {
|
|
7536
|
-
return task.type === "suite" ? pointer :
|
|
7564
|
+
return task.type === "suite" ? pointer : c.red(F_CROSS);
|
|
7537
7565
|
}
|
|
7538
7566
|
return " ";
|
|
7539
7567
|
}
|
|
@@ -7551,7 +7579,7 @@ function getHookStateSymbol(task, hookName) {
|
|
|
7551
7579
|
spinner = elegantSpinner();
|
|
7552
7580
|
spinnerMap2.set(hookName, spinner);
|
|
7553
7581
|
}
|
|
7554
|
-
return
|
|
7582
|
+
return c.yellow(spinner());
|
|
7555
7583
|
}
|
|
7556
7584
|
}
|
|
7557
7585
|
const spinnerFrames = process.platform === "win32" ? ["-", "\\", "|", "/"] : ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
@@ -7570,24 +7598,24 @@ function formatProjectName(name, suffix = " ") {
|
|
|
7570
7598
|
return "";
|
|
7571
7599
|
const index = name.split("").reduce((acc, v, idx) => acc + v.charCodeAt(0) + idx, 0);
|
|
7572
7600
|
const colors = [
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
|
|
7577
|
-
|
|
7601
|
+
c.blue,
|
|
7602
|
+
c.yellow,
|
|
7603
|
+
c.cyan,
|
|
7604
|
+
c.green,
|
|
7605
|
+
c.magenta
|
|
7578
7606
|
];
|
|
7579
7607
|
return colors[index % colors.length](`|${name}|`) + suffix;
|
|
7580
7608
|
}
|
|
7581
7609
|
|
|
7582
7610
|
var _a;
|
|
7583
7611
|
const BADGE_PADDING = " ";
|
|
7584
|
-
const HELP_HINT = `${
|
|
7585
|
-
const HELP_UPDATE_SNAP =
|
|
7586
|
-
const HELP_QUITE = `${
|
|
7612
|
+
const HELP_HINT = `${c.dim("press ")}${c.bold("h")}${c.dim(" to show help")}`;
|
|
7613
|
+
const HELP_UPDATE_SNAP = c.dim("press ") + c.bold(c.yellow("u")) + c.dim(" to update snapshot");
|
|
7614
|
+
const HELP_QUITE = `${c.dim("press ")}${c.bold("q")}${c.dim(" to quit")}`;
|
|
7587
7615
|
const WAIT_FOR_CHANGE_PASS = `
|
|
7588
|
-
${
|
|
7616
|
+
${c.bold(c.inverse(c.green(" PASS ")))}${c.green(" Waiting for file changes...")}`;
|
|
7589
7617
|
const WAIT_FOR_CHANGE_FAIL = `
|
|
7590
|
-
${
|
|
7618
|
+
${c.bold(c.inverse(c.red(" FAIL ")))}${c.red(" Tests failed. Watching for file changes...")}`;
|
|
7591
7619
|
const LAST_RUN_LOG_TIMEOUT = 1500;
|
|
7592
7620
|
class BaseReporter {
|
|
7593
7621
|
constructor() {
|
|
@@ -7622,7 +7650,7 @@ class BaseReporter {
|
|
|
7622
7650
|
}
|
|
7623
7651
|
}
|
|
7624
7652
|
onTaskUpdate(packs) {
|
|
7625
|
-
var _a2, _b, _c;
|
|
7653
|
+
var _a2, _b, _c, _d;
|
|
7626
7654
|
if (this.isTTY)
|
|
7627
7655
|
return;
|
|
7628
7656
|
const logger = this.ctx.logger;
|
|
@@ -7635,22 +7663,24 @@ class BaseReporter {
|
|
|
7635
7663
|
return ((_a3 = t.result) == null ? void 0 : _a3.state) === "fail";
|
|
7636
7664
|
});
|
|
7637
7665
|
const skipped = tests.filter((t) => t.mode === "skip" || t.mode === "todo");
|
|
7638
|
-
let state =
|
|
7666
|
+
let state = c.dim(`${tests.length} test${tests.length > 1 ? "s" : ""}`);
|
|
7639
7667
|
if (failed.length)
|
|
7640
|
-
state += ` ${
|
|
7668
|
+
state += ` ${c.dim("|")} ${c.red(`${failed.length} failed`)}`;
|
|
7641
7669
|
if (skipped.length)
|
|
7642
|
-
state += ` ${
|
|
7643
|
-
let suffix =
|
|
7670
|
+
state += ` ${c.dim("|")} ${c.yellow(`${skipped.length} skipped`)}`;
|
|
7671
|
+
let suffix = c.dim(" (") + state + c.dim(")");
|
|
7644
7672
|
if (task.result.duration) {
|
|
7645
|
-
const color = task.result.duration > this.ctx.config.slowTestThreshold ?
|
|
7646
|
-
suffix += color(` ${Math.round(task.result.duration)}${
|
|
7673
|
+
const color = task.result.duration > this.ctx.config.slowTestThreshold ? c.yellow : c.gray;
|
|
7674
|
+
suffix += color(` ${Math.round(task.result.duration)}${c.dim("ms")}`);
|
|
7647
7675
|
}
|
|
7648
7676
|
if (this.ctx.config.logHeapUsage && task.result.heap != null)
|
|
7649
|
-
suffix +=
|
|
7677
|
+
suffix += c.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
|
|
7650
7678
|
logger.log(` ${getStateSymbol(task)} ${task.name} ${suffix}`);
|
|
7651
7679
|
for (const test of failed) {
|
|
7652
|
-
logger.log(
|
|
7653
|
-
|
|
7680
|
+
logger.log(c.red(` ${pointer} ${getFullName(test)}`));
|
|
7681
|
+
(_d = (_c = test.result) == null ? void 0 : _c.errors) == null ? void 0 : _d.forEach((e) => {
|
|
7682
|
+
logger.log(c.red(` ${F_RIGHT} ${e == null ? void 0 : e.message}`));
|
|
7683
|
+
});
|
|
7654
7684
|
}
|
|
7655
7685
|
}
|
|
7656
7686
|
}
|
|
@@ -7670,13 +7700,13 @@ class BaseReporter {
|
|
|
7670
7700
|
hints.unshift(HELP_UPDATE_SNAP);
|
|
7671
7701
|
else
|
|
7672
7702
|
hints.push(HELP_QUITE);
|
|
7673
|
-
this.ctx.logger.log(BADGE_PADDING + hints.join(
|
|
7703
|
+
this.ctx.logger.log(BADGE_PADDING + hints.join(c.dim(", ")));
|
|
7674
7704
|
if (this._lastRunCount) {
|
|
7675
7705
|
const LAST_RUN_TEXT = `rerun x${this._lastRunCount}`;
|
|
7676
7706
|
const LAST_RUN_TEXTS = [
|
|
7677
|
-
|
|
7678
|
-
|
|
7679
|
-
|
|
7707
|
+
c.blue(LAST_RUN_TEXT),
|
|
7708
|
+
c.gray(LAST_RUN_TEXT),
|
|
7709
|
+
c.dim(c.gray(LAST_RUN_TEXT))
|
|
7680
7710
|
];
|
|
7681
7711
|
this.ctx.logger.logUpdate(BADGE_PADDING + LAST_RUN_TEXTS[0]);
|
|
7682
7712
|
this._lastRunTimeout = 0;
|
|
@@ -7704,8 +7734,8 @@ class BaseReporter {
|
|
|
7704
7734
|
let reruns = this._filesInWatchMode.get(filepath) ?? 0;
|
|
7705
7735
|
this._filesInWatchMode.set(filepath, ++reruns);
|
|
7706
7736
|
});
|
|
7707
|
-
const BADGE =
|
|
7708
|
-
const TRIGGER = trigger ?
|
|
7737
|
+
const BADGE = c.inverse(c.bold(c.blue(" RERUN ")));
|
|
7738
|
+
const TRIGGER = trigger ? c.dim(` ${this.relative(trigger)}`) : "";
|
|
7709
7739
|
if (files.length > 1) {
|
|
7710
7740
|
this.ctx.logger.clearFullScreen(`
|
|
7711
7741
|
${BADGE}${TRIGGER}
|
|
@@ -7715,7 +7745,7 @@ ${BADGE}${TRIGGER}
|
|
|
7715
7745
|
const rerun = this._filesInWatchMode.get(files[0]) ?? 1;
|
|
7716
7746
|
this._lastRunCount = rerun;
|
|
7717
7747
|
this.ctx.logger.clearFullScreen(`
|
|
7718
|
-
${BADGE}${TRIGGER} ${
|
|
7748
|
+
${BADGE}${TRIGGER} ${c.blue(`x${rerun}`)}
|
|
7719
7749
|
`);
|
|
7720
7750
|
}
|
|
7721
7751
|
this._timeStart = new Date();
|
|
@@ -7725,7 +7755,7 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
|
|
|
7725
7755
|
if (!this.shouldLog(log))
|
|
7726
7756
|
return;
|
|
7727
7757
|
const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : void 0;
|
|
7728
|
-
this.ctx.logger.log(
|
|
7758
|
+
this.ctx.logger.log(c.gray(log.type + c.dim(` | ${task ? getFullName(task) : "unknown test"}`)));
|
|
7729
7759
|
process[log.type].write(`${log.content}
|
|
7730
7760
|
`);
|
|
7731
7761
|
}
|
|
@@ -7739,7 +7769,7 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
|
|
|
7739
7769
|
return true;
|
|
7740
7770
|
}
|
|
7741
7771
|
onServerRestart(reason) {
|
|
7742
|
-
this.ctx.logger.log(
|
|
7772
|
+
this.ctx.logger.log(c.bold(c.magenta(
|
|
7743
7773
|
reason === "config" ? "\nRestarting due to config changes..." : "\nRestarting Vitest..."
|
|
7744
7774
|
)));
|
|
7745
7775
|
}
|
|
@@ -7751,7 +7781,7 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
|
|
|
7751
7781
|
await this.reportTestSummary(files);
|
|
7752
7782
|
}
|
|
7753
7783
|
async reportTestSummary(files) {
|
|
7754
|
-
const tests =
|
|
7784
|
+
const tests = getTests(files);
|
|
7755
7785
|
const logger = this.ctx.logger;
|
|
7756
7786
|
const executionTime = this.end - this.start;
|
|
7757
7787
|
const collectTime = files.reduce((acc, test) => acc + Math.max(0, test.collectDuration || 0), 0);
|
|
@@ -7762,7 +7792,7 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
|
|
|
7762
7792
|
}, 0);
|
|
7763
7793
|
const transformTime = Array.from(this.ctx.vitenode.fetchCache.values()).reduce((a, b) => a + ((b == null ? void 0 : b.duration) || 0), 0);
|
|
7764
7794
|
const threadTime = collectTime + testsTime + setupTime;
|
|
7765
|
-
const padTitle = (str) =>
|
|
7795
|
+
const padTitle = (str) => c.dim(`${str.padStart(11)} `);
|
|
7766
7796
|
const time = (time2) => {
|
|
7767
7797
|
if (time2 > 1e3)
|
|
7768
7798
|
return `${(time2 / 1e3).toFixed(2)}s`;
|
|
@@ -7779,8 +7809,11 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
|
|
|
7779
7809
|
logger.log(padTitle("Test Files"), getStateString(files));
|
|
7780
7810
|
logger.log(padTitle("Tests"), getStateString(tests));
|
|
7781
7811
|
if (this.mode === "typecheck") {
|
|
7782
|
-
const
|
|
7783
|
-
|
|
7812
|
+
const failed = tests.filter((t) => {
|
|
7813
|
+
var _a2, _b, _c;
|
|
7814
|
+
return ((_a2 = t.meta) == null ? void 0 : _a2.typecheck) && ((_c = (_b = t.result) == null ? void 0 : _b.errors) == null ? void 0 : _c.length);
|
|
7815
|
+
});
|
|
7816
|
+
logger.log(padTitle("Type Errors"), failed.length ? c.bold(c.red(`${failed} failed`)) : c.dim("no errors"));
|
|
7784
7817
|
}
|
|
7785
7818
|
logger.log(padTitle("Start at"), formatTimeString(this._timeStart));
|
|
7786
7819
|
if (this.watchFilters)
|
|
@@ -7788,7 +7821,7 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
|
|
|
7788
7821
|
else if (this.mode === "typecheck")
|
|
7789
7822
|
logger.log(padTitle("Duration"), time(executionTime));
|
|
7790
7823
|
else
|
|
7791
|
-
logger.log(padTitle("Duration"), time(executionTime) +
|
|
7824
|
+
logger.log(padTitle("Duration"), time(executionTime) + c.dim(` (transform ${time(transformTime)}, setup ${time(setupTime)}, collect ${time(collectTime)}, tests ${time(testsTime)})`));
|
|
7792
7825
|
logger.log();
|
|
7793
7826
|
}
|
|
7794
7827
|
async printErrorsSummary(files) {
|
|
@@ -7797,24 +7830,23 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
|
|
|
7797
7830
|
const tests = getTests(files);
|
|
7798
7831
|
const failedSuites = suites.filter((i) => {
|
|
7799
7832
|
var _a2;
|
|
7800
|
-
return (_a2 = i.result) == null ? void 0 : _a2.
|
|
7833
|
+
return (_a2 = i.result) == null ? void 0 : _a2.errors;
|
|
7801
7834
|
});
|
|
7802
7835
|
const failedTests = tests.filter((i) => {
|
|
7803
7836
|
var _a2;
|
|
7804
7837
|
return ((_a2 = i.result) == null ? void 0 : _a2.state) === "fail";
|
|
7805
7838
|
});
|
|
7806
|
-
const failedTotal = failedSuites
|
|
7839
|
+
const failedTotal = countTestErrors(failedSuites) + countTestErrors(failedTests);
|
|
7807
7840
|
let current = 1;
|
|
7808
|
-
const errorDivider = () => logger.error(`${
|
|
7841
|
+
const errorDivider = () => logger.error(`${c.red(c.dim(divider(`[${current++}/${failedTotal}]`, void 0, 1)))}
|
|
7809
7842
|
`);
|
|
7810
7843
|
if (failedSuites.length) {
|
|
7811
|
-
logger.error(
|
|
7844
|
+
logger.error(c.red(divider(c.bold(c.inverse(` Failed Suites ${failedSuites.length} `)))));
|
|
7812
7845
|
logger.error();
|
|
7813
7846
|
await this.printTaskErrors(failedSuites, errorDivider);
|
|
7814
7847
|
}
|
|
7815
7848
|
if (failedTests.length) {
|
|
7816
|
-
|
|
7817
|
-
logger.error(picocolors.exports.red(divider(picocolors.exports.bold(picocolors.exports.inverse(` ${message} ${failedTests.length} `)))));
|
|
7849
|
+
logger.error(c.red(divider(c.bold(c.inverse(` Failed Tests ${failedTests.length} `)))));
|
|
7818
7850
|
logger.error();
|
|
7819
7851
|
await this.printTaskErrors(failedTests, errorDivider);
|
|
7820
7852
|
}
|
|
@@ -7828,47 +7860,48 @@ ${BADGE}${TRIGGER} ${picocolors.exports.blue(`x${rerun}`)}
|
|
|
7828
7860
|
return ((_b = (_a2 = i.result) == null ? void 0 : _a2.benchmark) == null ? void 0 : _b.rank) === 1;
|
|
7829
7861
|
});
|
|
7830
7862
|
logger.log(`
|
|
7831
|
-
${
|
|
7863
|
+
${c.cyan(c.inverse(c.bold(" BENCH ")))} ${c.cyan("Summary")}
|
|
7832
7864
|
`);
|
|
7833
7865
|
for (const bench of topBenchs) {
|
|
7834
7866
|
const group = bench.suite;
|
|
7835
7867
|
if (!group)
|
|
7836
7868
|
continue;
|
|
7837
7869
|
const groupName = getFullName(group);
|
|
7838
|
-
logger.log(` ${bench.name}${
|
|
7870
|
+
logger.log(` ${bench.name}${c.dim(` - ${groupName}`)}`);
|
|
7839
7871
|
const siblings = group.tasks.filter((i) => {
|
|
7840
7872
|
var _a2;
|
|
7841
7873
|
return ((_a2 = i.result) == null ? void 0 : _a2.benchmark) && i !== bench;
|
|
7842
7874
|
}).sort((a, b) => a.result.benchmark.rank - b.result.benchmark.rank);
|
|
7843
7875
|
for (const sibling of siblings) {
|
|
7844
7876
|
const number = `${(sibling.result.benchmark.mean / bench.result.benchmark.mean).toFixed(2)}x`;
|
|
7845
|
-
logger.log(` ${
|
|
7877
|
+
logger.log(` ${c.green(number)} ${c.gray("faster than")} ${sibling.name}`);
|
|
7846
7878
|
}
|
|
7847
7879
|
logger.log("");
|
|
7848
7880
|
}
|
|
7849
7881
|
}
|
|
7850
7882
|
async printTaskErrors(tasks, errorDivider) {
|
|
7851
|
-
var _a2, _b;
|
|
7883
|
+
var _a2, _b, _c;
|
|
7852
7884
|
const errorsQueue = [];
|
|
7853
7885
|
for (const task of tasks) {
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
|
|
7886
|
+
(_b = (_a2 = task.result) == null ? void 0 : _a2.errors) == null ? void 0 : _b.forEach((error) => {
|
|
7887
|
+
const errorItem = (error == null ? void 0 : error.stackStr) && errorsQueue.find((i) => {
|
|
7888
|
+
var _a3;
|
|
7889
|
+
return ((_a3 = i[0]) == null ? void 0 : _a3.stackStr) === error.stackStr;
|
|
7890
|
+
});
|
|
7891
|
+
if (errorItem)
|
|
7892
|
+
errorItem[1].push(task);
|
|
7893
|
+
else
|
|
7894
|
+
errorsQueue.push([error, [task]]);
|
|
7858
7895
|
});
|
|
7859
|
-
if (errorItem)
|
|
7860
|
-
errorItem[1].push(task);
|
|
7861
|
-
else
|
|
7862
|
-
errorsQueue.push([error, [task]]);
|
|
7863
7896
|
}
|
|
7864
7897
|
for (const [error, tasks2] of errorsQueue) {
|
|
7865
7898
|
for (const task of tasks2) {
|
|
7866
7899
|
const filepath = (task == null ? void 0 : task.filepath) || "";
|
|
7867
|
-
const projectName = (task == null ? void 0 : task.projectName) || ((
|
|
7900
|
+
const projectName = (task == null ? void 0 : task.projectName) || ((_c = task.file) == null ? void 0 : _c.projectName);
|
|
7868
7901
|
let name = getFullName(task);
|
|
7869
7902
|
if (filepath)
|
|
7870
|
-
name = `${name} ${
|
|
7871
|
-
this.ctx.logger.error(`${
|
|
7903
|
+
name = `${name} ${c.dim(`[ ${this.relative(filepath)} ]`)}`;
|
|
7904
|
+
this.ctx.logger.error(`${c.red(c.bold(c.inverse(" FAIL ")))} ${formatProjectName(projectName)}${name}`);
|
|
7872
7905
|
}
|
|
7873
7906
|
await this.ctx.logger.printError(error);
|
|
7874
7907
|
errorDivider();
|
|
@@ -7894,7 +7927,7 @@ function formatFilepath$1(path) {
|
|
|
7894
7927
|
if (firstDot < 0)
|
|
7895
7928
|
firstDot = basename.length;
|
|
7896
7929
|
firstDot += lastSlash;
|
|
7897
|
-
return
|
|
7930
|
+
return c.dim(path.slice(0, lastSlash)) + path.slice(lastSlash, firstDot) + c.dim(path.slice(firstDot));
|
|
7898
7931
|
}
|
|
7899
7932
|
function formatNumber$1(number) {
|
|
7900
7933
|
const res = String(number.toFixed(number < 100 ? 4 : 2)).split(".");
|
|
@@ -7904,7 +7937,7 @@ function renderHookState(task, hookName, level = 0) {
|
|
|
7904
7937
|
var _a, _b;
|
|
7905
7938
|
const state = (_b = (_a = task.result) == null ? void 0 : _a.hooks) == null ? void 0 : _b[hookName];
|
|
7906
7939
|
if (state && state === "run")
|
|
7907
|
-
return `${" ".repeat(level)} ${getHookStateSymbol(task, hookName)} ${
|
|
7940
|
+
return `${" ".repeat(level)} ${getHookStateSymbol(task, hookName)} ${c.dim(`[ ${hookName} ]`)}`;
|
|
7908
7941
|
return "";
|
|
7909
7942
|
}
|
|
7910
7943
|
function renderBenchmarkItems$1(result) {
|
|
@@ -7933,16 +7966,16 @@ function renderBenchmark$1(task, tasks) {
|
|
|
7933
7966
|
});
|
|
7934
7967
|
return [
|
|
7935
7968
|
padded[0],
|
|
7936
|
-
|
|
7937
|
-
|
|
7938
|
-
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
result.rank === 1 ?
|
|
7969
|
+
c.dim(" "),
|
|
7970
|
+
c.blue(padded[1]),
|
|
7971
|
+
c.dim(" ops/sec "),
|
|
7972
|
+
c.cyan(padded[3]),
|
|
7973
|
+
c.dim(` (${padded[4]} samples)`),
|
|
7974
|
+
result.rank === 1 ? c.bold(c.green(" fastest")) : result.rank === benchs.length && benchs.length > 2 ? c.bold(c.gray(" slowest")) : ""
|
|
7942
7975
|
].join("");
|
|
7943
7976
|
}
|
|
7944
7977
|
function renderTree$1(tasks, options, level = 0) {
|
|
7945
|
-
var _a, _b, _c, _d, _e, _f;
|
|
7978
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
7946
7979
|
let output = [];
|
|
7947
7980
|
for (const task of tasks) {
|
|
7948
7981
|
let suffix = "";
|
|
@@ -7950,26 +7983,26 @@ function renderTree$1(tasks, options, level = 0) {
|
|
|
7950
7983
|
if (level === 0 && task.type === "suite" && task.projectName)
|
|
7951
7984
|
prefix += formatProjectName(task.projectName);
|
|
7952
7985
|
if (task.type === "test" && ((_a = task.result) == null ? void 0 : _a.retryCount) && task.result.retryCount > 1)
|
|
7953
|
-
suffix +=
|
|
7954
|
-
if (task.type === "suite" && !
|
|
7955
|
-
const tests =
|
|
7956
|
-
suffix +=
|
|
7986
|
+
suffix += c.yellow(` (retry x${task.result.retryCount})`);
|
|
7987
|
+
if (task.type === "suite" && !((_b = task.meta) == null ? void 0 : _b.typecheck)) {
|
|
7988
|
+
const tests = getTests(task);
|
|
7989
|
+
suffix += c.dim(` (${tests.length})`);
|
|
7957
7990
|
}
|
|
7958
7991
|
if (task.mode === "skip" || task.mode === "todo")
|
|
7959
|
-
suffix += ` ${
|
|
7960
|
-
if (((
|
|
7992
|
+
suffix += ` ${c.dim(c.gray("[skipped]"))}`;
|
|
7993
|
+
if (((_c = task.result) == null ? void 0 : _c.duration) != null) {
|
|
7961
7994
|
if (task.result.duration > DURATION_LONG$1)
|
|
7962
|
-
suffix +=
|
|
7995
|
+
suffix += c.yellow(` ${Math.round(task.result.duration)}${c.dim("ms")}`);
|
|
7963
7996
|
}
|
|
7964
|
-
if (options.showHeap && ((
|
|
7965
|
-
suffix +=
|
|
7997
|
+
if (options.showHeap && ((_d = task.result) == null ? void 0 : _d.heap) != null)
|
|
7998
|
+
suffix += c.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
|
|
7966
7999
|
let name = task.name;
|
|
7967
8000
|
if (level === 0)
|
|
7968
8001
|
name = formatFilepath$1(name);
|
|
7969
8002
|
const padding = " ".repeat(level);
|
|
7970
8003
|
const body = task.type === "benchmark" ? renderBenchmark$1(task, tasks) : name;
|
|
7971
8004
|
output.push(padding + prefix + body + suffix);
|
|
7972
|
-
if (((
|
|
8005
|
+
if (((_e = task.result) == null ? void 0 : _e.state) !== "pass" && outputMap$1.get(task) != null) {
|
|
7973
8006
|
let data = outputMap$1.get(task);
|
|
7974
8007
|
if (typeof data === "string") {
|
|
7975
8008
|
data = stripAnsi(data.trim().split("\n").filter(Boolean).pop());
|
|
@@ -7978,13 +8011,13 @@ function renderTree$1(tasks, options, level = 0) {
|
|
|
7978
8011
|
}
|
|
7979
8012
|
if (data != null) {
|
|
7980
8013
|
const out = `${" ".repeat(level)}${F_RIGHT} ${data}`;
|
|
7981
|
-
output.push(` ${
|
|
8014
|
+
output.push(` ${c.gray(cliTruncate(out, getCols(-3)))}`);
|
|
7982
8015
|
}
|
|
7983
8016
|
}
|
|
7984
8017
|
output = output.concat(renderHookState(task, "beforeAll", level + 1));
|
|
7985
8018
|
output = output.concat(renderHookState(task, "beforeEach", level + 1));
|
|
7986
8019
|
if (task.type === "suite" && task.tasks.length > 0) {
|
|
7987
|
-
if (((
|
|
8020
|
+
if (((_f = task.result) == null ? void 0 : _f.state) === "fail" || ((_g = task.result) == null ? void 0 : _g.state) === "run" || options.renderSucceed)
|
|
7988
8021
|
output = output.concat(renderTree$1(task.tasks, options, level + 1));
|
|
7989
8022
|
}
|
|
7990
8023
|
output = output.concat(renderHookState(task, "afterAll", level + 1));
|
|
@@ -8033,7 +8066,7 @@ class DefaultReporter extends BaseReporter {
|
|
|
8033
8066
|
}
|
|
8034
8067
|
async onTestRemoved(trigger) {
|
|
8035
8068
|
await this.stopListRender();
|
|
8036
|
-
this.ctx.logger.clearScreen(
|
|
8069
|
+
this.ctx.logger.clearScreen(c.yellow("Test removed...") + (trigger ? c.dim(` [ ${this.relative(trigger)} ]
|
|
8037
8070
|
`) : ""), true);
|
|
8038
8071
|
const files = this.ctx.state.getFiles(this.watchFilters);
|
|
8039
8072
|
createListRenderer(files, this.rendererOptions).stop();
|
|
@@ -8080,10 +8113,10 @@ class DefaultReporter extends BaseReporter {
|
|
|
8080
8113
|
}
|
|
8081
8114
|
}
|
|
8082
8115
|
|
|
8083
|
-
const check =
|
|
8084
|
-
const cross =
|
|
8085
|
-
const pending =
|
|
8086
|
-
const skip =
|
|
8116
|
+
const check = c.green("\xB7");
|
|
8117
|
+
const cross = c.red("x");
|
|
8118
|
+
const pending = c.yellow("*");
|
|
8119
|
+
const skip = c.dim(c.gray("-"));
|
|
8087
8120
|
function render(tasks) {
|
|
8088
8121
|
const all = getTests(tasks);
|
|
8089
8122
|
return all.map((i) => {
|
|
@@ -8195,14 +8228,14 @@ class JsonReporter$1 {
|
|
|
8195
8228
|
this.start = Date.now();
|
|
8196
8229
|
}
|
|
8197
8230
|
async logTasks(files) {
|
|
8198
|
-
var _a, _b;
|
|
8231
|
+
var _a, _b, _c;
|
|
8199
8232
|
const suites = getSuites(files);
|
|
8200
8233
|
const numTotalTestSuites = suites.length;
|
|
8201
8234
|
const tests = getTests(files);
|
|
8202
8235
|
const numTotalTests = tests.length;
|
|
8203
8236
|
const numFailedTestSuites = suites.filter((s) => {
|
|
8204
8237
|
var _a2;
|
|
8205
|
-
return (_a2 = s.result) == null ? void 0 : _a2.
|
|
8238
|
+
return (_a2 = s.result) == null ? void 0 : _a2.errors;
|
|
8206
8239
|
}).length;
|
|
8207
8240
|
const numPassedTestSuites = numTotalTestSuites - numFailedTestSuites;
|
|
8208
8241
|
const numPendingTestSuites = suites.filter((s) => {
|
|
@@ -8234,7 +8267,7 @@ class JsonReporter$1 {
|
|
|
8234
8267
|
return Math.max(prev, (((_a2 = next.result) == null ? void 0 : _a2.startTime) ?? 0) + (((_b2 = next.result) == null ? void 0 : _b2.duration) ?? 0));
|
|
8235
8268
|
}, startTime);
|
|
8236
8269
|
const assertionResults = await Promise.all(tests2.map(async (t) => {
|
|
8237
|
-
var _a2, _b2,
|
|
8270
|
+
var _a2, _b2, _c2, _d;
|
|
8238
8271
|
const ancestorTitles = [];
|
|
8239
8272
|
let iter = t.suite;
|
|
8240
8273
|
while (iter) {
|
|
@@ -8248,7 +8281,7 @@ class JsonReporter$1 {
|
|
|
8248
8281
|
status: StatusMap[((_a2 = t.result) == null ? void 0 : _a2.state) || t.mode] || "skipped",
|
|
8249
8282
|
title: t.name,
|
|
8250
8283
|
duration: (_b2 = t.result) == null ? void 0 : _b2.duration,
|
|
8251
|
-
failureMessages: ((_d = (
|
|
8284
|
+
failureMessages: ((_d = (_c2 = t.result) == null ? void 0 : _c2.errors) == null ? void 0 : _d.map((e) => e.message)) || [],
|
|
8252
8285
|
location: await this.getFailureLocation(t)
|
|
8253
8286
|
};
|
|
8254
8287
|
}));
|
|
@@ -8266,7 +8299,7 @@ class JsonReporter$1 {
|
|
|
8266
8299
|
var _a2;
|
|
8267
8300
|
return ((_a2 = t.result) == null ? void 0 : _a2.state) === "fail";
|
|
8268
8301
|
}) ? "failed" : "passed",
|
|
8269
|
-
message: ((_b = (_a = file.result) == null ? void 0 : _a.
|
|
8302
|
+
message: ((_c = (_b = (_a = file.result) == null ? void 0 : _a.errors) == null ? void 0 : _b[0]) == null ? void 0 : _c.message) ?? "",
|
|
8270
8303
|
name: file.filepath
|
|
8271
8304
|
});
|
|
8272
8305
|
}
|
|
@@ -8303,16 +8336,15 @@ class JsonReporter$1 {
|
|
|
8303
8336
|
}
|
|
8304
8337
|
}
|
|
8305
8338
|
async getFailureLocation(test) {
|
|
8306
|
-
var _a;
|
|
8307
|
-
const error = (_a = test.result) == null ? void 0 : _a.
|
|
8339
|
+
var _a, _b;
|
|
8340
|
+
const error = (_b = (_a = test.result) == null ? void 0 : _a.errors) == null ? void 0 : _b[0];
|
|
8308
8341
|
if (!error)
|
|
8309
8342
|
return;
|
|
8310
8343
|
const stack = parseStacktrace(error);
|
|
8311
8344
|
const frame = stack[stack.length - 1];
|
|
8312
8345
|
if (!frame)
|
|
8313
8346
|
return;
|
|
8314
|
-
|
|
8315
|
-
return { line: pos.line, column: pos.column };
|
|
8347
|
+
return { line: frame.line, column: frame.column };
|
|
8316
8348
|
}
|
|
8317
8349
|
}
|
|
8318
8350
|
|
|
@@ -8330,10 +8362,13 @@ class VerboseReporter extends DefaultReporter {
|
|
|
8330
8362
|
if (task && task.type === "test" && ((_a = task.result) == null ? void 0 : _a.state) && ((_b = task.result) == null ? void 0 : _b.state) !== "run") {
|
|
8331
8363
|
let title = ` ${getStateSymbol(task)} ${getFullName(task)}`;
|
|
8332
8364
|
if (this.ctx.config.logHeapUsage && task.result.heap != null)
|
|
8333
|
-
title +=
|
|
8365
|
+
title += c.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
|
|
8334
8366
|
this.ctx.logger.log(title);
|
|
8335
|
-
if (task.result.state === "fail")
|
|
8336
|
-
|
|
8367
|
+
if (task.result.state === "fail") {
|
|
8368
|
+
(_c = task.result.errors) == null ? void 0 : _c.forEach((error) => {
|
|
8369
|
+
this.ctx.logger.log(c.red(` ${F_RIGHT} ${error == null ? void 0 : error.message}`));
|
|
8370
|
+
});
|
|
8371
|
+
}
|
|
8337
8372
|
}
|
|
8338
8373
|
}
|
|
8339
8374
|
}
|
|
@@ -8399,22 +8434,23 @@ class TapReporter {
|
|
|
8399
8434
|
this.logger.log("}");
|
|
8400
8435
|
} else {
|
|
8401
8436
|
this.logger.log(`${ok} ${id} - ${tapString(task.name)}${comment}`);
|
|
8402
|
-
if (((_b = task.result) == null ? void 0 : _b.state) === "fail" && task.result.
|
|
8403
|
-
this.logger.indent();
|
|
8404
|
-
const error = task.result.error;
|
|
8405
|
-
const stacks = parseStacktrace(error);
|
|
8406
|
-
const stack = stacks[0];
|
|
8407
|
-
this.logger.log("---");
|
|
8408
|
-
this.logger.log("error:");
|
|
8437
|
+
if (((_b = task.result) == null ? void 0 : _b.state) === "fail" && task.result.errors) {
|
|
8409
8438
|
this.logger.indent();
|
|
8410
|
-
|
|
8411
|
-
|
|
8412
|
-
|
|
8413
|
-
this.logger.log(
|
|
8414
|
-
|
|
8415
|
-
this.logger.
|
|
8416
|
-
this.
|
|
8417
|
-
|
|
8439
|
+
task.result.errors.forEach((error) => {
|
|
8440
|
+
const stacks = parseStacktrace(error);
|
|
8441
|
+
const stack = stacks[0];
|
|
8442
|
+
this.logger.log("---");
|
|
8443
|
+
this.logger.log("error:");
|
|
8444
|
+
this.logger.indent();
|
|
8445
|
+
this.logErrorDetails(error);
|
|
8446
|
+
this.logger.unindent();
|
|
8447
|
+
if (stack)
|
|
8448
|
+
this.logger.log(`at: ${yamlString(`${stack.file}:${stack.line}:${stack.column}`)}`);
|
|
8449
|
+
if (error.showDiff) {
|
|
8450
|
+
this.logger.log(`actual: ${yamlString(error.actual)}`);
|
|
8451
|
+
this.logger.log(`expected: ${yamlString(error.expected)}`);
|
|
8452
|
+
}
|
|
8453
|
+
});
|
|
8418
8454
|
this.logger.log("...");
|
|
8419
8455
|
this.logger.unindent();
|
|
8420
8456
|
}
|
|
@@ -8505,9 +8541,8 @@ class JUnitReporter {
|
|
|
8505
8541
|
await this.baseLog(escapeXML(errorDetails));
|
|
8506
8542
|
const stack = parseStacktrace(error);
|
|
8507
8543
|
for (const frame of stack) {
|
|
8508
|
-
const pos = frame.sourcePos ?? frame;
|
|
8509
8544
|
const path = relative(this.ctx.config.root, frame.file);
|
|
8510
|
-
await this.baseLog(` ${F_POINTER} ${[frame.method, `${path}:${
|
|
8545
|
+
await this.baseLog(` ${F_POINTER} ${[frame.method, `${path}:${frame.line}:${frame.column}`].filter(Boolean).join(" ")}`);
|
|
8511
8546
|
if (frame.file in this.ctx.state.filesMap)
|
|
8512
8547
|
break;
|
|
8513
8548
|
}
|
|
@@ -8531,21 +8566,23 @@ class JUnitReporter {
|
|
|
8531
8566
|
name: task.name,
|
|
8532
8567
|
time: getDuration(task)
|
|
8533
8568
|
}, async () => {
|
|
8534
|
-
var _a;
|
|
8569
|
+
var _a, _b;
|
|
8535
8570
|
await this.writeLogs(task, "out");
|
|
8536
8571
|
await this.writeLogs(task, "err");
|
|
8537
8572
|
if (task.mode === "skip" || task.mode === "todo")
|
|
8538
8573
|
await this.logger.log("<skipped/>");
|
|
8539
8574
|
if (((_a = task.result) == null ? void 0 : _a.state) === "fail") {
|
|
8540
|
-
const
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8544
|
-
|
|
8545
|
-
|
|
8546
|
-
|
|
8547
|
-
|
|
8548
|
-
|
|
8575
|
+
const promises = ((_b = task.result.errors) == null ? void 0 : _b.map(async (error) => {
|
|
8576
|
+
await this.writeElement("failure", {
|
|
8577
|
+
message: error == null ? void 0 : error.message,
|
|
8578
|
+
type: (error == null ? void 0 : error.name) ?? (error == null ? void 0 : error.nameStr)
|
|
8579
|
+
}, async () => {
|
|
8580
|
+
if (!error)
|
|
8581
|
+
return;
|
|
8582
|
+
await this.writeErrorDetails(error);
|
|
8583
|
+
});
|
|
8584
|
+
})) || [];
|
|
8585
|
+
await Promise.all(promises);
|
|
8549
8586
|
}
|
|
8550
8587
|
});
|
|
8551
8588
|
}
|
|
@@ -8695,7 +8732,7 @@ function formatFilepath(path) {
|
|
|
8695
8732
|
if (firstDot < 0)
|
|
8696
8733
|
firstDot = basename.length;
|
|
8697
8734
|
firstDot += lastSlash;
|
|
8698
|
-
return
|
|
8735
|
+
return c.dim(path.slice(0, lastSlash)) + path.slice(lastSlash, firstDot) + c.dim(path.slice(firstDot));
|
|
8699
8736
|
}
|
|
8700
8737
|
function formatNumber(number) {
|
|
8701
8738
|
const res = String(number.toFixed(number < 100 ? 4 : 2)).split(".");
|
|
@@ -8711,7 +8748,7 @@ function renderTableHead(tasks) {
|
|
|
8711
8748
|
return `${" ".repeat(3)}${tableHead.map((i, idx) => {
|
|
8712
8749
|
const width = Math.max(...allItems.map((i2) => i2[idx].length));
|
|
8713
8750
|
return idx ? i.padStart(width, " ") : i.padEnd(width, " ");
|
|
8714
|
-
}).map(
|
|
8751
|
+
}).map(c.bold).join(" ")}`;
|
|
8715
8752
|
}
|
|
8716
8753
|
function renderBenchmarkItems(result) {
|
|
8717
8754
|
return [
|
|
@@ -8745,17 +8782,17 @@ function renderBenchmark(task, tasks) {
|
|
|
8745
8782
|
});
|
|
8746
8783
|
return [
|
|
8747
8784
|
padded[0],
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
|
|
8751
|
-
|
|
8752
|
-
|
|
8753
|
-
|
|
8754
|
-
|
|
8755
|
-
|
|
8756
|
-
|
|
8757
|
-
|
|
8758
|
-
result.rank === 1 ?
|
|
8785
|
+
c.blue(padded[1]),
|
|
8786
|
+
c.cyan(padded[2]),
|
|
8787
|
+
c.cyan(padded[3]),
|
|
8788
|
+
c.cyan(padded[4]),
|
|
8789
|
+
c.cyan(padded[5]),
|
|
8790
|
+
c.cyan(padded[6]),
|
|
8791
|
+
c.cyan(padded[7]),
|
|
8792
|
+
c.cyan(padded[8]),
|
|
8793
|
+
c.dim(padded[9]),
|
|
8794
|
+
c.dim(padded[10]),
|
|
8795
|
+
result.rank === 1 ? c.bold(c.green(" fastest")) : result.rank === benchs.length && benchs.length > 2 ? c.bold(c.gray(" slowest")) : ""
|
|
8759
8796
|
].join(" ");
|
|
8760
8797
|
}
|
|
8761
8798
|
function renderTree(tasks, options, level = 0) {
|
|
@@ -8771,15 +8808,15 @@ ${padding}`;
|
|
|
8771
8808
|
prefix += ` ${getStateSymbol(task)} `;
|
|
8772
8809
|
let suffix = "";
|
|
8773
8810
|
if (task.type === "suite")
|
|
8774
|
-
suffix +=
|
|
8811
|
+
suffix += c.dim(` (${getTests(task).length})`);
|
|
8775
8812
|
if (task.mode === "skip" || task.mode === "todo")
|
|
8776
|
-
suffix += ` ${
|
|
8813
|
+
suffix += ` ${c.dim(c.gray("[skipped]"))}`;
|
|
8777
8814
|
if (((_a = task.result) == null ? void 0 : _a.duration) != null) {
|
|
8778
8815
|
if (task.result.duration > DURATION_LONG)
|
|
8779
|
-
suffix +=
|
|
8816
|
+
suffix += c.yellow(` ${Math.round(task.result.duration)}${c.dim("ms")}`);
|
|
8780
8817
|
}
|
|
8781
8818
|
if (options.showHeap && ((_b = task.result) == null ? void 0 : _b.heap) != null)
|
|
8782
|
-
suffix +=
|
|
8819
|
+
suffix += c.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
|
|
8783
8820
|
let name = task.name;
|
|
8784
8821
|
if (level === 0)
|
|
8785
8822
|
name = formatFilepath(name);
|
|
@@ -8794,7 +8831,7 @@ ${padding}`;
|
|
|
8794
8831
|
}
|
|
8795
8832
|
if (data != null) {
|
|
8796
8833
|
const out = `${" ".repeat(level)}${F_RIGHT} ${data}`;
|
|
8797
|
-
output.push(` ${
|
|
8834
|
+
output.push(` ${c.gray(cliTruncate(out, getCols(-3)))}`);
|
|
8798
8835
|
}
|
|
8799
8836
|
}
|
|
8800
8837
|
if (task.type === "suite" && task.tasks.length > 0) {
|
|
@@ -8846,7 +8883,7 @@ class TableReporter extends BaseReporter {
|
|
|
8846
8883
|
}
|
|
8847
8884
|
async onTestRemoved(trigger) {
|
|
8848
8885
|
await this.stopListRender();
|
|
8849
|
-
this.ctx.logger.clearScreen(
|
|
8886
|
+
this.ctx.logger.clearScreen(c.yellow("Test removed...") + (trigger ? c.dim(` [ ${this.relative(trigger)} ]
|
|
8850
8887
|
`) : ""), true);
|
|
8851
8888
|
const files = this.ctx.state.getFiles(this.watchFilters);
|
|
8852
8889
|
createTableRenderer(files, this.rendererOptions).stop();
|
|
@@ -9076,10 +9113,11 @@ const defaultCoverageExcludes = [
|
|
|
9076
9113
|
"**/.{eslint,mocha,prettier}rc.{js,cjs,yml}"
|
|
9077
9114
|
];
|
|
9078
9115
|
const coverageConfigDefaults = {
|
|
9116
|
+
all: false,
|
|
9079
9117
|
provider: "c8",
|
|
9080
9118
|
enabled: false,
|
|
9081
9119
|
clean: true,
|
|
9082
|
-
cleanOnRerun:
|
|
9120
|
+
cleanOnRerun: true,
|
|
9083
9121
|
reportsDirectory: "./coverage",
|
|
9084
9122
|
excludeNodeModules: true,
|
|
9085
9123
|
exclude: defaultCoverageExcludes,
|
|
@@ -9341,8 +9379,8 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
9341
9379
|
if (options.dom) {
|
|
9342
9380
|
if (((_a = viteConfig.test) == null ? void 0 : _a.environment) != null && viteConfig.test.environment !== "happy-dom") {
|
|
9343
9381
|
console.warn(
|
|
9344
|
-
|
|
9345
|
-
`${
|
|
9382
|
+
c.yellow(
|
|
9383
|
+
`${c.inverse(c.yellow(" Vitest "))} Your config.test.environment ("${viteConfig.test.environment}") conflicts with --dom flag ("happy-dom"), ignoring "${viteConfig.test.environment}"`
|
|
9346
9384
|
)
|
|
9347
9385
|
);
|
|
9348
9386
|
}
|
|
@@ -9422,10 +9460,8 @@ function resolveConfig(mode, options, viteConfig) {
|
|
|
9422
9460
|
if (options.related)
|
|
9423
9461
|
resolved.related = toArray(options.related).map((file) => resolve(resolved.root, file));
|
|
9424
9462
|
if (mode !== "benchmark") {
|
|
9425
|
-
|
|
9426
|
-
|
|
9427
|
-
...toArray(resolved.reporter)
|
|
9428
|
-
])).filter(Boolean);
|
|
9463
|
+
const reporters = resolved.reporter ?? resolved.reporters;
|
|
9464
|
+
resolved.reporters = Array.from(new Set(toArray(reporters))).filter(Boolean);
|
|
9429
9465
|
}
|
|
9430
9466
|
if (!resolved.reporters.length)
|
|
9431
9467
|
resolved.reporters.push("default");
|
|
@@ -9941,14 +9977,101 @@ createLogUpdate(process$1.stdout);
|
|
|
9941
9977
|
|
|
9942
9978
|
createLogUpdate(process$1.stderr);
|
|
9943
9979
|
|
|
9944
|
-
var version = "0.
|
|
9980
|
+
var version = "0.27.0";
|
|
9945
9981
|
|
|
9946
|
-
function
|
|
9947
|
-
var _a
|
|
9948
|
-
|
|
9949
|
-
|
|
9950
|
-
|
|
9982
|
+
function formatLine(line, outputTruncateLength) {
|
|
9983
|
+
var _a;
|
|
9984
|
+
return cliTruncate(line, (outputTruncateLength ?? (((_a = process.stdout) == null ? void 0 : _a.columns) || 80)) - 4);
|
|
9985
|
+
}
|
|
9986
|
+
function unifiedDiff(actual, expected, options = {}) {
|
|
9987
|
+
if (actual === expected)
|
|
9988
|
+
return "";
|
|
9989
|
+
const { outputTruncateLength, outputDiffLines, outputDiffMaxLines, noColor, showLegend = true } = options;
|
|
9990
|
+
const indent = " ";
|
|
9991
|
+
const diffLimit = outputDiffLines || 15;
|
|
9992
|
+
const diffMaxLines = outputDiffMaxLines || 50;
|
|
9993
|
+
const counts = {
|
|
9994
|
+
"+": 0,
|
|
9995
|
+
"-": 0
|
|
9996
|
+
};
|
|
9997
|
+
let previousState = null;
|
|
9998
|
+
let previousCount = 0;
|
|
9999
|
+
const str = (str2) => str2;
|
|
10000
|
+
const dim = noColor ? str : c.dim;
|
|
10001
|
+
const green = noColor ? str : c.green;
|
|
10002
|
+
const red = noColor ? str : c.red;
|
|
10003
|
+
function preprocess(line) {
|
|
10004
|
+
if (!line || line.match(/\\ No newline/))
|
|
10005
|
+
return;
|
|
10006
|
+
const char = line[0];
|
|
10007
|
+
if ("-+".includes(char)) {
|
|
10008
|
+
if (previousState !== char) {
|
|
10009
|
+
previousState = char;
|
|
10010
|
+
previousCount = 0;
|
|
10011
|
+
}
|
|
10012
|
+
previousCount++;
|
|
10013
|
+
counts[char]++;
|
|
10014
|
+
if (previousCount === diffLimit)
|
|
10015
|
+
return dim(`${char} ...`);
|
|
10016
|
+
else if (previousCount > diffLimit)
|
|
10017
|
+
return;
|
|
10018
|
+
}
|
|
10019
|
+
return line;
|
|
10020
|
+
}
|
|
10021
|
+
const msg = createPatch("string", expected, actual);
|
|
10022
|
+
let lines = msg.split("\n").slice(5).map(preprocess).filter(Boolean);
|
|
10023
|
+
let moreLines = 0;
|
|
10024
|
+
const isCompact = counts["+"] === 1 && counts["-"] === 1 && lines.length === 2;
|
|
10025
|
+
if (lines.length > diffMaxLines) {
|
|
10026
|
+
const firstDiff = lines.findIndex((line) => line[0] === "-" || line[0] === "+");
|
|
10027
|
+
const displayLines = lines.slice(firstDiff - 2, diffMaxLines);
|
|
10028
|
+
const lastDisplayedIndex = firstDiff - 2 + diffMaxLines;
|
|
10029
|
+
if (lastDisplayedIndex < lines.length)
|
|
10030
|
+
moreLines = lines.length - lastDisplayedIndex;
|
|
10031
|
+
lines = displayLines;
|
|
10032
|
+
}
|
|
10033
|
+
let formatted = lines.map((line) => {
|
|
10034
|
+
line = line.replace(/\\"/g, '"');
|
|
10035
|
+
if (line[0] === "-") {
|
|
10036
|
+
line = formatLine(line.slice(1), outputTruncateLength);
|
|
10037
|
+
if (isCompact)
|
|
10038
|
+
return green(line);
|
|
10039
|
+
return green(`- ${formatLine(line, outputTruncateLength)}`);
|
|
10040
|
+
}
|
|
10041
|
+
if (line[0] === "+") {
|
|
10042
|
+
line = formatLine(line.slice(1), outputTruncateLength);
|
|
10043
|
+
if (isCompact)
|
|
10044
|
+
return red(line);
|
|
10045
|
+
return red(`+ ${formatLine(line, outputTruncateLength)}`);
|
|
10046
|
+
}
|
|
10047
|
+
if (line.match(/@@/))
|
|
10048
|
+
return "--";
|
|
10049
|
+
return ` ${line}`;
|
|
10050
|
+
});
|
|
10051
|
+
if (moreLines)
|
|
10052
|
+
formatted.push(dim(`... ${moreLines} more lines`));
|
|
10053
|
+
if (showLegend) {
|
|
10054
|
+
if (isCompact) {
|
|
10055
|
+
formatted = [
|
|
10056
|
+
`${green("- Expected")} ${formatted[0]}`,
|
|
10057
|
+
`${red("+ Received")} ${formatted[1]}`
|
|
10058
|
+
];
|
|
10059
|
+
} else {
|
|
10060
|
+
if (formatted[0].includes('"'))
|
|
10061
|
+
formatted[0] = formatted[0].replace('"', "");
|
|
10062
|
+
const last = formatted.length - 1;
|
|
10063
|
+
if (formatted[last].endsWith('"'))
|
|
10064
|
+
formatted[last] = formatted[last].slice(0, formatted[last].length - 1);
|
|
10065
|
+
formatted.unshift(
|
|
10066
|
+
green(`- Expected - ${counts["-"]}`),
|
|
10067
|
+
red(`+ Received + ${counts["+"]}`),
|
|
10068
|
+
""
|
|
10069
|
+
);
|
|
10070
|
+
}
|
|
10071
|
+
}
|
|
10072
|
+
return formatted.map((i) => i ? indent + i : i).join("\n");
|
|
9951
10073
|
}
|
|
10074
|
+
|
|
9952
10075
|
async function printError(error, ctx, options = {}) {
|
|
9953
10076
|
const { showCodeFrame = true, fullStack = false, type } = options;
|
|
9954
10077
|
let e = error;
|
|
@@ -9974,15 +10097,12 @@ async function printError(error, ctx, options = {}) {
|
|
|
9974
10097
|
printErrorType(type, ctx);
|
|
9975
10098
|
printErrorMessage(e, ctx.logger);
|
|
9976
10099
|
if (e.frame) {
|
|
9977
|
-
ctx.logger.error(
|
|
10100
|
+
ctx.logger.error(c.yellow(e.frame));
|
|
9978
10101
|
} else {
|
|
9979
|
-
printStack(ctx, stacks, nearest, errorProperties, (s
|
|
10102
|
+
printStack(ctx, stacks, nearest, errorProperties, (s) => {
|
|
9980
10103
|
if (showCodeFrame && s === nearest && nearest) {
|
|
9981
|
-
const
|
|
9982
|
-
|
|
9983
|
-
const sourceCode = readFileSync(file, "utf-8");
|
|
9984
|
-
ctx.logger.error(picocolors.exports.yellow(generateCodeFrame(sourceCode, 4, pos)));
|
|
9985
|
-
}
|
|
10104
|
+
const sourceCode = readFileSync(nearest.file, "utf-8");
|
|
10105
|
+
ctx.logger.error(c.yellow(generateCodeFrame(sourceCode, 4, s.line, s.column)));
|
|
9986
10106
|
}
|
|
9987
10107
|
});
|
|
9988
10108
|
}
|
|
@@ -10001,7 +10121,7 @@ async function printError(error, ctx, options = {}) {
|
|
|
10001
10121
|
}
|
|
10002
10122
|
function printErrorType(type, ctx) {
|
|
10003
10123
|
ctx.logger.error(`
|
|
10004
|
-
${
|
|
10124
|
+
${c.red(divider(c.bold(c.inverse(` ${type} `))))}`);
|
|
10005
10125
|
}
|
|
10006
10126
|
const skipErrorProperties = /* @__PURE__ */ new Set([
|
|
10007
10127
|
"nameStr",
|
|
@@ -10039,16 +10159,16 @@ function handleImportOutsideModuleError(stack, ctx) {
|
|
|
10039
10159
|
name = name.split("/").slice(0, 2).join("/");
|
|
10040
10160
|
else
|
|
10041
10161
|
name = name.split("/")[0];
|
|
10042
|
-
ctx.logger.error(
|
|
10043
|
-
`Module ${path} seems to be an ES Module but shipped in a CommonJS package. You might want to create an issue to the package ${
|
|
10162
|
+
ctx.logger.error(c.yellow(
|
|
10163
|
+
`Module ${path} seems to be an ES Module but shipped in a CommonJS package. You might want to create an issue to the package ${c.bold(`"${name}"`)} asking them to ship the file in .mjs extension or add "type": "module" in their package.json.
|
|
10044
10164
|
|
|
10045
10165
|
As a temporary workaround you can try to inline the package by updating your config:
|
|
10046
10166
|
|
|
10047
|
-
` +
|
|
10167
|
+
` + c.gray(c.dim("// vitest.config.js")) + "\n" + c.green(`export default {
|
|
10048
10168
|
test: {
|
|
10049
10169
|
deps: {
|
|
10050
10170
|
inline: [
|
|
10051
|
-
${
|
|
10171
|
+
${c.yellow(c.bold(`"${name}"`))}
|
|
10052
10172
|
]
|
|
10053
10173
|
}
|
|
10054
10174
|
}
|
|
@@ -10058,8 +10178,8 @@ As a temporary workaround you can try to inline the package by updating your con
|
|
|
10058
10178
|
}
|
|
10059
10179
|
function displayDiff(actual, expected, console, options = {}) {
|
|
10060
10180
|
const diff = unifiedDiff(actual, expected, options);
|
|
10061
|
-
const dim = options.noColor ? (s) => s :
|
|
10062
|
-
const black = options.noColor ? (s) => s :
|
|
10181
|
+
const dim = options.noColor ? (s) => s : c.dim;
|
|
10182
|
+
const black = options.noColor ? (s) => s : c.black;
|
|
10063
10183
|
if (diff)
|
|
10064
10184
|
console.error(diff + "\n");
|
|
10065
10185
|
else if (actual && expected && actual !== '"undefined"' && expected !== '"undefined"')
|
|
@@ -10067,40 +10187,38 @@ function displayDiff(actual, expected, console, options = {}) {
|
|
|
10067
10187
|
}
|
|
10068
10188
|
function printErrorMessage(error, logger) {
|
|
10069
10189
|
const errorName = error.name || error.nameStr || "Unknown Error";
|
|
10070
|
-
logger.error(
|
|
10190
|
+
logger.error(c.red(`${c.bold(errorName)}: ${error.message}`));
|
|
10071
10191
|
}
|
|
10072
10192
|
function printStack(ctx, stack, highlight, errorProperties, onStack) {
|
|
10073
10193
|
if (!stack.length)
|
|
10074
10194
|
return;
|
|
10075
10195
|
const logger = ctx.logger;
|
|
10076
10196
|
for (const frame of stack) {
|
|
10077
|
-
const
|
|
10078
|
-
const
|
|
10079
|
-
|
|
10080
|
-
|
|
10081
|
-
logger.error(color(` ${picocolors.exports.dim(F_POINTER)} ${[frame.method, picocolors.exports.dim(`${path}:${pos.line}:${pos.column}`)].filter(Boolean).join(" ")}`));
|
|
10082
|
-
onStack == null ? void 0 : onStack(frame, pos);
|
|
10197
|
+
const color = frame === highlight ? c.yellow : c.gray;
|
|
10198
|
+
const path = relative(ctx.config.root, frame.file);
|
|
10199
|
+
logger.error(color(` ${c.dim(F_POINTER)} ${[frame.method, c.dim(`${path}:${frame.line}:${frame.column}`)].filter(Boolean).join(" ")}`));
|
|
10200
|
+
onStack == null ? void 0 : onStack(frame);
|
|
10083
10201
|
if (frame.file in ctx.state.filesMap)
|
|
10084
10202
|
break;
|
|
10085
10203
|
}
|
|
10086
10204
|
logger.error();
|
|
10087
10205
|
const hasProperties = Object.keys(errorProperties).length > 0;
|
|
10088
10206
|
if (hasProperties) {
|
|
10089
|
-
logger.error(
|
|
10207
|
+
logger.error(c.red(c.dim(divider())));
|
|
10090
10208
|
const propertiesString = stringify$5(errorProperties, 10, { printBasicPrototype: false });
|
|
10091
|
-
logger.error(
|
|
10209
|
+
logger.error(c.red(c.bold("Serialized Error:")), c.gray(propertiesString));
|
|
10092
10210
|
}
|
|
10093
10211
|
}
|
|
10094
|
-
function generateCodeFrame(source, indent = 0,
|
|
10212
|
+
function generateCodeFrame(source, indent = 0, lineNumber, columnNumber, range = 2) {
|
|
10095
10213
|
var _a;
|
|
10096
|
-
start =
|
|
10097
|
-
end =
|
|
10214
|
+
const start = positionToOffset(source, lineNumber, columnNumber);
|
|
10215
|
+
const end = start;
|
|
10098
10216
|
const lines = source.split(lineSplitRE);
|
|
10099
10217
|
let count = 0;
|
|
10100
10218
|
let res = [];
|
|
10101
10219
|
const columns = ((_a = process.stdout) == null ? void 0 : _a.columns) || 80;
|
|
10102
10220
|
function lineNo(no = "") {
|
|
10103
|
-
return
|
|
10221
|
+
return c.gray(`${String(no).padStart(3, " ")}| `);
|
|
10104
10222
|
}
|
|
10105
10223
|
for (let i = 0; i < lines.length; i++) {
|
|
10106
10224
|
count += lines[i].length + 1;
|
|
@@ -10115,11 +10233,11 @@ function generateCodeFrame(source, indent = 0, start = 0, end, range = 2) {
|
|
|
10115
10233
|
if (j === i) {
|
|
10116
10234
|
const pad = start - (count - lineLength);
|
|
10117
10235
|
const length = Math.max(1, end > count ? lineLength - pad : end - start);
|
|
10118
|
-
res.push(lineNo() + " ".repeat(pad) +
|
|
10236
|
+
res.push(lineNo() + " ".repeat(pad) + c.red("^".repeat(length)));
|
|
10119
10237
|
} else if (j > i) {
|
|
10120
10238
|
if (end > count) {
|
|
10121
10239
|
const length = Math.max(1, Math.min(end - count, lineLength));
|
|
10122
|
-
res.push(lineNo() +
|
|
10240
|
+
res.push(lineNo() + c.red("^".repeat(length)));
|
|
10123
10241
|
}
|
|
10124
10242
|
count += lineLength + 1;
|
|
10125
10243
|
}
|
|
@@ -10184,62 +10302,62 @@ class Logger {
|
|
|
10184
10302
|
}
|
|
10185
10303
|
printNoTestFound(filters) {
|
|
10186
10304
|
const config = this.ctx.config;
|
|
10187
|
-
const comma =
|
|
10305
|
+
const comma = c.dim(", ");
|
|
10188
10306
|
if (filters == null ? void 0 : filters.length)
|
|
10189
|
-
this.console.error(
|
|
10307
|
+
this.console.error(c.dim("filter: ") + c.yellow(filters.join(comma)));
|
|
10190
10308
|
if (config.include)
|
|
10191
|
-
this.console.error(
|
|
10309
|
+
this.console.error(c.dim("include: ") + c.yellow(config.include.join(comma)));
|
|
10192
10310
|
if (config.exclude)
|
|
10193
|
-
this.console.error(
|
|
10311
|
+
this.console.error(c.dim("exclude: ") + c.yellow(config.exclude.join(comma)));
|
|
10194
10312
|
if (config.watchExclude)
|
|
10195
|
-
this.console.error(
|
|
10313
|
+
this.console.error(c.dim("watch exclude: ") + c.yellow(config.watchExclude.join(comma)));
|
|
10196
10314
|
if (config.passWithNoTests)
|
|
10197
10315
|
this.log(`No ${config.mode} files found, exiting with code 0
|
|
10198
10316
|
`);
|
|
10199
10317
|
else
|
|
10200
|
-
this.error(
|
|
10318
|
+
this.error(c.red(`
|
|
10201
10319
|
No ${config.mode} files found, exiting with code 1`));
|
|
10202
10320
|
}
|
|
10203
10321
|
printBanner() {
|
|
10204
10322
|
var _a, _b, _c;
|
|
10205
10323
|
this.log();
|
|
10206
|
-
const versionTest = this.ctx.config.watch ?
|
|
10207
|
-
const mode = this.ctx.config.watch ?
|
|
10208
|
-
this.log(`${
|
|
10324
|
+
const versionTest = this.ctx.config.watch ? c.blue(`v${version}`) : c.cyan(`v${version}`);
|
|
10325
|
+
const mode = this.ctx.config.watch ? c.blue(" DEV ") : c.cyan(" RUN ");
|
|
10326
|
+
this.log(`${c.inverse(c.bold(mode))} ${versionTest} ${c.gray(this.ctx.config.root)}`);
|
|
10209
10327
|
if (this.ctx.config.browser)
|
|
10210
|
-
this.log(
|
|
10328
|
+
this.log(c.dim(c.green(` Browser runner started at http://${((_a = this.ctx.config.api) == null ? void 0 : _a.host) || "localhost"}:${c.bold(`${this.ctx.server.config.server.port}`)}`)));
|
|
10211
10329
|
else if (this.ctx.config.ui)
|
|
10212
|
-
this.log(
|
|
10330
|
+
this.log(c.dim(c.green(` UI started at http://${((_b = this.ctx.config.api) == null ? void 0 : _b.host) || "localhost"}:${c.bold(`${this.ctx.server.config.server.port}`)}${this.ctx.config.uiBase}`)));
|
|
10213
10331
|
else if (this.ctx.config.api)
|
|
10214
|
-
this.log(
|
|
10332
|
+
this.log(c.dim(c.green(` API started at http://${((_c = this.ctx.config.api) == null ? void 0 : _c.host) || "localhost"}:${c.bold(`${this.ctx.config.api.port}`)}`)));
|
|
10215
10333
|
if (this.ctx.coverageProvider)
|
|
10216
|
-
this.log(
|
|
10334
|
+
this.log(c.dim(" Coverage enabled with ") + c.yellow(this.ctx.coverageProvider.name));
|
|
10217
10335
|
this.log();
|
|
10218
10336
|
}
|
|
10219
10337
|
async printUnhandledErrors(errors) {
|
|
10220
|
-
const errorMessage =
|
|
10338
|
+
const errorMessage = c.red(c.bold(
|
|
10221
10339
|
`
|
|
10222
10340
|
Vitest caught ${errors.length} unhandled error${errors.length > 1 ? "s" : ""} during the test run.
|
|
10223
10341
|
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.`
|
|
10224
10342
|
));
|
|
10225
|
-
this.log(
|
|
10343
|
+
this.log(c.red(divider(c.bold(c.inverse(" Unhandled Errors ")))));
|
|
10226
10344
|
this.log(errorMessage);
|
|
10227
10345
|
await Promise.all(errors.map(async (err) => {
|
|
10228
10346
|
await this.printError(err, true, err.type || "Unhandled Error");
|
|
10229
10347
|
}));
|
|
10230
|
-
this.log(
|
|
10348
|
+
this.log(c.red(divider()));
|
|
10231
10349
|
}
|
|
10232
10350
|
async printSourceTypeErrors(errors) {
|
|
10233
|
-
const errorMessage =
|
|
10351
|
+
const errorMessage = c.red(c.bold(
|
|
10234
10352
|
`
|
|
10235
10353
|
Vitest found ${errors.length} error${errors.length > 1 ? "s" : ""} not related to your test files.`
|
|
10236
10354
|
));
|
|
10237
|
-
this.log(
|
|
10355
|
+
this.log(c.red(divider(c.bold(c.inverse(" Source Errors ")))));
|
|
10238
10356
|
this.log(errorMessage);
|
|
10239
10357
|
await Promise.all(errors.map(async (err) => {
|
|
10240
10358
|
await this.printError(err, true);
|
|
10241
10359
|
}));
|
|
10242
|
-
this.log(
|
|
10360
|
+
this.log(c.red(divider()));
|
|
10243
10361
|
}
|
|
10244
10362
|
}
|
|
10245
10363
|
|
|
@@ -10277,7 +10395,7 @@ class Vitest {
|
|
|
10277
10395
|
this.state = new StateManager();
|
|
10278
10396
|
this.cache = new VitestCache();
|
|
10279
10397
|
this.snapshot = new SnapshotManager({ ...resolved.snapshotOptions });
|
|
10280
|
-
if (this.config.watch)
|
|
10398
|
+
if (this.config.watch && this.mode !== "typecheck")
|
|
10281
10399
|
this.registerWatcher();
|
|
10282
10400
|
this.vitenode = new ViteNodeServer(server, this.config);
|
|
10283
10401
|
const node = this.vitenode;
|
|
@@ -10347,12 +10465,14 @@ class Vitest {
|
|
|
10347
10465
|
this.configOverride || {}
|
|
10348
10466
|
);
|
|
10349
10467
|
}
|
|
10350
|
-
async typecheck(filters) {
|
|
10351
|
-
const
|
|
10468
|
+
async typecheck(filters = []) {
|
|
10469
|
+
const { include, exclude } = this.config.typecheck;
|
|
10470
|
+
const testsFilesList = await this.globFiles(filters, include, exclude);
|
|
10352
10471
|
const checker = new Typechecker(this, testsFilesList);
|
|
10353
10472
|
this.typechecker = checker;
|
|
10354
10473
|
checker.onParseEnd(async ({ files, sourceErrors }) => {
|
|
10355
10474
|
this.state.collectFiles(checker.getTestFiles());
|
|
10475
|
+
await this.report("onTaskUpdate", checker.getTestPacks());
|
|
10356
10476
|
await this.report("onCollected");
|
|
10357
10477
|
if (!files.length) {
|
|
10358
10478
|
this.logger.printNoTestFound();
|
|
@@ -10385,8 +10505,10 @@ class Vitest {
|
|
|
10385
10505
|
await this.report("onWatcherRerun", testsFilesList, "File change detected. Triggering rerun.");
|
|
10386
10506
|
await checker.collectTests();
|
|
10387
10507
|
this.state.collectFiles(checker.getTestFiles());
|
|
10508
|
+
await this.report("onTaskUpdate", checker.getTestPacks());
|
|
10388
10509
|
await this.report("onCollected");
|
|
10389
10510
|
});
|
|
10511
|
+
await checker.prepare();
|
|
10390
10512
|
await checker.collectTests();
|
|
10391
10513
|
await checker.start();
|
|
10392
10514
|
}
|
|
@@ -10415,7 +10537,7 @@ class Vitest {
|
|
|
10415
10537
|
await Promise.all(files.map((file) => this.cache.stats.updateStats(file)));
|
|
10416
10538
|
await this.runFiles(files);
|
|
10417
10539
|
if (this.coverageProvider) {
|
|
10418
|
-
this.logger.log(
|
|
10540
|
+
this.logger.log(c.blue(" % ") + c.dim("Coverage report from ") + c.yellow(this.coverageProvider.name));
|
|
10419
10541
|
await this.coverageProvider.reportCoverage();
|
|
10420
10542
|
}
|
|
10421
10543
|
if (this.config.watch && !this.config.browser)
|
|
@@ -10442,13 +10564,13 @@ class Vitest {
|
|
|
10442
10564
|
}
|
|
10443
10565
|
async filterTestsBySource(tests) {
|
|
10444
10566
|
if (this.config.changed && !this.config.related) {
|
|
10445
|
-
const { VitestGit } = await import('./chunk-node-git.
|
|
10567
|
+
const { VitestGit } = await import('./chunk-node-git.543e964a.js');
|
|
10446
10568
|
const vitestGit = new VitestGit(this.config.root);
|
|
10447
10569
|
const related2 = await vitestGit.findChangedFiles({
|
|
10448
10570
|
changedSince: this.config.changed
|
|
10449
10571
|
});
|
|
10450
10572
|
if (!related2) {
|
|
10451
|
-
this.logger.error(
|
|
10573
|
+
this.logger.error(c.red("Could not find Git root. Have you initialized git with `git init`?\n"));
|
|
10452
10574
|
process.exit(1);
|
|
10453
10575
|
}
|
|
10454
10576
|
this.config.related = Array.from(new Set(related2));
|
|
@@ -10668,8 +10790,7 @@ class Vitest {
|
|
|
10668
10790
|
);
|
|
10669
10791
|
}));
|
|
10670
10792
|
}
|
|
10671
|
-
async
|
|
10672
|
-
const { include, exclude, includeSource } = this.config;
|
|
10793
|
+
async globFiles(filters, include, exclude) {
|
|
10673
10794
|
const globOptions = {
|
|
10674
10795
|
absolute: true,
|
|
10675
10796
|
dot: true,
|
|
@@ -10681,10 +10802,13 @@ class Vitest {
|
|
|
10681
10802
|
filters = filters.map((f) => toNamespacedPath(f));
|
|
10682
10803
|
if (filters.length)
|
|
10683
10804
|
testFiles = testFiles.filter((i) => filters.some((f) => i.includes(f)));
|
|
10805
|
+
return testFiles;
|
|
10806
|
+
}
|
|
10807
|
+
async globTestFiles(filters = []) {
|
|
10808
|
+
const { include, exclude, includeSource } = this.config;
|
|
10809
|
+
const testFiles = await this.globFiles(filters, include, exclude);
|
|
10684
10810
|
if (includeSource) {
|
|
10685
|
-
|
|
10686
|
-
if (filters.length)
|
|
10687
|
-
files = files.filter((i) => filters.some((f) => i.includes(f)));
|
|
10811
|
+
const files = await this.globFiles(filters, includeSource, exclude);
|
|
10688
10812
|
await Promise.all(files.map(async (file) => {
|
|
10689
10813
|
try {
|
|
10690
10814
|
const code = await promises.readFile(file, "utf-8");
|
|
@@ -10751,7 +10875,10 @@ const EnvReplacerPlugin = () => {
|
|
|
10751
10875
|
if (s) {
|
|
10752
10876
|
return {
|
|
10753
10877
|
code: s.toString(),
|
|
10754
|
-
map: s.generateMap({
|
|
10878
|
+
map: s.generateMap({
|
|
10879
|
+
hires: true,
|
|
10880
|
+
source: cleanUrl(id)
|
|
10881
|
+
})
|
|
10755
10882
|
};
|
|
10756
10883
|
}
|
|
10757
10884
|
}
|
|
@@ -10807,7 +10934,7 @@ const GlobalSetupPlugin = (ctx) => {
|
|
|
10807
10934
|
}
|
|
10808
10935
|
} catch (e) {
|
|
10809
10936
|
ctx.logger.error(`
|
|
10810
|
-
${
|
|
10937
|
+
${c.red(divider(c.bold(c.inverse(" Error during global setup "))))}`);
|
|
10811
10938
|
await ctx.logger.printError(e);
|
|
10812
10939
|
process.exit(1);
|
|
10813
10940
|
}
|
|
@@ -10990,7 +11117,7 @@ function CSSEnablerPlugin(ctx) {
|
|
|
10990
11117
|
})`;
|
|
10991
11118
|
return { code };
|
|
10992
11119
|
}
|
|
10993
|
-
return { code: "" };
|
|
11120
|
+
return { code: 'export default ""' };
|
|
10994
11121
|
}
|
|
10995
11122
|
}
|
|
10996
11123
|
];
|
|
@@ -11133,7 +11260,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
|
|
|
11133
11260
|
try {
|
|
11134
11261
|
await ctx.setServer(options, server);
|
|
11135
11262
|
if (options.api && options.watch)
|
|
11136
|
-
(await import('./chunk-api-setup.
|
|
11263
|
+
(await import('./chunk-api-setup.16ac28c0.js')).setup(ctx);
|
|
11137
11264
|
} catch (err) {
|
|
11138
11265
|
ctx.logger.printError(err, true);
|
|
11139
11266
|
process.exit(1);
|
|
@@ -11182,8 +11309,8 @@ const keys = [
|
|
|
11182
11309
|
function printShortcutsHelp() {
|
|
11183
11310
|
stdout().write(
|
|
11184
11311
|
`
|
|
11185
|
-
${
|
|
11186
|
-
${keys.map((i) =>
|
|
11312
|
+
${c.bold(" Watch Usage")}
|
|
11313
|
+
${keys.map((i) => c.dim(" press ") + c.reset(c.bold(i[0])) + c.dim(` to ${i[1]}`)).join("\n")}
|
|
11187
11314
|
`
|
|
11188
11315
|
);
|
|
11189
11316
|
}
|