vitest 0.10.1 → 0.10.4

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.
@@ -1,5 +1,5 @@
1
1
  import { promises } from 'fs';
2
- import { c as createBirpc } from './chunk-vite-node-utils.c160b239.js';
2
+ import { c as createBirpc } from './chunk-vite-node-utils.3cb38009.js';
3
3
  import require$$0$1 from 'stream';
4
4
  import require$$0 from 'zlib';
5
5
  import require$$3 from 'net';
@@ -9,11 +9,11 @@ import require$$2 from 'events';
9
9
  import require$$1 from 'https';
10
10
  import require$$2$1 from 'http';
11
11
  import url from 'url';
12
- import { A as API_PATH } from './chunk-constants.90075174.js';
13
- import { r as interpretSourcePos, b as parseStacktrace } from './chunk-utils-timers.c50fec92.js';
12
+ import { A as API_PATH } from './chunk-constants.54c46a47.js';
13
+ import { r as interpretSourcePos, b as parseStacktrace } from './chunk-utils-timers.8a5e7cd5.js';
14
14
  import 'module';
15
15
  import 'vm';
16
- import './chunk-utils-global.9b434e81.js';
16
+ import './chunk-utils-global.eb31f3da.js';
17
17
  import 'tty';
18
18
  import 'local-pkg';
19
19
  import 'path';
@@ -1,5 +1,5 @@
1
1
  import { fileURLToPath } from 'url';
2
- import { k as resolve } from './chunk-utils-global.9b434e81.js';
2
+ import { k as resolve } from './chunk-utils-global.eb31f3da.js';
3
3
 
4
4
  const distDir = resolve(fileURLToPath(import.meta.url), "../../dist");
5
5
  const defaultPort = 51204;
@@ -1,7 +1,7 @@
1
1
  import { existsSync, promises } from 'fs';
2
2
  import { createRequire } from 'module';
3
3
  import { pathToFileURL } from 'url';
4
- import { t as toArray, k as resolve } from './chunk-utils-global.9b434e81.js';
4
+ import { t as toArray, k as resolve } from './chunk-utils-global.eb31f3da.js';
5
5
 
6
6
  const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
