vitest 0.10.1 → 0.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-integrations-globals.a759742a.js → chunk-integrations-globals.16d9702f.js} +1 -1
- package/dist/{chunk-vite-node-externalize.4dd7260b.js → chunk-vite-node-externalize.4255f25f.js} +18 -7
- package/dist/cli.js +1 -1
- package/dist/entry.js +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/node.d.ts +6 -0
- package/dist/node.js +1 -1
- package/dist/{vendor-entry.9dd6e6e6.js → vendor-entry.17835032.js} +6 -1
- package/package.json +3 -3
package/dist/{chunk-vite-node-externalize.4dd7260b.js → chunk-vite-node-externalize.4255f25f.js}
RENAMED
|
@@ -23,7 +23,7 @@ import { e as stripAnsi, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as
|
|
|
23
23
|
import MagicString from './chunk-magic-string.d5e0e473.js';
|
|
24
24
|
import { p as prompts } from './vendor-index.405e58ef.js';
|
|
25
25
|
|
|
26
|
-
var version = "0.10.
|
|
26
|
+
var version = "0.10.2";
|
|
27
27
|
|
|
28
28
|
function stripFinalNewline(input) {
|
|
29
29
|
const LF = typeof input === 'string' ? '\n' : '\n'.charCodeAt();
|
|
@@ -8455,6 +8455,7 @@ const WAIT_FOR_CHANGE_PASS = `
|
|
|
8455
8455
|
${picocolors.exports.bold(picocolors.exports.inverse(picocolors.exports.green(" PASS ")))}${picocolors.exports.green(" Waiting for file changes...")}`;
|
|
8456
8456
|
const WAIT_FOR_CHANGE_FAIL = `
|
|
8457
8457
|
${picocolors.exports.bold(picocolors.exports.inverse(picocolors.exports.red(" FAIL ")))}${picocolors.exports.red(" Tests failed. Watching for file changes...")}`;
|
|
8458
|
+
const DURATION_LONG$1 = 300;
|
|
8458
8459
|
class BaseReporter {
|
|
8459
8460
|
constructor() {
|
|
8460
8461
|
this.start = 0;
|
|
@@ -8515,8 +8516,12 @@ Please, resolve all the errors to make sure your tests are not affected.`));
|
|
|
8515
8516
|
if (skipped.length)
|
|
8516
8517
|
state += ` ${picocolors.exports.dim("|")} ${picocolors.exports.yellow(`${skipped.length} skipped`)}`;
|
|
8517
8518
|
let suffix = picocolors.exports.dim(" (") + state + picocolors.exports.dim(")");
|
|
8518
|
-
if (task.result.duration)
|
|
8519
|
-
|
|
8519
|
+
if (task.result.duration) {
|
|
8520
|
+
const color = task.result.duration > DURATION_LONG$1 ? picocolors.exports.yellow : picocolors.exports.gray;
|
|
8521
|
+
suffix += color(` ${Math.round(task.result.duration)}${picocolors.exports.dim("ms")}`);
|
|
8522
|
+
}
|
|
8523
|
+
if (this.ctx.config.logHeapUsage && task.result.heap != null)
|
|
8524
|
+
suffix += picocolors.exports.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
|
|
8520
8525
|
this.ctx.log(` ${getStateSymbol(task)} ${task.name} ${suffix}`);
|
|
8521
8526
|
for (const test of failed) {
|
|
8522
8527
|
this.ctx.log(picocolors.exports.red(` ${pointer} ${getFullName(test)}`));
|
|
@@ -9151,7 +9156,7 @@ function renderHookState(task, hookName, level = 0) {
|
|
|
9151
9156
|
return "";
|
|
9152
9157
|
}
|
|
9153
9158
|
function renderTree(tasks, options, level = 0) {
|
|
9154
|
-
var _a, _b, _c, _d;
|
|
9159
|
+
var _a, _b, _c, _d, _e;
|
|
9155
9160
|
let output = [];
|
|
9156
9161
|
for (const task of tasks) {
|
|
9157
9162
|
let suffix = "";
|
|
@@ -9164,11 +9169,13 @@ function renderTree(tasks, options, level = 0) {
|
|
|
9164
9169
|
if (task.result.duration > DURATION_LONG)
|
|
9165
9170
|
suffix += picocolors.exports.yellow(` ${Math.round(task.result.duration)}${picocolors.exports.dim("ms")}`);
|
|
9166
9171
|
}
|
|
9172
|
+
if (options.showHeap && ((_b = task.result) == null ? void 0 : _b.heap) != null)
|
|
9173
|
+
suffix += picocolors.exports.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
|
|
9167
9174
|
let name = task.name;
|
|
9168
9175
|
if (level === 0)
|
|
9169
9176
|
name = formatFilepath(name);
|
|
9170
9177
|
output.push(" ".repeat(level) + prefix + name + suffix);
|
|
9171
|
-
if (((
|
|
9178
|
+
if (((_c = task.result) == null ? void 0 : _c.state) !== "pass" && outputMap.get(task) != null) {
|
|
9172
9179
|
let data = outputMap.get(task);
|
|
9173
9180
|
if (typeof data === "string") {
|
|
9174
9181
|
data = stripAnsi(data.trim().split("\n").filter(Boolean).pop());
|
|
@@ -9183,7 +9190,7 @@ function renderTree(tasks, options, level = 0) {
|
|
|
9183
9190
|
output = output.concat(renderHookState(task, "beforeAll", level + 1));
|
|
9184
9191
|
output = output.concat(renderHookState(task, "beforeEach", level + 1));
|
|
9185
9192
|
if (task.type === "suite" && task.tasks.length > 0) {
|
|
9186
|
-
if (((
|
|
9193
|
+
if (((_d = task.result) == null ? void 0 : _d.state) === "fail" || ((_e = task.result) == null ? void 0 : _e.state) === "run" || options.renderSucceed)
|
|
9187
9194
|
output = output.concat(renderTree(task.tasks, options, level + 1));
|
|
9188
9195
|
}
|
|
9189
9196
|
output = output.concat(renderHookState(task, "afterAll", level + 1));
|
|
@@ -9245,6 +9252,7 @@ class DefaultReporter extends BaseReporter {
|
|
|
9245
9252
|
onCollected() {
|
|
9246
9253
|
if (this.isTTY) {
|
|
9247
9254
|
this.rendererOptions.outputStream = this.ctx.outputStream;
|
|
9255
|
+
this.rendererOptions.showHeap = this.ctx.config.logHeapUsage;
|
|
9248
9256
|
const files = this.ctx.state.getFiles(this.watchFilters);
|
|
9249
9257
|
if (!this.renderer)
|
|
9250
9258
|
this.renderer = createListRenderer(files, this.rendererOptions).start();
|
|
@@ -9513,7 +9521,10 @@ class VerboseReporter extends DefaultReporter {
|
|
|
9513
9521
|
for (const pack of packs) {
|
|
9514
9522
|
const task = this.ctx.state.idMap.get(pack[0]);
|
|
9515
9523
|
if (task && task.type === "test" && ((_a = task.result) == null ? void 0 : _a.state) && ((_b = task.result) == null ? void 0 : _b.state) !== "run") {
|
|
9516
|
-
|
|
9524
|
+
let title = ` ${getStateSymbol(task)} ${getFullName(task)}`;
|
|
9525
|
+
if (this.ctx.config.logHeapUsage && task.result.heap != null)
|
|
9526
|
+
title += picocolors.exports.magenta(` ${Math.floor(task.result.heap / 1024 / 1024)} MB heap used`);
|
|
9527
|
+
this.ctx.log(title);
|
|
9517
9528
|
if (task.result.state === "fail")
|
|
9518
9529
|
this.ctx.log(picocolors.exports.red(` ${F_RIGHT} ${(_c = task.result.error) == null ? void 0 : _c.message}`));
|
|
9519
9530
|
}
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
2
|
import { p as picocolors } from './chunk-utils-global.9b434e81.js';
|
|
3
|
-
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.
|
|
3
|
+
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.4255f25f.js';
|
|
4
4
|
import 'tty';
|
|
5
5
|
import 'local-pkg';
|
|
6
6
|
import 'path';
|
package/dist/entry.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -435,6 +435,7 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
435
435
|
interface ListRendererOptions {
|
|
436
436
|
renderSucceed?: boolean;
|
|
437
437
|
outputStream: NodeJS.WritableStream;
|
|
438
|
+
showHeap: boolean;
|
|
438
439
|
}
|
|
439
440
|
declare const createListRenderer: (_tasks: Task[], options: ListRendererOptions) => {
|
|
440
441
|
start(): any;
|
|
@@ -747,6 +748,7 @@ interface TaskResult {
|
|
|
747
748
|
state: TaskState;
|
|
748
749
|
duration?: number;
|
|
749
750
|
startTime?: number;
|
|
751
|
+
heap?: number;
|
|
750
752
|
error?: ErrorWithDiff;
|
|
751
753
|
htmlError?: string;
|
|
752
754
|
hooks?: Partial<Record<keyof SuiteHooks, TaskState>>;
|
|
@@ -1151,6 +1153,10 @@ interface InlineConfig {
|
|
|
1151
1153
|
* Resolve custom snapshot path
|
|
1152
1154
|
*/
|
|
1153
1155
|
resolveSnapshotPath?: (path: string, extension: string) => string;
|
|
1156
|
+
/**
|
|
1157
|
+
* Show heap usage after each test. Usefull for debugging memory leaks.
|
|
1158
|
+
*/
|
|
1159
|
+
logHeapUsage?: boolean;
|
|
1154
1160
|
}
|
|
1155
1161
|
interface UserConfig extends InlineConfig {
|
|
1156
1162
|
/**
|
package/dist/node.d.ts
CHANGED
|
@@ -234,6 +234,7 @@ declare abstract class BaseReporter implements Reporter {
|
|
|
234
234
|
interface ListRendererOptions {
|
|
235
235
|
renderSucceed?: boolean;
|
|
236
236
|
outputStream: NodeJS.WritableStream;
|
|
237
|
+
showHeap: boolean;
|
|
237
238
|
}
|
|
238
239
|
declare const createListRenderer: (_tasks: Task[], options: ListRendererOptions) => {
|
|
239
240
|
start(): any;
|
|
@@ -510,6 +511,7 @@ interface TaskResult {
|
|
|
510
511
|
state: TaskState;
|
|
511
512
|
duration?: number;
|
|
512
513
|
startTime?: number;
|
|
514
|
+
heap?: number;
|
|
513
515
|
error?: ErrorWithDiff;
|
|
514
516
|
htmlError?: string;
|
|
515
517
|
hooks?: Partial<Record<keyof SuiteHooks, TaskState>>;
|
|
@@ -852,6 +854,10 @@ interface InlineConfig {
|
|
|
852
854
|
* Resolve custom snapshot path
|
|
853
855
|
*/
|
|
854
856
|
resolveSnapshotPath?: (path: string, extension: string) => string;
|
|
857
|
+
/**
|
|
858
|
+
* Show heap usage after each test. Usefull for debugging memory leaks.
|
|
859
|
+
*/
|
|
860
|
+
logHeapUsage?: boolean;
|
|
855
861
|
}
|
|
856
862
|
interface UserConfig extends InlineConfig {
|
|
857
863
|
/**
|
package/dist/node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.
|
|
1
|
+
export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.4255f25f.js';
|
|
2
2
|
export { V as VitestRunner } from './chunk-runtime-mocker.ca5ecf98.js';
|
|
3
3
|
import 'buffer';
|
|
4
4
|
import 'path';
|
|
@@ -419,7 +419,7 @@ async function setupGlobalEnv(config) {
|
|
|
419
419
|
globalSetup = true;
|
|
420
420
|
setupConsoleLogSpy();
|
|
421
421
|
if (config.globals)
|
|
422
|
-
(await import('./chunk-integrations-globals.
|
|
422
|
+
(await import('./chunk-integrations-globals.16d9702f.js')).registerApiGlobally();
|
|
423
423
|
}
|
|
424
424
|
function setupDefines(defines) {
|
|
425
425
|
for (const key in defines)
|
|
@@ -867,6 +867,8 @@ async function runTest(test) {
|
|
|
867
867
|
}
|
|
868
868
|
getSnapshotClient().clearTest();
|
|
869
869
|
test.result.duration = now() - start;
|
|
870
|
+
if (workerState.config.logHeapUsage)
|
|
871
|
+
test.result.heap = process.memoryUsage().heapUsed;
|
|
870
872
|
workerState.current = void 0;
|
|
871
873
|
updateTask(test);
|
|
872
874
|
}
|
|
@@ -915,6 +917,9 @@ async function runSuite(suite) {
|
|
|
915
917
|
}
|
|
916
918
|
}
|
|
917
919
|
suite.result.duration = now() - start;
|
|
920
|
+
const workerState = getWorkerState();
|
|
921
|
+
if (workerState.config.logHeapUsage)
|
|
922
|
+
suite.result.heap = process.memoryUsage().heapUsed;
|
|
918
923
|
if (suite.mode === "run") {
|
|
919
924
|
if (!hasTests(suite)) {
|
|
920
925
|
suite.result.state = "fail";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.10.
|
|
4
|
+
"version": "0.10.2",
|
|
5
5
|
"description": "A blazing fast unit test framework powered by Vite",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"vite",
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"@types/node": "^17.0.31",
|
|
94
94
|
"@types/prompts": "^2.4.0",
|
|
95
95
|
"@types/sinonjs__fake-timers": "^8.1.2",
|
|
96
|
-
"@vitest/ui": "0.10.
|
|
96
|
+
"@vitest/ui": "0.10.2",
|
|
97
97
|
"birpc": "^0.2.2",
|
|
98
98
|
"c8": "^7.11.2",
|
|
99
99
|
"cac": "^6.7.12",
|
|
@@ -120,7 +120,7 @@
|
|
|
120
120
|
"source-map-js": "^1.0.2",
|
|
121
121
|
"strip-ansi": "^7.0.1",
|
|
122
122
|
"typescript": "^4.6.4",
|
|
123
|
-
"vite-node": "0.10.
|
|
123
|
+
"vite-node": "0.10.2",
|
|
124
124
|
"ws": "^8.6.0"
|
|
125
125
|
},
|
|
126
126
|
"engines": {
|