7
7
  const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/cypress/**", "**/.{idea,git,cache,output,temp}/**"];
@@ -1,22 +1,22 @@
1
- import { g as globalApis } from './chunk-constants.90075174.js';
2
- import { i as index } from './vendor-entry.9dd6e6e6.js';
1
+ import { g as globalApis } from './chunk-constants.54c46a47.js';
2
+ import { i as index } from './vendor-entry.a660e61c.js';
3
3
  import 'url';
4
- import './chunk-utils-global.9b434e81.js';
4
+ import './chunk-utils-global.eb31f3da.js';
5
5
  import 'tty';
6
6
  import 'local-pkg';
7
7
  import 'path';
8
8
  import 'fs';
9
9
  import 'console';
10
10
  import 'stream';
11
- import './chunk-runtime-chain.6292a3de.js';
11
+ import './chunk-runtime-chain.0ac0691b.js';
12
12
  import 'chai';
13
13
  import './vendor-_commonjsHelpers.addc3445.js';
14
- import './chunk-runtime-rpc.8e14ae4f.js';
15
- import './chunk-utils-timers.c50fec92.js';
14
+ import './chunk-runtime-rpc.710f6f7f.js';
15
+ import './chunk-utils-timers.8a5e7cd5.js';
16
16
  import './chunk-integrations-spy.f036df6f.js';
17
17
  import 'tinyspy';
18
18
  import 'util';
19
- import './chunk-defaults.fd5b939d.js';
19
+ import './chunk-defaults.c143550b.js';
20
20
  import 'module';
21
21
  import 'crypto';
22
22
 
@@ -1,9 +1,9 @@
1
1
  import chai$1, { expect as expect$1, util } from 'chai';
2
2
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
3
- import { r as rpc } from './chunk-runtime-rpc.8e14ae4f.js';
4
- import { i as isObject, a as index, g as getCallLastIndex, s as slash, b as getWorkerState, c as getNames, d as assertTypes, p as picocolors, n as noop, t as toArray, r as resetModules } from './chunk-utils-global.9b434e81.js';
3
+ import { r as rpc } from './chunk-runtime-rpc.710f6f7f.js';
4
+ import { i as isObject, a as index, g as getCallLastIndex, s as slash, b as getWorkerState, c as getNames, d as assertTypes, p as picocolors, n as noop, t as toArray, r as resetModules } from './chunk-utils-global.eb31f3da.js';
5
5
  import fs, { promises } from 'fs';
6
- import { p as plugins_1, f as format_1, g as getOriginalPos, a as posToNumber, n as numberToPos, l as lineSplitRE, b as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils, c as setTimeout, d as clearTimeout } from './chunk-utils-timers.c50fec92.js';
6
+ import { p as plugins_1, f as format_1, g as getOriginalPos, a as posToNumber, n as numberToPos, l as lineSplitRE, b as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils, c as setTimeout, d as clearTimeout } from './chunk-utils-timers.8a5e7cd5.js';
7
7
  import { i as isMockFunction, s as spyOn, f as fn, a as spies } from './chunk-integrations-spy.f036df6f.js';
8
8
  import require$$0, { format } from 'util';
9
9
 
@@ -534,14 +534,18 @@ ${snapshots.join("\n\n")}
534
534
  }
535
535
  function prepareExpected(expected) {
536
536
  function findStartIndent() {
537
- var _a;
538
- const match = /^( +)}\s+$/m.exec(expected || "");
539
- return ((_a = match == null ? void 0 : match[1]) == null ? void 0 : _a.length) || 0;
537
+ var _a, _b;
538
+ const matchObject = /^( +)}\s+$/m.exec(expected || "");
539
+ const objectIndent = (_a = matchObject == null ? void 0 : matchObject[1]) == null ? void 0 : _a.length;
540
+ if (objectIndent)
541
+ return objectIndent;
542
+ const matchText = /^\n( +)"/.exec(expected || "");
543
+ return ((_b = matchText == null ? void 0 : matchText[1]) == null ? void 0 : _b.length) || 0;
540
544
  }
541
- const startIdent = findStartIndent();
545
+ const startIndent = findStartIndent();
542
546
  let expectedTrimmed = expected == null ? void 0 : expected.trim();
543
- if (startIdent) {
544
- expectedTrimmed = expectedTrimmed == null ? void 0 : expectedTrimmed.replace(new RegExp(`^${" ".repeat(startIdent)}`, "gm"), "").replace(/ +}$/, "}");
547
+ if (startIndent) {
548
+ expectedTrimmed = expectedTrimmed == null ? void 0 : expectedTrimmed.replace(new RegExp(`^${" ".repeat(startIndent)}`, "gm"), "").replace(/ +}$/, "}");
545
549
  }
546
550
  return expectedTrimmed;
547
551
  }
@@ -898,7 +902,17 @@ class SnapshotClient {
898
902
  clearTest() {
899
903
  this.test = void 0;
900
904
  }
901
- assert(received, test = this.test, message, isInline = false, properties, inlineSnapshot, error) {
905
+ assert(options) {
906
+ const {
907
+ test = this.test,
908
+ message,
909
+ isInline = false,
910
+ properties,
911
+ inlineSnapshot,
912
+ error,
913
+ errorMessage
914
+ } = options;
915
+ let { received } = options;
902
916
  if (!test)
903
917
  throw new Error("Snapshot cannot be used outside of test");
904
918
  if (typeof properties === "object") {
@@ -911,7 +925,7 @@ class SnapshotClient {
911
925
  else
912
926
  received = deepMergeSnapshot(received, properties);
913
927
  } catch (err) {
914
- err.message = "Snapshot mismatched";
928
+ err.message = errorMessage || "Snapshot mismatched";
915
929
  throw err;
916
930
  }
917
931
  }
@@ -931,7 +945,7 @@ class SnapshotClient {
931
945
  try {
932
946
  expect$1(actual.trim()).equals(expected ? expected.trim() : "");
933
947
  } catch (error2) {
934
- error2.message = `Snapshot \`${key || "unknown"}\` mismatched`;
948
+ error2.message = errorMessage || `Snapshot \`${key || "unknown"}\` mismatched`;
935
949
  throw error2;
936
950
  }
937
951
  }
@@ -973,7 +987,15 @@ const SnapshotPlugin = (chai, utils) => {
973
987
  message = properties;
974
988
  properties = void 0;
975
989
  }
976
- getSnapshotClient().assert(expected, test, message, false, properties);
990
+ const errorMessage = utils.flag(this, "message");
991
+ getSnapshotClient().assert({
992
+ received: expected,
993
+ test,
994
+ message,
995
+ isInline: false,
996
+ properties,
997
+ errorMessage
998
+ });
977
999
  });
978
1000
  }
979
1001
  utils.addMethod(chai.Assertion.prototype, "toMatchInlineSnapshot", function __VITEST_INLINE_SNAPSHOT__(properties, inlineSnapshot, message) {
@@ -987,18 +1009,43 @@ const SnapshotPlugin = (chai, utils) => {
987
1009
  }
988
1010
  if (inlineSnapshot)
989
1011
  inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
990
- getSnapshotClient().assert(expected, test, message, true, properties, inlineSnapshot, error);
1012
+ const errorMessage = utils.flag(this, "message");
1013
+ getSnapshotClient().assert({
1014
+ received: expected,
1015
+ test,
1016
+ message,
1017
+ isInline: true,
1018
+ properties,
1019
+ inlineSnapshot,
1020
+ error,
1021
+ errorMessage
1022
+ });
991
1023
  });
992
1024
  utils.addMethod(chai.Assertion.prototype, "toThrowErrorMatchingSnapshot", function(message) {
993
1025
  const expected = utils.flag(this, "object");
994
1026
  const test = utils.flag(this, "vitest-test");
995
- getSnapshotClient().assert(getErrorString(expected), test, message);
1027
+ const errorMessage = utils.flag(this, "message");
1028
+ getSnapshotClient().assert({
1029
+ received: getErrorString(expected),
1030
+ test,
1031
+ message,
1032
+ errorMessage
1033
+ });
996
1034
  });
997
1035
  utils.addMethod(chai.Assertion.prototype, "toThrowErrorMatchingInlineSnapshot", function __VITEST_INLINE_SNAPSHOT__(inlineSnapshot, message) {
998
1036
  const expected = utils.flag(this, "object");
999
1037
  const error = utils.flag(this, "error");
1000
1038
  const test = utils.flag(this, "vitest-test");
1001
- getSnapshotClient().assert(getErrorString(expected), test, message, true, void 0, inlineSnapshot, error);
1039
+ const errorMessage = utils.flag(this, "message");
1040
+ getSnapshotClient().assert({
1041
+ received: getErrorString(expected),
1042
+ test,
1043
+ message,
1044
+ inlineSnapshot,
1045
+ isInline: true,
1046
+ error,
1047
+ errorMessage
1048
+ });
1002
1049
  });
1003
1050
  };
1004
1051
 
@@ -1,8 +1,8 @@
1
- import { n as normalizeRequestId, i as isNodeBuiltin, t as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.c160b239.js';
1
+ import { n as normalizeRequestId, i as isNodeBuiltin, t as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.3cb38009.js';
2
2
  import { normalizePath } from 'vite';
3
- import { b as getWorkerState, B as isWindows, C as mergeSlashes, h as dirname, f as basename, k as resolve, D as getType, E as getAllProperties, s as slash } from './chunk-utils-global.9b434e81.js';
3
+ import { b as getWorkerState, D as isWindows, E as mergeSlashes, h as dirname, f as basename, k as resolve, F as getType, G as getAllProperties, s as slash } from './chunk-utils-global.eb31f3da.js';
4
4
  import { existsSync, readdirSync } from 'fs';
5
- import { d as distDir } from './chunk-constants.90075174.js';
5
+ import { d as distDir } from './chunk-constants.54c46a47.js';
6
6
 
7
7
  var __defProp = Object.defineProperty;
8
8
  var __getOwnPropSymbols = Object.getOwnPropertySymbols;
@@ -1,4 +1,4 @@
1
- import { b as getWorkerState } from './chunk-utils-global.9b434e81.js';
1
+ import { b as getWorkerState } from './chunk-utils-global.eb31f3da.js';
2
2
 
3
3
  const rpc = () => {
4
4
  return getWorkerState().rpc;
@@ -335,6 +335,9 @@ function assertTypes(value, name, types) {
335
335
  if (!pass)
336
336
  throw new TypeError(`${name} value must be ${types.join(" or ")}, received "${receivedType}"`);
337
337
  }
338
+ function stdout() {
339
+ return console._stdout || process.stdout;
340
+ }
338
341
 
339
342
  function getTests(suite) {
340
343
  return toArray(suite).flatMap((s) => s.type === "test" ? [s] : s.tasks.flatMap((c) => c.type === "test" ? [c] : getTests(c)));
@@ -454,4 +457,4 @@ function getCallLastIndex(code) {
454
457
  return null;
455
458
  }
456
459
 
457
- export { extname as A, isWindows as B, mergeSlashes as C, getType as D, getAllProperties as E, clone as F, partitionSuiteChildren as G, hasTests as H, index as a, getWorkerState as b, getNames as c, assertTypes as d, notNullish as e, basename as f, getCallLastIndex as g, dirname as h, isObject as i, join as j, resolve as k, isAbsolute as l, relative as m, noop as n, getTests as o, picocolors as p, getFullName as q, resetModules as r, slash as s, toArray as t, hasFailed as u, hasFailedSnapshot as v, getSuites as w, deepMerge as x, toNamespacedPath as y, ensurePackageInstalled as z };
460
+ export { ensurePackageInstalled as A, stdout as B, extname as C, isWindows as D, mergeSlashes as E, getType as F, getAllProperties as G, clone as H, partitionSuiteChildren as I, hasTests as J, index as a, getWorkerState as b, getNames as c, assertTypes as d, notNullish as e, basename as f, getCallLastIndex as g, dirname as h, isObject as i, join as j, resolve as k, isAbsolute as l, relative as m, noop as n, getTests as o, picocolors as p, getFullName as q, resetModules as r, slash as s, toArray as t, hasFailed as u, hasFailedSnapshot as v, getSuites as w, normalize as x, deepMerge as y, toNamespacedPath as z };
@@ -1,4 +1,4 @@
1
- import { s as slash, e as notNullish, p as picocolors } from './chunk-utils-global.9b434e81.js';
1
+ import { s as slash, e as notNullish, p as picocolors } from './chunk-utils-global.eb31f3da.js';
2
2
 
3
3
  const setTimeout$1 = globalThis.setTimeout;
4
4
  const setInterval = globalThis.setInterval;
@@ -5,25 +5,25 @@ import process$1 from 'process';
5
5
  import { s as signalExit, m as mergeStream, g as getStream, c as crossSpawn, o as onetime$1 } from './vendor-index.40be925a.js';
6
6
  import url, { fileURLToPath, pathToFileURL } from 'url';
7
7
  import require$$0, { constants as constants$5, cpus, hostname } from 'os';
8
- import { j as join, f as basename, h as dirname, k as resolve, p as picocolors, s as slash$2, l as isAbsolute, m as relative, o as getTests, q as getFullName, u as hasFailed, v as hasFailedSnapshot, w as getSuites, t as toArray, n as noop$1, x as deepMerge, y as toNamespacedPath, g as getCallLastIndex, e as notNullish, z as ensurePackageInstalled } from './chunk-utils-global.9b434e81.js';
8
+ import { j as join, f as basename, h as dirname, k as resolve, p as picocolors, s as slash$2, l as isAbsolute, m as relative, o as getTests, q as getFullName, u as hasFailed, v as hasFailedSnapshot, w as getSuites, t as toArray, x as normalize, n as noop$1, y as deepMerge, z as toNamespacedPath, g as getCallLastIndex, e as notNullish, A as ensurePackageInstalled, B as stdout } from './chunk-utils-global.eb31f3da.js';
9
9
  import { createServer, mergeConfig } from 'vite';
10
10
  import fs$8, { promises, existsSync, readFileSync } from 'fs';
11
- import { d as distDir, a as defaultPort, c as configFiles } from './chunk-constants.90075174.js';
11
+ import { d as distDir, a as defaultPort, c as configFiles } from './chunk-constants.54c46a47.js';
12
12
  import readline from 'readline';
13
13
  import require$$0$1 from 'util';
14
14
  import require$$0$2 from 'stream';
15
15
  import require$$2 from 'events';
16
16
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
17
- import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.c160b239.js';
18
- import { c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage } from './chunk-defaults.fd5b939d.js';
17
+ import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.3cb38009.js';
18
+ import { c as configDefaults, r as resolveC8Options, a as cleanCoverage, b as reportCoverage } from './chunk-defaults.c143550b.js';
19
19
  import { MessageChannel } from 'worker_threads';
20
20
  import { Tinypool } from 'tinypool';
21
21
  import { performance } from 'perf_hooks';
22
- import { e as stripAnsi, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as setInterval, o as clearInterval, q as cliTruncate, c as setTimeout$1, b as parseStacktrace, r as interpretSourcePos, s as stringify$5, u as unifiedDiff, a as posToNumber, l as lineSplitRE, d as clearTimeout$1 } from './chunk-utils-timers.c50fec92.js';
22
+ import { e as stripAnsi, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as setInterval, o as clearInterval, q as cliTruncate, c as setTimeout$1, b as parseStacktrace, r as interpretSourcePos, s as stringify$5, u as unifiedDiff, a as posToNumber, l as lineSplitRE, d as clearTimeout$1 } from './chunk-utils-timers.8a5e7cd5.js';
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.1";
26
+ var version = "0.10.4";
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
- suffix += picocolors.exports.yellow(` ${Math.round(task.result.duration)}${picocolors.exports.dim("ms")}`);
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 (((_b = task.result) == null ? void 0 : _b.state) !== "pass" && outputMap.get(task) != null) {
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 (((_c = task.result) == null ? void 0 : _c.state) === "fail" || ((_d = task.result) == null ? void 0 : _d.state) === "run" || options.renderSucceed)
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
- this.ctx.log(` ${getStateSymbol(task)} ${getFullName(task)}`);
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
  }
@@ -10088,7 +10099,7 @@ const esmErrors = [
10088
10099
  function handleImportOutsideModuleError(stack, ctx) {
10089
10100
  if (!esmErrors.some((e) => stack.includes(e)))
10090
10101
  return;
10091
- const path = stack.split("\n")[0].trim();
10102
+ const path = normalize(stack.split("\n")[0].trim());
10092
10103
  let name = path.split("/node_modules/").pop() || "";
10093
10104
  if (name == null ? void 0 : name.startsWith("@"))
10094
10105
  name = name.split("/").slice(0, 2).join("/");
@@ -10424,7 +10435,10 @@ class Vitest {
10424
10435
  await this.rerunFiles(this.state.getFailedFilepaths(), "rerun failed");
10425
10436
  }
10426
10437
  async updateSnapshot(files) {
10427
- files = files || this.state.getFailedFilepaths();
10438
+ files = files || [
10439
+ ...this.state.getFailedFilepaths(),
10440
+ ...this.snapshot.summary.uncheckedKeysByFile.map((s) => s.filePath)
10441
+ ];
10428
10442
  this.configOverride = {
10429
10443
  snapshotOptions: {
10430
10444
  updateSnapshot: "all"
@@ -10924,7 +10938,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
10924
10938
  await ctx.setServer(options, server);
10925
10939
  haveStarted = true;
10926
10940
  if (options.api && options.watch)
10927
- (await import('./chunk-api-setup.b55307fb.js')).setup(ctx);
10941
+ (await import('./chunk-api-setup.0baa5b9c.js')).setup(ctx);
10928
10942
  if (!options.watch)
10929
10943
  await server.watcher.close();
10930
10944
  }
@@ -10963,7 +10977,7 @@ const keys = [
10963
10977
  ["q", "quit"]
10964
10978
  ];
10965
10979
  function printShortcutsHelp() {
10966
- process.stdout.write(`
10980
+ stdout().write(`
10967
10981
  ${picocolors.exports.bold(" Watch Usage")}
10968
10982
  ${keys.map((i) => picocolors.exports.dim(" press ") + picocolors.exports.reset(picocolors.exports.bold(i[0])) + picocolors.exports.dim(` to ${i[1]}`)).join("\n")}
10969
10983
  `);
@@ -1,7 +1,7 @@
1
1
  import { builtinModules, createRequire } from 'module';
2
2
  import { pathToFileURL, fileURLToPath as fileURLToPath$2, URL as URL$1 } from 'url';
3
3
  import vm from 'vm';
4
- import { l as isAbsolute$2, k as resolve, j as join$2, A as extname$2, h as dirname$2 } from './chunk-utils-global.9b434e81.js';
4
+ import { l as isAbsolute$2, k as resolve, j as join$2, C as extname$2, h as dirname$2 } from './chunk-utils-global.eb31f3da.js';
5
5
  import path from 'path';
6
6
  import fs, { realpathSync, statSync, Stats, promises, existsSync } from 'fs';
7
7
  import assert from 'assert';
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'events';
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.4dd7260b.js';
2
+ import { p as picocolors } from './chunk-utils-global.eb31f3da.js';
3
+ import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.92c54acc.js';
4
4
  import 'tty';
5
5
  import 'local-pkg';
6
6
  import 'path';
@@ -16,16 +16,16 @@ import 'util';
16
16
  import 'url';
17
17
  import 'os';
18
18
  import 'vite';
19
- import './chunk-constants.90075174.js';
19
+ import './chunk-constants.54c46a47.js';
20
20
  import 'readline';
21
- import './chunk-vite-node-utils.c160b239.js';
21
+ import './chunk-vite-node-utils.3cb38009.js';
22
22
  import 'module';
23
23
  import 'vm';
24
- import './chunk-defaults.fd5b939d.js';
24
+ import './chunk-defaults.c143550b.js';
25
25
  import 'worker_threads';
26
26
  import 'tinypool';
27
27
  import 'perf_hooks';
28
- import './chunk-utils-timers.c50fec92.js';
28
+ import './chunk-utils-timers.8a5e7cd5.js';
29
29
  import './chunk-magic-string.d5e0e473.js';
30
30
  import './vendor-index.405e58ef.js';
31
31
 
package/dist/entry.js CHANGED
@@ -1,20 +1,20 @@
1
- export { r as run } from './vendor-entry.9dd6e6e6.js';
1
+ export { r as run } from './vendor-entry.a660e61c.js';
2
2
  import 'fs';
3
- import './chunk-utils-global.9b434e81.js';
3
+ import './chunk-utils-global.eb31f3da.js';
4
4
  import 'tty';
5
5
  import 'local-pkg';
6
6
  import 'path';
7
7
  import 'console';
8
8
  import 'stream';
9
- import './chunk-runtime-chain.6292a3de.js';
9
+ import './chunk-runtime-chain.0ac0691b.js';
10
10
  import 'chai';
11
11
  import './vendor-_commonjsHelpers.addc3445.js';
12
- import './chunk-runtime-rpc.8e14ae4f.js';
13
- import './chunk-utils-timers.c50fec92.js';
12
+ import './chunk-runtime-rpc.710f6f7f.js';
13
+ import './chunk-utils-timers.8a5e7cd5.js';
14
14
  import './chunk-integrations-spy.f036df6f.js';
15
15
  import 'tinyspy';
16
16
  import 'util';
17
- import './chunk-defaults.fd5b939d.js';
17
+ import './chunk-defaults.c143550b.js';
18
18
  import 'module';
19
19
  import 'url';
20
20
  import 'crypto';
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/index.js CHANGED
@@ -1,13 +1,13 @@
1
- export { c as afterAll, f as afterEach, b as beforeAll, e as beforeEach, g as createExpect, d as describe, h as expect, k as getRunningMode, a as isFirstRun, l as isWatchMode, i as it, r as runOnce, s as suite, t as test, j as vi, v as vitest, w as withCallback } from './chunk-runtime-chain.6292a3de.js';
1
+ export { c as afterAll, f as afterEach, b as beforeAll, e as beforeEach, g as createExpect, d as describe, h as expect, k as getRunningMode, a as isFirstRun, l as isWatchMode, i as it, r as runOnce, s as suite, t as test, j as vi, v as vitest, w as withCallback } from './chunk-runtime-chain.0ac0691b.js';
2
2
  export { assert, default as chai, should } from 'chai';
3
3
  import './vendor-_commonjsHelpers.addc3445.js';
4
- import './chunk-runtime-rpc.8e14ae4f.js';
5
- import './chunk-utils-global.9b434e81.js';
4
+ import './chunk-runtime-rpc.710f6f7f.js';
5
+ import './chunk-utils-global.eb31f3da.js';
6
6
  import 'tty';
7
7
  import 'local-pkg';
8
8
  import 'path';
9
9
  import 'fs';
10
- import './chunk-utils-timers.c50fec92.js';
10
+ import './chunk-utils-timers.8a5e7cd5.js';
11
11
  import './chunk-integrations-spy.f036df6f.js';
12
12
  import 'tinyspy';
13
13
  import 'util';
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,5 +1,5 @@
1
- export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.4dd7260b.js';
2
- export { V as VitestRunner } from './chunk-runtime-mocker.ca5ecf98.js';
1
+ export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.92c54acc.js';
2
+ export { V as VitestRunner } from './chunk-runtime-mocker.89015cf8.js';
3
3
  import 'buffer';
4
4
  import 'path';
5
5
  import 'child_process';
@@ -13,19 +13,19 @@ import 'stream';
13
13
  import 'util';
14
14
  import 'url';
15
15
  import 'os';
16
- import './chunk-utils-global.9b434e81.js';
16
+ import './chunk-utils-global.eb31f3da.js';
17
17
  import 'tty';
18
18
  import 'local-pkg';
19
19
  import 'vite';
20
- import './chunk-constants.90075174.js';
20
+ import './chunk-constants.54c46a47.js';
21
21
  import 'readline';
22
- import './chunk-vite-node-utils.c160b239.js';
22
+ import './chunk-vite-node-utils.3cb38009.js';
23
23
  import 'module';
24
24
  import 'vm';
25
- import './chunk-defaults.fd5b939d.js';
25
+ import './chunk-defaults.c143550b.js';
26
26
  import 'worker_threads';
27
27
  import 'tinypool';
28
28
  import 'perf_hooks';
29
- import './chunk-utils-timers.c50fec92.js';
29
+ import './chunk-utils-timers.8a5e7cd5.js';
30
30
  import './chunk-magic-string.d5e0e473.js';
31
31
  import './vendor-index.405e58ef.js';
@@ -1,13 +1,13 @@
1
1
  import { promises } from 'fs';
2
- import { b as getWorkerState, t as toArray, F as clone, D as getType, m as relative, G as partitionSuiteChildren, H as hasTests, u as hasFailed, q as getFullName, r as resetModules } from './chunk-utils-global.9b434e81.js';
2
+ import { b as getWorkerState, t as toArray, H as clone, F as getType, m as relative, B as stdout, I as partitionSuiteChildren, J as hasTests, u as hasFailed, q as getFullName, r as resetModules } from './chunk-utils-global.eb31f3da.js';
3
3
  import { Console } from 'console';
4
4
  import { Writable } from 'stream';
5
5
  import { importModule } from 'local-pkg';
6
- import { s as suite, t as test, d as describe, i as it, r as runOnce, a as isFirstRun, b as beforeAll, c as afterAll, e as beforeEach, f as afterEach, w as withCallback, g as createExpect, h as expect, v as vitest, j as vi, k as getRunningMode, l as isWatchMode, m as resetRunOnceCounter, R as RealDate, n as clearCollectorContext, o as defaultSuite, p as setHooks, q as getHooks, u as collectorContext, x as getSnapshotClient, y as setState, z as getFn, A as getState } from './chunk-runtime-chain.6292a3de.js';
6
+ import { s as suite, t as test, d as describe, i as it, r as runOnce, a as isFirstRun, b as beforeAll, c as afterAll, e as beforeEach, f as afterEach, w as withCallback, g as createExpect, h as expect, v as vitest, j as vi, k as getRunningMode, l as isWatchMode, m as resetRunOnceCounter, R as RealDate, n as clearCollectorContext, o as defaultSuite, p as setHooks, q as getHooks, u as collectorContext, x as getSnapshotClient, y as setState, z as getFn, A as getState } from './chunk-runtime-chain.0ac0691b.js';
7
7
  import chai, { assert, should, util } from 'chai';
8
- import { r as rpc } from './chunk-runtime-rpc.8e14ae4f.js';
9
- import { d as clearTimeout, c as setTimeout, s as stringify } from './chunk-utils-timers.c50fec92.js';
10
- import { t as takeCoverage } from './chunk-defaults.fd5b939d.js';
8
+ import { r as rpc } from './chunk-runtime-rpc.710f6f7f.js';
9
+ import { d as clearTimeout, c as setTimeout, s as stringify } from './chunk-utils-timers.8a5e7cd5.js';
10
+ import { t as takeCoverage } from './chunk-defaults.c143550b.js';
11
11
  import { createHash } from 'crypto';
12
12
  import { format } from 'util';
13
13
 
@@ -374,8 +374,8 @@ var jsdom = {
374
374
  var happy = {
375
375
  name: "happy-dom",
376
376
  async setup(global) {
377
- const { Window } = await importModule("happy-dom");
378
- const win = new Window();
377
+ const { Window, GlobalWindow } = await importModule("happy-dom");
378
+ const win = new (GlobalWindow || Window)();
379
379
  const keys = getWindowKeys(global, win);
380
380
  const overrideObject = /* @__PURE__ */ new Map();
381
381
  for (const key of keys) {
@@ -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.a759742a.js')).registerApiGlobally();
422
+ (await import('./chunk-integrations-globals.6bdc721a.js')).registerApiGlobally();
423
423
  }
424
424
  function setupDefines(defines) {
425
425
  for (const key in defines)
@@ -672,7 +672,7 @@ async function collectTests(paths, config) {
672
672
  state: "fail",
673
673
  error: processError(e)
674
674
  };
675
- process.stdout.write("\0");
675
+ stdout().write("\0");
676
676
  }
677
677
  calculateHash(file);
678
678
  const hasOnlyTasks = someTasksAreOnly(file);
@@ -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/dist/worker.js CHANGED
@@ -1,8 +1,8 @@
1
- import { k as resolve, b as getWorkerState } from './chunk-utils-global.9b434e81.js';
2
- import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.c160b239.js';
3
- import { d as distDir } from './chunk-constants.90075174.js';
4
- import { e as executeInViteNode } from './chunk-runtime-mocker.ca5ecf98.js';
5
- import { r as rpc } from './chunk-runtime-rpc.8e14ae4f.js';
1
+ import { k as resolve, b as getWorkerState, B as stdout } from './chunk-utils-global.eb31f3da.js';
2
+ import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.3cb38009.js';
3
+ import { d as distDir } from './chunk-constants.54c46a47.js';
4
+ import { e as executeInViteNode } from './chunk-runtime-mocker.89015cf8.js';
5
+ import { r as rpc } from './chunk-runtime-rpc.710f6f7f.js';
6
6
  import 'tty';
7
7
  import 'local-pkg';
8
8
  import 'path';
@@ -54,7 +54,7 @@ async function startViteNode(ctx) {
54
54
  function init(ctx) {
55
55
  if (typeof __vitest_worker__ !== "undefined" && ctx.config.threads && ctx.config.isolate)
56
56
  throw new Error(`worker for ${ctx.files.join(",")} already initialized by ${getWorkerState().ctx.files.join(",")}. This is probably an internal bug of Vitest.`);
57
- process.stdout.write("\0");
57
+ stdout().write("\0");
58
58
  const { config, port, id } = ctx;
59
59
  process.env.VITEST_WORKER_ID = String(id);
60
60
  globalThis.__vitest_worker__ = {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "0.10.1",
4
+ "version": "0.10.4",
5
5
  "description": "A blazing fast unit test framework powered by Vite",
6
6
  "keywords": [
7
7
  "vite",
@@ -81,7 +81,7 @@
81
81
  "local-pkg": "^0.4.1",
82
82
  "tinypool": "^0.1.3",
83
83
  "tinyspy": "^0.3.2",
84
- "vite": "^2.9.5"
84
+ "vite": "^2.9.7"
85
85
  },
86
86
  "devDependencies": {
87
87
  "@antfu/install-pkg": "^0.1.0",
@@ -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.1",
96
+ "@vitest/ui": "0.10.4",
97
97
  "birpc": "^0.2.2",
98
98
  "c8": "^7.11.2",
99
99
  "cac": "^6.7.12",
@@ -104,7 +104,7 @@
104
104
  "fast-glob": "^3.2.11",
105
105
  "find-up": "^6.3.0",
106
106
  "flatted": "^3.2.5",
107
- "happy-dom": "^2.55.0",
107
+ "happy-dom": "^3.1.1",
108
108
  "jsdom": "^19.0.0",
109
109
  "log-update": "^5.0.1",
110
110
  "magic-string": "^0.26.1",
@@ -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.1",
123
+ "vite-node": "0.10.4",
124
124
  "ws": "^8.6.0"
125
125
  },
126
126
  "engines": {