vitest 0.26.1 → 0.26.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- export { A as AssertType, E as EnhancedSpy, q as ExpectTypeOf, x as Mock, y as MockContext, w as MockInstance, z as Mocked, B as MockedClass, u as MockedFunction, v as MockedObject, S as SpyInstance, j as afterAll, l as afterEach, r as assertType, h as beforeAll, k as beforeEach, n as createExpect, e as describe, m as expect, p as expectTypeOf, i as it, o as onTestFailed, d as suite, t as test } from './index-1e9f7f83.js';
2
- import { b as ResolvedConfig } from './types-c41bae41.js';
3
- export { a1 as AfterSuiteRunMeta, A as ApiConfig, a7 as ArgumentsType, a6 as Arrayable, a4 as Awaitable, ap as BaseCoverageOptions, av as BenchFunction, at as Benchmark, aw as BenchmarkAPI, au as BenchmarkResult, as as BenchmarkUserOptions, B as BuiltinEnvironment, i as CSSModuleScopeStrategy, C as CollectLineNumbers, f as CollectLines, ab as Constructable, h as Context, ar as CoverageC8Options, aq as CoverageIstanbulOptions, an as CoverageOptions, ak as CoverageProvider, al as CoverageProviderModule, am as CoverageReporter, a9 as DeepMerge, D as DoneCallback, ae as Environment, E as EnvironmentOptions, ad as EnvironmentReturn, ai as ErrorWithDiff, a as File, x as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, a8 as MergeInsertions, ac as ModuleCache, M as ModuleGraphData, aa as MutableArray, a5 as Nullable, aj as OnServerRestartHandler, O as OnTestFailedHandler, ah as ParsedStack, ag as Position, d as RawErrsMap, c as Reporter, a0 as ResolveIdFunction, b as ResolvedConfig, ao as ResolvedCoverageOptions, g as RootAndTarget, l as RunMode, R as RuntimeConfig, K as RuntimeContext, S as SequenceHooks, P as SnapshotData, X as SnapshotMatchOptions, Y as SnapshotResult, W as SnapshotStateOptions, _ as SnapshotSummary, Q as SnapshotUpdateState, p as Suite, w as SuiteAPI, z as SuiteCollector, G as SuiteFactory, y as SuiteHooks, s as Task, n as TaskBase, o as TaskResult, T as TaskResultPack, m as TaskState, q as Test, v as TestAPI, L as TestContext, t as TestFunction, u as TestOptions, e as TscErrorInfo, r as TypeCheck, k as TypecheckConfig, Z as UncheckedSnapshot, U as UserConfig, af as UserConsoleLog, N as Vitest, V as VitestEnvironment, j as VitestRunMode, $ as WorkerContext, a3 as WorkerGlobalState, a2 as WorkerRPC } from './types-c41bae41.js';
1
+ export { A as AssertType, E as EnhancedSpy, q as ExpectTypeOf, x as Mock, y as MockContext, w as MockInstance, z as Mocked, B as MockedClass, u as MockedFunction, v as MockedObject, S as SpyInstance, j as afterAll, l as afterEach, r as assertType, h as beforeAll, k as beforeEach, n as createExpect, e as describe, m as expect, p as expectTypeOf, i as it, o as onTestFailed, d as suite, t as test } from './index-761e769b.js';
2
+ import { b as ResolvedConfig } from './types-bae746aa.js';
3
+ export { a2 as AfterSuiteRunMeta, A as ApiConfig, a8 as ArgumentsType, a7 as Arrayable, a5 as Awaitable, ap as BaseCoverageOptions, av as BenchFunction, at as Benchmark, aw as BenchmarkAPI, au as BenchmarkResult, as as BenchmarkUserOptions, B as BuiltinEnvironment, j as CSSModuleScopeStrategy, C as CollectLineNumbers, g as CollectLines, ac as Constructable, i as Context, ar as CoverageC8Options, aq as CoverageIstanbulOptions, an as CoverageOptions, ak as CoverageProvider, al as CoverageProviderModule, am as CoverageReporter, aa as DeepMerge, D as DoneCallback, af as Environment, E as EnvironmentOptions, ae as EnvironmentReturn, ai as ErrorWithDiff, a as File, y as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, a9 as MergeInsertions, ad as ModuleCache, c as ModuleGraphData, ab as MutableArray, a6 as Nullable, aj as OnServerRestartHandler, O as OnTestFailedHandler, ah as ParsedStack, e as RawErrsMap, d as Reporter, a1 as ResolveIdFunction, b as ResolvedConfig, ao as ResolvedCoverageOptions, h as RootAndTarget, m as RunMode, R as RuntimeConfig, L as RuntimeContext, S as SequenceHooks, Q as SnapshotData, Y as SnapshotMatchOptions, Z as SnapshotResult, X as SnapshotStateOptions, $ as SnapshotSummary, W as SnapshotUpdateState, q as Suite, x as SuiteAPI, G as SuiteCollector, K as SuiteFactory, z as SuiteHooks, t as Task, o as TaskBase, p as TaskResult, T as TaskResultPack, n as TaskState, r as Test, w as TestAPI, N as TestContext, u as TestFunction, v as TestOptions, f as TscErrorInfo, s as TypeCheck, l as TypecheckConfig, _ as UncheckedSnapshot, U as UserConfig, ag as UserConsoleLog, P as Vitest, V as VitestEnvironment, k as VitestRunMode, a0 as WorkerContext, a4 as WorkerGlobalState, a3 as WorkerRPC } from './types-bae746aa.js';
4
4
  import * as chai from 'chai';
5
5
  export { chai };
6
6
  export { assert, should } from 'chai';
package/dist/browser.js CHANGED
@@ -1,7 +1,7 @@
1
- export { c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.4cd984be.js';
2
- import { e as dist } from './chunk-utils-import.afe2ffde.js';
3
- export { a as afterAll, d as afterEach, f as assertType, b as beforeAll, c as beforeEach, o as onTestFailed } from './chunk-utils-import.afe2ffde.js';
4
- export { a as setupGlobalEnv, s as startTests } from './chunk-runtime-setup.9cdedce6.js';
1
+ export { c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.f51aa930.js';
2
+ import { e as dist } from './chunk-utils-import.e7f64637.js';
3
+ export { a as afterAll, d as afterEach, f as assertType, b as beforeAll, c as beforeEach, o as onTestFailed } from './chunk-utils-import.e7f64637.js';
4
+ export { a as setupGlobalEnv, s as startTests } from './chunk-runtime-setup.a06d5c72.js';
5
5
  import * as chai from 'chai';
6
6
  export { chai };
7
7
  export { assert, should } from 'chai';
@@ -17,7 +17,7 @@ import './vendor-_commonjsHelpers.addc3445.js';
17
17
  import './chunk-runtime-rpc.54d72169.js';
18
18
  import './chunk-utils-timers.715da787.js';
19
19
  import 'node:fs';
20
- import './chunk-utils-source-map.59ba6b0a.js';
20
+ import './chunk-utils-source-map.5278ee22.js';
21
21
  import 'fs';
22
22
  import './spy.js';
23
23
  import 'tinyspy';
@@ -11,6 +11,7 @@ import require$$2$1 from 'http';
11
11
  import require$$7 from 'url';
12
12
  import { A as API_PATH } from './chunk-utils-env.3fdc1793.js';
13
13
  import './chunk-typecheck-constants.06e1fe5b.js';
14
+ import { p as parseStacktrace } from './chunk-utils-source-map.5278ee22.js';
14
15
  import 'tty';
15
16
  import 'node:url';
16
17
  import 'path';
@@ -4557,6 +4558,10 @@ class WebSocketReporter {
4557
4558
  async onTaskUpdate(packs) {
4558
4559
  if (this.clients.size === 0)
4559
4560
  return;
4561
+ packs.forEach(([, result]) => {
4562
+ if (result == null ? void 0 : result.error)
4563
+ result.error.stacks = parseStacktrace(result.error);
4564
+ });
4560
4565
  this.clients.forEach((client) => {
4561
4566
  var _a;
4562
4567
  (_a = client.onTaskUpdate) == null ? void 0 : _a.call(client, packs);
@@ -1,9 +1,9 @@
1
1
  import { m as globalApis } from './chunk-utils-env.3fdc1793.js';
2
- import { i as index } from './chunk-utils-import.afe2ffde.js';
2
+ import { i as index } from './chunk-utils-import.e7f64637.js';
3
3
  import 'tty';
4
4
  import 'node:url';
5
5
  import 'path';
6
- import './chunk-runtime-chain.4cd984be.js';
6
+ import './chunk-runtime-chain.f51aa930.js';
7
7
  import 'util';
8
8
  import 'chai';
9
9
  import './chunk-typecheck-constants.06e1fe5b.js';
@@ -13,7 +13,7 @@ import './vendor-_commonjsHelpers.addc3445.js';
13
13
  import './chunk-runtime-rpc.54d72169.js';
14
14
  import './chunk-utils-timers.715da787.js';
15
15
  import 'node:fs';
16
- import './chunk-utils-source-map.59ba6b0a.js';
16
+ import './chunk-utils-source-map.5278ee22.js';
17
17
  import 'fs';
18
18
  import './spy.js';
19
19
  import 'tinyspy';
@@ -7,7 +7,7 @@ import { r as rpc } from './chunk-runtime-rpc.54d72169.js';
7
7
  import fs from 'node:fs';
8
8
  import { j as join, d as dirname, p as picocolors } from './chunk-utils-env.3fdc1793.js';
9
9
  import { p as plugins_1, f as format_1, u as unifiedDiff, a as stringify, m as matcherUtils, s as safeSetTimeout, b as safeClearTimeout } from './chunk-utils-timers.715da787.js';
10
- import { a as posToNumber, n as numberToPos, l as lineSplitRE, p as parseStacktrace } from './chunk-utils-source-map.59ba6b0a.js';
10
+ import { a as positionToOffset, o as offsetToLineNumber, l as lineSplitRE, p as parseStacktrace } from './chunk-utils-source-map.5278ee22.js';
11
11
  import { promises } from 'fs';
12
12
  import { isMockFunction } from './spy.js';
13
13
 
@@ -608,7 +608,7 @@ async function saveInlineSnapshots(snapshots) {
608
608
  const code = await promises.readFile(file, "utf8");
609
609
  const s = new MagicString(code);
610
610
  for (const snap of snaps) {
611
- const index = posToNumber(code, snap);
611
+ const index = positionToOffset(code, snap.line, snap.column);
612
612
  replaceInlineSnap(code, s, index, snap.snapshot);
613
613
  }
614
614
  const transformed = s.toString();
@@ -630,8 +630,8 @@ function replaceObjectSnap(code, s, index, newSnap) {
630
630
  return true;
631
631
  }
632
632
  function prepareSnapString(snap, source, index) {
633
- const lineIndex = numberToPos(source, index).line;
634
- const line = source.split(lineSplitRE)[lineIndex - 1];
633
+ const lineNumber = offsetToLineNumber(source, index);
634
+ const line = source.split(lineSplitRE)[lineNumber - 1];
635
635
  const indent = line.match(/^\s*/)[0] || "";
636
636
  const indentNext = indent.includes(" ") ? `${indent} ` : `${indent} `;
637
637
  const lines = snap.trim().replace(/\\/g, "\\\\").split(/\n/g);
@@ -2192,7 +2192,7 @@ function createTestContext(test) {
2192
2192
  }
2193
2193
  function makeTimeoutMsg(isHook, timeout) {
2194
2194
  return `${isHook ? "Hook" : "Test"} timed out in ${timeout}ms.
2195
- If this is a long-running test, pass a timeout value as the last argument or configure it globally with "${isHook ? "hookTimeout" : "testTimeout"}".`;
2195
+ If this is a long-running ${isHook ? "hook" : "test"}, pass a timeout value as the last argument or configure it globally with "${isHook ? "hookTimeout" : "testTimeout"}".`;
2196
2196
  }
2197
2197
 
2198
2198
  const fnMap = /* @__PURE__ */ new WeakMap();
@@ -265,11 +265,11 @@ ${picocolors.exports.green(`vi.mock("${mockpath}", async () => {
265
265
  const mockPath = this.getMockPath(id);
266
266
  if (mock === null) {
267
267
  const cache = this.moduleCache.get(mockPath);
268
- if (cache == null ? void 0 : cache.exports)
268
+ if (cache.exports)
269
269
  return cache.exports;
270
270
  const exports = {};
271
271
  this.moduleCache.set(mockPath, { exports });
272
- const mod = await this.runner.directRequest(url, url, []);
272
+ const mod = await this.runner.directRequest(url, url, callstack);
273
273
  this.mockObject(mod, exports);
274
274
  return exports;
275
275
  }
@@ -1,8 +1,8 @@
1
1
  import { performance } from 'perf_hooks';
2
2
  import { s as someTasksAreOnly, i as interpretTaskModes, t as takeCoverageInsideWorker, p as pLimit } from './chunk-integrations-coverage.befed097.js';
3
- import { r as resetRunOnceCounter, i as index, v as vi, s as setCurrentTest } from './chunk-utils-import.afe2ffde.js';
3
+ import { r as resetRunOnceCounter, i as index, v as vi, s as setCurrentTest } from './chunk-utils-import.e7f64637.js';
4
4
  import { g as getWorkerState, R as RealDate, t as toArray, l as relativePath, j as isRunningInBenchmark, p as partitionSuiteChildren, q as shuffle, u as hasTests, v as hasFailed, w as createDefer, f as getFullName } from './chunk-typecheck-constants.06e1fe5b.js';
5
- import { f as clearCollectorContext, h as defaultSuite, j as setHooks, k as getHooks, l as collectorContext, m as getBenchOptions, n as getFn, o as setState, G as GLOBAL_EXPECT, p as getState } from './chunk-runtime-chain.4cd984be.js';
5
+ import { f as clearCollectorContext, h as defaultSuite, j as setHooks, k as getHooks, l as collectorContext, m as getBenchOptions, n as getFn, o as setState, G as GLOBAL_EXPECT, p as getState } from './chunk-runtime-chain.f51aa930.js';
6
6
  import { r as rpc } from './chunk-runtime-rpc.54d72169.js';
7
7
  import { p as processError } from './chunk-runtime-error.f5c8aaf2.js';
8
8
  import { installSourcemapsSupport } from 'vite-node/source-map';
@@ -29,7 +29,7 @@ async function setupGlobalEnv(config) {
29
29
  await setupConsoleLogSpy();
30
30
  }
31
31
  if (config.globals)
32
- (await import('./chunk-integrations-globals.96914902.js')).registerApiGlobally();
32
+ (await import('./chunk-integrations-globals.ee28730b.js')).registerApiGlobally();
33
33
  }
34
34
  function setupDefines(defines) {
35
35
  for (const key in defines)
@@ -200,7 +200,8 @@ async function collectTests(paths, config) {
200
200
  type: "suite",
201
201
  mode: "run",
202
202
  filepath,
203
- tasks: []
203
+ tasks: [],
204
+ projectName: config.name
204
205
  };
205
206
  clearCollectorContext();
206
207
  try {
@@ -329,7 +330,7 @@ const callCleanupHooks = async (cleanups) => {
329
330
  async function runTest(test) {
330
331
  var _a, _b, _c;
331
332
  if (test.mode !== "run") {
332
- const { getSnapshotClient } = await import('./chunk-runtime-chain.4cd984be.js').then(function (n) { return n.r; });
333
+ const { getSnapshotClient } = await import('./chunk-runtime-chain.f51aa930.js').then(function (n) { return n.r; });
333
334
  getSnapshotClient().skipTestSnapshots(test);
334
335
  return;
335
336
  }
@@ -346,7 +347,7 @@ async function runTest(test) {
346
347
  clearModuleMocks();
347
348
  setCurrentTest(test);
348
349
  if (isNode) {
349
- const { getSnapshotClient } = await import('./chunk-runtime-chain.4cd984be.js').then(function (n) { return n.r; });
350
+ const { getSnapshotClient } = await import('./chunk-runtime-chain.f51aa930.js').then(function (n) { return n.r; });
350
351
  await getSnapshotClient().setTest(test);
351
352
  }
352
353
  const workerState = getWorkerState();
@@ -409,7 +410,7 @@ async function runTest(test) {
409
410
  console.error(test.result.error.message, test.result.error.stackStr);
410
411
  setCurrentTest(void 0);
411
412
  if (isNode) {
412
- const { getSnapshotClient } = await import('./chunk-runtime-chain.4cd984be.js').then(function (n) { return n.r; });
413
+ const { getSnapshotClient } = await import('./chunk-runtime-chain.f51aa930.js').then(function (n) { return n.r; });
413
414
  getSnapshotClient().clearTest();
414
415
  }
415
416
  test.result.duration = now() - start;
@@ -615,7 +616,7 @@ async function startTestsBrowser(paths, config) {
615
616
  async function startTestsNode(paths, config) {
616
617
  const files = await collectTests(paths, config);
617
618
  rpc().onCollected(files);
618
- const { getSnapshotClient } = await import('./chunk-runtime-chain.4cd984be.js').then(function (n) { return n.r; });
619
+ const { getSnapshotClient } = await import('./chunk-runtime-chain.f51aa930.js').then(function (n) { return n.r; });
619
620
  getSnapshotClient().clear();
620
621
  await runFiles(files, config);
621
622
  const coverage = await takeCoverageInsideWorker(config.coverage);
@@ -28,10 +28,10 @@ import { Tinypool } from 'tinypool';
28
28
  import { c as createBirpc } from './vendor-index.783e7f3e.js';
29
29
  import { performance } from 'perf_hooks';
30
30
  import { c as stripAnsi, d as safeSetInterval, e as safeClearInterval, g as cliTruncate, s as safeSetTimeout, h as stringWidth, i as ansiStyles, j as sliceAnsi, a as stringify$5, u as unifiedDiff, b as safeClearTimeout } from './chunk-utils-timers.715da787.js';
31
- import { p as parseStacktrace, a as posToNumber, l as lineSplitRE } from './chunk-utils-source-map.59ba6b0a.js';
31
+ import { p as parseStacktrace, a as positionToOffset, l as lineSplitRE } from './chunk-utils-source-map.5278ee22.js';
32
32
  import { resolveModule } from 'local-pkg';
33
33
  import { createHash } from 'crypto';
34
- import { slash as slash$2 } from 'vite-node/utils';
34
+ import { slash as slash$2, cleanUrl } from 'vite-node/utils';
35
35
  import { o as onetime } from './vendor-index.9c919048.js';
36
36
  import { s as signalExit } from './vendor-index.7a2cebfe.js';
37
37
  import { createHash as createHash$1 } from 'node:crypto';
@@ -40,7 +40,7 @@ import { stripLiteral } from 'strip-literal';
40
40
  import require$$0$3 from 'readline';
41
41
  import { p as prompts } from './vendor-index.9f20a9be.js';
42
42
 
43
- var version$1 = "0.26.1";
43
+ var version$1 = "0.26.3";
44
44
 
45
45
  class EndError extends Error {
46
46
  constructor(value) {
@@ -6969,7 +6969,7 @@ async function collectTests(ctx, filepath) {
6969
6969
  const file = {
6970
6970
  filepath,
6971
6971
  type: "suite",
6972
- id: "-1",
6972
+ id: filepath,
6973
6973
  name: relative(ctx.config.root, filepath),
6974
6974
  mode: "run",
6975
6975
  tasks: [],
@@ -7138,7 +7138,7 @@ class Typechecker {
7138
7138
  const state = suite.mode === "run" || suite.mode === "only" ? "fail" : suite.mode;
7139
7139
  const task = {
7140
7140
  type: "typecheck",
7141
- id: idx.toString(),
7141
+ id: `${path}${idx.toString()}`,
7142
7142
  name: `error expect ${idx + 1}`,
7143
7143
  mode: suite.mode,
7144
7144
  file,
@@ -7175,11 +7175,7 @@ class Typechecker {
7175
7175
  file: filepath,
7176
7176
  line: info.line,
7177
7177
  column: info.column,
7178
- method: "",
7179
- sourcePos: {
7180
- line: info.line,
7181
- column: info.column
7182
- }
7178
+ method: ""
7183
7179
  }
7184
7180
  ]);
7185
7181
  Error.stackTraceLimit = limit;
@@ -7261,6 +7257,9 @@ class Typechecker {
7261
7257
  getTestFiles() {
7262
7258
  return Object.values(this._tests || {}).map((i) => i.file);
7263
7259
  }
7260
+ getTestPacks() {
7261
+ return Object.values(this._tests || {}).map((i) => [i.file.id, void 0]);
7262
+ }
7264
7263
  }
7265
7264
 
7266
7265
  const workerPath = url.pathToFileURL(resolve(distDir, "./worker.js")).href;
@@ -7565,6 +7564,19 @@ function elegantSpinner() {
7565
7564
  function formatTimeString(date) {
7566
7565
  return date.toTimeString().split(" ")[0];
7567
7566
  }
7567
+ function formatProjectName(name, suffix = " ") {
7568
+ if (!name)
7569
+ return "";
7570
+ const index = name.split("").reduce((acc, v, idx) => acc + v.charCodeAt(0) + idx, 0);
7571
+ const colors = [
7572
+ picocolors.exports.blue,
7573
+ picocolors.exports.yellow,
7574
+ picocolors.exports.cyan,
7575
+ picocolors.exports.green,
7576
+ picocolors.exports.magenta
7577
+ ];
7578
+ return colors[index % colors.length](`|${name}|`) + suffix;
7579
+ }
7568
7580
 
7569
7581
  var _a;
7570
7582
  const BADGE_PADDING = " ";
@@ -7835,7 +7847,7 @@ ${picocolors.exports.cyan(picocolors.exports.inverse(picocolors.exports.bold(" B
7835
7847
  }
7836
7848
  }
7837
7849
  async printTaskErrors(tasks, errorDivider) {
7838
- var _a2;
7850
+ var _a2, _b;
7839
7851
  const errorsQueue = [];
7840
7852
  for (const task of tasks) {
7841
7853
  const error = (_a2 = task.result) == null ? void 0 : _a2.error;
@@ -7851,10 +7863,11 @@ ${picocolors.exports.cyan(picocolors.exports.inverse(picocolors.exports.bold(" B
7851
7863
  for (const [error, tasks2] of errorsQueue) {
7852
7864
  for (const task of tasks2) {
7853
7865
  const filepath = (task == null ? void 0 : task.filepath) || "";
7866
+ const projectName = (task == null ? void 0 : task.projectName) || ((_b = task.file) == null ? void 0 : _b.projectName);
7854
7867
  let name = getFullName(task);
7855
7868
  if (filepath)
7856
7869
  name = `${name} ${picocolors.exports.dim(`[ ${this.relative(filepath)} ]`)}`;
7857
- this.ctx.logger.error(`${picocolors.exports.red(picocolors.exports.bold(picocolors.exports.inverse(" FAIL ")))} ${name}`);
7870
+ this.ctx.logger.error(`${picocolors.exports.red(picocolors.exports.bold(picocolors.exports.inverse(" FAIL ")))} ${formatProjectName(projectName)}${name}`);
7858
7871
  }
7859
7872
  await this.ctx.logger.printError(error);
7860
7873
  errorDivider();
@@ -7932,7 +7945,9 @@ function renderTree$1(tasks, options, level = 0) {
7932
7945
  let output = [];
7933
7946
  for (const task of tasks) {
7934
7947
  let suffix = "";
7935
- const prefix = ` ${getStateSymbol(task)} `;
7948
+ let prefix = ` ${getStateSymbol(task)} `;
7949
+ if (level === 0 && task.type === "suite" && task.projectName)
7950
+ prefix += formatProjectName(task.projectName);
7936
7951
  if (task.type === "test" && ((_a = task.result) == null ? void 0 : _a.retryCount) && task.result.retryCount > 1)
7937
7952
  suffix += picocolors.exports.yellow(` (retry x${task.result.retryCount})`);
7938
7953
  if (task.type === "suite" && !isTypecheckTest(task)) {
@@ -8295,8 +8310,7 @@ class JsonReporter$1 {
8295
8310
  const frame = stack[stack.length - 1];
8296
8311
  if (!frame)
8297
8312
  return;
8298
- const pos = frame.sourcePos || frame;
8299
- return { line: pos.line, column: pos.column };
8313
+ return { line: frame.line, column: frame.column };
8300
8314
  }
8301
8315
  }
8302
8316
 
@@ -8489,9 +8503,8 @@ class JUnitReporter {
8489
8503
  await this.baseLog(escapeXML(errorDetails));
8490
8504
  const stack = parseStacktrace(error);
8491
8505
  for (const frame of stack) {
8492
- const pos = frame.sourcePos ?? frame;
8493
8506
  const path = relative(this.ctx.config.root, frame.file);
8494
- await this.baseLog(` ${F_POINTER} ${[frame.method, `${path}:${pos.line}:${pos.column}`].filter(Boolean).join(" ")}`);
8507
+ await this.baseLog(` ${F_POINTER} ${[frame.method, `${path}:${frame.line}:${frame.column}`].filter(Boolean).join(" ")}`);
8495
8508
  if (frame.file in this.ctx.state.filesMap)
8496
8509
  break;
8497
8510
  }
@@ -9925,14 +9938,8 @@ createLogUpdate(process$1.stdout);
9925
9938
 
9926
9939
  createLogUpdate(process$1.stderr);
9927
9940
 
9928
- var version = "0.26.1";
9941
+ var version = "0.26.3";
9929
9942
 
9930
- function fileFromParsedStack(stack) {
9931
- var _a, _b;
9932
- if ((_b = (_a = stack == null ? void 0 : stack.sourcePos) == null ? void 0 : _a.source) == null ? void 0 : _b.startsWith(".."))
9933
- return join(stack.file, "../", stack.sourcePos.source);
9934
- return stack.file;
9935
- }
9936
9943
  async function printError(error, ctx, options = {}) {
9937
9944
  const { showCodeFrame = true, fullStack = false, type } = options;
9938
9945
  let e = error;
@@ -9960,13 +9967,10 @@ async function printError(error, ctx, options = {}) {
9960
9967
  if (e.frame) {
9961
9968
  ctx.logger.error(picocolors.exports.yellow(e.frame));
9962
9969
  } else {
9963
- printStack(ctx, stacks, nearest, errorProperties, (s, pos) => {
9970
+ printStack(ctx, stacks, nearest, errorProperties, (s) => {
9964
9971
  if (showCodeFrame && s === nearest && nearest) {
9965
- const file = fileFromParsedStack(nearest);
9966
- if (nearest.file === file || existsSync$1(file)) {
9967
- const sourceCode = readFileSync(file, "utf-8");
9968
- ctx.logger.error(picocolors.exports.yellow(generateCodeFrame(sourceCode, 4, pos)));
9969
- }
9972
+ const sourceCode = readFileSync(nearest.file, "utf-8");
9973
+ ctx.logger.error(picocolors.exports.yellow(generateCodeFrame(sourceCode, 4, s.line, s.column)));
9970
9974
  }
9971
9975
  });
9972
9976
  }
@@ -9978,7 +9982,8 @@ async function printError(error, ctx, options = {}) {
9978
9982
  if (e.showDiff || e.showDiff === void 0 && e.actual && e.expected) {
9979
9983
  displayDiff(stringify$5(e.actual), stringify$5(e.expected), ctx.logger.console, {
9980
9984
  outputTruncateLength: ctx.config.outputTruncateLength,
9981
- outputDiffLines: ctx.config.outputDiffLines
9985
+ outputDiffLines: ctx.config.outputDiffLines,
9986
+ outputDiffMaxLines: ctx.config.outputDiffMaxLines
9982
9987
  });
9983
9988
  }
9984
9989
  }
@@ -10057,12 +10062,10 @@ function printStack(ctx, stack, highlight, errorProperties, onStack) {
10057
10062
  return;
10058
10063
  const logger = ctx.logger;
10059
10064
  for (const frame of stack) {
10060
- const pos = frame.sourcePos || frame;
10061
10065
  const color = frame === highlight ? picocolors.exports.yellow : picocolors.exports.gray;
10062
- const file = fileFromParsedStack(frame);
10063
- const path = relative(ctx.config.root, file);
10064
- logger.error(color(` ${picocolors.exports.dim(F_POINTER)} ${[frame.method, picocolors.exports.dim(`${path}:${pos.line}:${pos.column}`)].filter(Boolean).join(" ")}`));
10065
- onStack == null ? void 0 : onStack(frame, pos);
10066
+ const path = relative(ctx.config.root, frame.file);
10067
+ logger.error(color(` ${picocolors.exports.dim(F_POINTER)} ${[frame.method, picocolors.exports.dim(`${path}:${frame.line}:${frame.column}`)].filter(Boolean).join(" ")}`));
10068
+ onStack == null ? void 0 : onStack(frame);
10066
10069
  if (frame.file in ctx.state.filesMap)
10067
10070
  break;
10068
10071
  }
@@ -10074,10 +10077,10 @@ function printStack(ctx, stack, highlight, errorProperties, onStack) {
10074
10077
  logger.error(picocolors.exports.red(picocolors.exports.bold("Serialized Error:")), picocolors.exports.gray(propertiesString));
10075
10078
  }
10076
10079
  }
10077
- function generateCodeFrame(source, indent = 0, start = 0, end, range = 2) {
10080
+ function generateCodeFrame(source, indent = 0, lineNumber, columnNumber, range = 2) {
10078
10081
  var _a;
10079
- start = posToNumber(source, start);
10080
- end = end || start;
10082
+ const start = positionToOffset(source, lineNumber, columnNumber);
10083
+ const end = start;
10081
10084
  const lines = source.split(lineSplitRE);
10082
10085
  let count = 0;
10083
10086
  let res = [];
@@ -10336,6 +10339,7 @@ class Vitest {
10336
10339
  this.typechecker = checker;
10337
10340
  checker.onParseEnd(async ({ files, sourceErrors }) => {
10338
10341
  this.state.collectFiles(checker.getTestFiles());
10342
+ await this.report("onTaskUpdate", checker.getTestPacks());
10339
10343
  await this.report("onCollected");
10340
10344
  if (!files.length) {
10341
10345
  this.logger.printNoTestFound();
@@ -10368,6 +10372,7 @@ class Vitest {
10368
10372
  await this.report("onWatcherRerun", testsFilesList, "File change detected. Triggering rerun.");
10369
10373
  await checker.collectTests();
10370
10374
  this.state.collectFiles(checker.getTestFiles());
10375
+ await this.report("onTaskUpdate", checker.getTestPacks());
10371
10376
  await this.report("onCollected");
10372
10377
  });
10373
10378
  await checker.collectTests();
@@ -10734,7 +10739,10 @@ const EnvReplacerPlugin = () => {
10734
10739
  if (s) {
10735
10740
  return {
10736
10741
  code: s.toString(),
10737
- map: s.generateMap({ hires: true, source: id })
10742
+ map: s.generateMap({
10743
+ hires: true,
10744
+ source: cleanUrl(id)
10745
+ })
10738
10746
  };
10739
10747
  }
10740
10748
  }
@@ -11116,7 +11124,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
11116
11124
  try {
11117
11125
  await ctx.setServer(options, server);
11118
11126
  if (options.api && options.watch)
11119
- (await import('./chunk-api-setup.adeab271.js')).setup(ctx);
11127
+ (await import('./chunk-api-setup.47a09f0f.js')).setup(ctx);
11120
11128
  } catch (err) {
11121
11129
  ctx.logger.printError(err, true);
11122
11130
  process.exit(1);
@@ -1,6 +1,6 @@
1
- import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it, b as bench, c as createExpect, e as globalExpect } from './chunk-runtime-chain.4cd984be.js';
1
+ import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it, b as bench, c as createExpect, e as globalExpect } from './chunk-runtime-chain.f51aa930.js';
2
2
  import { g as getWorkerState, R as RealDate, r as resetDate, m as mockDate, a as resetModules } from './chunk-typecheck-constants.06e1fe5b.js';
3
- import { p as parseStacktrace } from './chunk-utils-source-map.59ba6b0a.js';
3
+ import { p as parseStacktrace } from './chunk-utils-source-map.5278ee22.js';
4
4
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
5
5
  import util from 'util';
6
6
  import { spyOn, fn, isMockFunction, spies } from './spy.js';
@@ -8,18 +8,24 @@ import { s as safeSetTimeout } from './chunk-utils-timers.715da787.js';
8
8
  import * as chai from 'chai';
9
9
  import { assert, should } from 'chai';
10
10
 
11
- async function waitForImportsToResolve(tries = 0) {
12
- await new Promise((resolve) => safeSetTimeout(resolve, 0));
11
+ function waitNextTick() {
12
+ return new Promise((resolve) => safeSetTimeout(resolve, 0));
13
+ }
14
+ async function waitForImportsToResolve() {
15
+ await waitNextTick();
13
16
  const state = getWorkerState();
14
17
  const promises = [];
18
+ let resolvingCount = 0;
15
19
  for (const mod of state.moduleCache.values()) {
16
20
  if (mod.promise && !mod.evaluated)
17
21
  promises.push(mod.promise);
22
+ if (mod.resolving)
23
+ resolvingCount++;
18
24
  }
19
- if (!promises.length && tries >= 3)
25
+ if (!promises.length && !resolvingCount)
20
26
  return;
21
27
  await Promise.allSettled(promises);
22
- await new Promise((resolve) => safeSetTimeout(resolve, 1)).then(() => Promise.resolve()).then(() => waitForImportsToResolve(tries + 1));
28
+ await waitForImportsToResolve();
23
29
  }
24
30
 
25
31
  let _test;
@@ -1298,7 +1304,6 @@ function withGlobal(_global) {
1298
1304
  * @param {number} minute
1299
1305
  * @param {number} second
1300
1306
  * @param {number} ms
1301
- *
1302
1307
  * @returns {Date}
1303
1308
  */
1304
1309
  function ClockDate(year, month, date, hour, minute, second, ms) {
@@ -1524,7 +1529,6 @@ function withGlobal(_global) {
1524
1529
  * @param {Clock} clock
1525
1530
  * @param {number} from
1526
1531
  * @param {number} to
1527
- *
1528
1532
  * @returns {Timer}
1529
1533
  */
1530
1534
  function firstTimerInRange(clock, from, to) {
@@ -1955,6 +1959,12 @@ function withGlobal(_global) {
1955
1959
  return [secsSinceStart, remainderInNanos];
1956
1960
  }
1957
1961
 
1962
+ function fakePerformanceNow() {
1963
+ const hrt = hrtime();
1964
+ const millis = hrt[0] * 1000 + hrt[1] / 1e6;
1965
+ return millis;
1966
+ }
1967
+
1958
1968
  if (hrtimeBigintPresent) {
1959
1969
  hrtime.bigint = function () {
1960
1970
  const parts = hrtime();
@@ -1997,19 +2007,18 @@ function withGlobal(_global) {
1997
2007
  });
1998
2008
  };
1999
2009
  if (typeof _global.Promise !== "undefined" && utilPromisify) {
2000
- clock.setTimeout[
2001
- utilPromisify.custom
2002
- ] = function promisifiedSetTimeout(timeout, arg) {
2003
- return new _global.Promise(function setTimeoutExecutor(
2004
- resolve
2005
- ) {
2006
- addTimer(clock, {
2007
- func: resolve,
2008
- args: [arg],
2009
- delay: timeout,
2010
+ clock.setTimeout[utilPromisify.custom] =
2011
+ function promisifiedSetTimeout(timeout, arg) {
2012
+ return new _global.Promise(function setTimeoutExecutor(
2013
+ resolve
2014
+ ) {
2015
+ addTimer(clock, {
2016
+ func: resolve,
2017
+ args: [arg],
2018
+ delay: timeout,
2019
+ });
2010
2020
  });
2011
- });
2012
- };
2021
+ };
2013
2022
  }
2014
2023
 
2015
2024
  clock.clearTimeout = function clearTimeout(timerId) {
@@ -2053,19 +2062,18 @@ function withGlobal(_global) {
2053
2062
  };
2054
2063
 
2055
2064
  if (typeof _global.Promise !== "undefined" && utilPromisify) {
2056
- clock.setImmediate[
2057
- utilPromisify.custom
2058
- ] = function promisifiedSetImmediate(arg) {
2059
- return new _global.Promise(function setImmediateExecutor(
2060
- resolve
2061
- ) {
2062
- addTimer(clock, {
2063
- func: resolve,
2064
- args: [arg],
2065
- immediate: true,
2066
- });
2067
- });
2068
- };
2065
+ clock.setImmediate[utilPromisify.custom] =
2066
+ function promisifiedSetImmediate(arg) {
2067
+ return new _global.Promise(
2068
+ function setImmediateExecutor(resolve) {
2069
+ addTimer(clock, {
2070
+ func: resolve,
2071
+ args: [arg],
2072
+ immediate: true,
2073
+ });
2074
+ }
2075
+ );
2076
+ };
2069
2077
  }
2070
2078
 
2071
2079
  clock.clearImmediate = function clearImmediate(timerId) {
@@ -2084,7 +2092,9 @@ function withGlobal(_global) {
2084
2092
  const result = addTimer(clock, {
2085
2093
  func: func,
2086
2094
  delay: getTimeToNextFrame(),
2087
- args: [clock.now + getTimeToNextFrame()],
2095
+ get args() {
2096
+ return [fakePerformanceNow()];
2097
+ },
2088
2098
  animation: true,
2089
2099
  });
2090
2100
 
@@ -2371,8 +2381,9 @@ function withGlobal(_global) {
2371
2381
  return;
2372
2382
  }
2373
2383
 
2374
- numTimers = Object.keys(clock.timers)
2375
- .length;
2384
+ numTimers = Object.keys(
2385
+ clock.timers
2386
+ ).length;
2376
2387
  if (numTimers === 0) {
2377
2388
  resetIsNearInfiniteLimit();
2378
2389
  resolve(clock.now);
@@ -2420,7 +2431,7 @@ function withGlobal(_global) {
2420
2431
  resolve(clock.now);
2421
2432
  }
2422
2433
 
2423
- resolve(clock.tickAsync(timer.callAt));
2434
+ resolve(clock.tickAsync(timer.callAt - clock.now));
2424
2435
  } catch (e) {
2425
2436
  reject(e);
2426
2437
  }
@@ -2460,11 +2471,7 @@ function withGlobal(_global) {
2460
2471
 
2461
2472
  if (performancePresent) {
2462
2473
  clock.performance = Object.create(null);
2463
- clock.performance.now = function FakeTimersNow() {
2464
- const hrt = hrtime();
2465
- const millis = hrt[0] * 1000 + hrt[1] / 1e6;
2466
- return millis;
2467
- };
2474
+ clock.performance.now = fakePerformanceNow;
2468
2475
  }
2469
2476
 
2470
2477
  if (hrtimePresent) {
@@ -2809,7 +2816,12 @@ class VitestUtils {
2809
2816
  return importer.file;
2810
2817
  }
2811
2818
  mock(path, factory) {
2812
- this._mocker.queueMock(path, this.getImporter(), factory);
2819
+ const importer = this.getImporter();
2820
+ this._mocker.queueMock(
2821
+ path,
2822
+ importer,
2823
+ factory ? () => factory(() => this._mocker.importActual(path, importer)) : void 0
2824
+ );
2813
2825
  }
2814
2826
  unmock(path) {
2815
2827
  this._mocker.queueUnmock(path, this.getImporter());
@@ -56,21 +56,16 @@ function parseStacktrace(e, full = false) {
56
56
  e.stacks = stackFrames;
57
57
  return stackFrames;
58
58
  }
59
- function posToNumber(source, pos) {
60
- if (typeof pos === "number")
61
- return pos;
59
+ function positionToOffset(source, lineNumber, columnNumber) {
62
60
  const lines = source.split(lineSplitRE);
63
- const { line, column } = pos;
64
61
  let start = 0;
65
- if (line > lines.length)
62
+ if (lineNumber > lines.length)
66
63
  return source.length;
67
- for (let i = 0; i < line - 1; i++)
64
+ for (let i = 0; i < lineNumber - 1; i++)
68
65
  start += lines[i].length + 1;
69
- return start + column;
66
+ return start + columnNumber;
70
67
  }
71
- function numberToPos(source, offset) {
72
- if (typeof offset !== "number")
73
- return offset;
68
+ function offsetToLineNumber(source, offset) {
74
69
  if (offset > source.length) {
75
70
  throw new Error(
76
71
  `offset is longer than source length! offset ${offset} > length ${source.length}`
@@ -79,16 +74,13 @@ function numberToPos(source, offset) {
79
74
  const lines = source.split(lineSplitRE);
80
75
  let counted = 0;
81
76
  let line = 0;
82
- let column = 0;
83
77
  for (; line < lines.length; line++) {
84
78
  const lineLength = lines[line].length + 1;
85
- if (counted + lineLength >= offset) {
86
- column = offset - counted + 1;
79
+ if (counted + lineLength >= offset)
87
80
  break;
88
- }
89
81
  counted += lineLength;
90
82
  }
91
- return { line: line + 1, column };
83
+ return line + 1;
92
84
  }
93
85
 
94
- export { posToNumber as a, lineSplitRE as l, numberToPos as n, parseStacktrace as p };
86
+ export { positionToOffset as a, lineSplitRE as l, offsetToLineNumber as o, parseStacktrace as p };
package/dist/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { p as picocolors, n as normalize } from './chunk-utils-env.3fdc1793.js';
2
2
  import { EventEmitter } from 'events';
3
- import { v as version, s as startVitest, d as divider } from './chunk-snapshot-manager.e54d78b8.js';
3
+ import { v as version, s as startVitest, d as divider } from './chunk-snapshot-manager.70695b70.js';
4
4
  import 'tty';
5
5
  import 'node:url';
6
6
  import 'path';
@@ -38,7 +38,7 @@ import 'tinypool';
38
38
  import './vendor-index.783e7f3e.js';
39
39
  import 'perf_hooks';
40
40
  import './chunk-utils-timers.715da787.js';
41
- import './chunk-utils-source-map.59ba6b0a.js';
41
+ import './chunk-utils-source-map.5278ee22.js';
42
42
  import 'crypto';
43
43
  import 'vite-node/utils';
44
44
  import './vendor-index.9c919048.js';
@@ -692,18 +692,24 @@ async function typecheck(cliFilters = [], options = {}) {
692
692
  console.warn(picocolors.exports.yellow("Testing types with tsc and vue-tsc is an experimental feature.\nBreaking changes might not follow semver, please pin Vitest's version when using it."));
693
693
  await start("typecheck", cliFilters, options);
694
694
  }
695
- function normalizeOptions(argv) {
695
+ function normalizeCliOptions(argv) {
696
696
  if (argv.root)
697
697
  argv.root = normalize(argv.root);
698
+ else
699
+ delete argv.root;
698
700
  if (argv.config)
699
701
  argv.config = normalize(argv.config);
702
+ else
703
+ delete argv.config;
700
704
  if (argv.dir)
701
705
  argv.dir = normalize(argv.dir);
706
+ else
707
+ delete argv.dir;
702
708
  return argv;
703
709
  }
704
710
  async function start(mode, cliFilters, options) {
705
711
  try {
706
- const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeOptions(options));
712
+ const ctx = await startVitest(mode, cliFilters.map(normalize), normalizeCliOptions(options));
707
713
  if (!(ctx == null ? void 0 : ctx.config.watch))
708
714
  await (ctx == null ? void 0 : ctx.exit());
709
715
  return ctx;
package/dist/config.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { UserConfig as UserConfig$2, ConfigEnv } from 'vite';
2
2
  export { ConfigEnv } from 'vite';
3
- import { U as UserConfig$1, ao as ResolvedCoverageOptions, F as FakeTimerInstallOpts } from './types-c41bae41.js';
3
+ import { U as UserConfig$1, ao as ResolvedCoverageOptions, F as FakeTimerInstallOpts } from './types-bae746aa.js';
4
4
  import 'tinybench';
5
5
  import 'vite-node/client';
6
6
  import 'vite-node/server';
package/dist/entry.js CHANGED
@@ -1,21 +1,21 @@
1
1
  import { promises } from 'node:fs';
2
2
  import { g as getWorkerState, a as resetModules } from './chunk-typecheck-constants.06e1fe5b.js';
3
- import { v as vi } from './chunk-utils-import.afe2ffde.js';
3
+ import { v as vi } from './chunk-utils-import.e7f64637.js';
4
4
  import { a as envs } from './chunk-env-node.b3664da2.js';
5
- import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-setup.9cdedce6.js';
5
+ import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-setup.a06d5c72.js';
6
6
  import 'node:path';
7
7
  import './chunk-utils-env.3fdc1793.js';
8
8
  import 'tty';
9
9
  import 'node:url';
10
10
  import 'path';
11
11
  import 'local-pkg';
12
- import './chunk-runtime-chain.4cd984be.js';
12
+ import './chunk-runtime-chain.f51aa930.js';
13
13
  import 'util';
14
14
  import 'chai';
15
15
  import './vendor-_commonjsHelpers.addc3445.js';
16
16
  import './chunk-runtime-rpc.54d72169.js';
17
17
  import './chunk-utils-timers.715da787.js';
18
- import './chunk-utils-source-map.59ba6b0a.js';
18
+ import './chunk-utils-source-map.5278ee22.js';
19
19
  import 'fs';
20
20
  import './spy.js';
21
21
  import 'tinyspy';
@@ -1,4 +1,4 @@
1
- import { ae as Environment } from './types-c41bae41.js';
1
+ import { af as Environment } from './types-bae746aa.js';
2
2
  import 'vite';
3
3
  import 'tinybench';
4
4
  import 'vite-node/client';
@@ -1,5 +1,5 @@
1
1
  import { SpyImpl } from 'tinyspy';
2
- import { w as SuiteAPI, v as TestAPI, aw as BenchmarkAPI, y as SuiteHooks, H as HookListener, L as TestContext, p as Suite, x as HookCleanupCallback, O as OnTestFailedHandler, q as Test } from './types-c41bae41.js';
2
+ import { x as SuiteAPI, w as TestAPI, aw as BenchmarkAPI, z as SuiteHooks, H as HookListener, N as TestContext, q as Suite, y as HookCleanupCallback, O as OnTestFailedHandler, r as Test } from './types-bae746aa.js';
3
3
 
4
4
  declare type Not<T extends boolean> = T extends true ? false : true;
5
5
  declare type And<Types extends boolean[]> = Types[number] extends true ? true : false;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { s as spyOn, f as fn, M as MaybeMockedDeep, a as MaybeMocked, b as MaybePartiallyMocked, c as MaybePartiallyMockedDeep, E as EnhancedSpy } from './index-1e9f7f83.js';
2
- export { A as AssertType, E as EnhancedSpy, q as ExpectTypeOf, x as Mock, y as MockContext, w as MockInstance, z as Mocked, B as MockedClass, u as MockedFunction, v as MockedObject, S as SpyInstance, j as afterAll, l as afterEach, r as assertType, h as beforeAll, k as beforeEach, g as bench, n as createExpect, e as describe, m as expect, p as expectTypeOf, i as it, o as onTestFailed, d as suite, t as test } from './index-1e9f7f83.js';
3
- import { D as DoneCallback, F as FakeTimerInstallOpts, R as RuntimeConfig, a as File, T as TaskResultPack, b as ResolvedConfig, M as ModuleGraphData, c as Reporter } from './types-c41bae41.js';
4
- export { a1 as AfterSuiteRunMeta, A as ApiConfig, a7 as ArgumentsType, a6 as Arrayable, a4 as Awaitable, ap as BaseCoverageOptions, av as BenchFunction, at as Benchmark, aw as BenchmarkAPI, au as BenchmarkResult, as as BenchmarkUserOptions, B as BuiltinEnvironment, i as CSSModuleScopeStrategy, C as CollectLineNumbers, f as CollectLines, ab as Constructable, h as Context, ar as CoverageC8Options, aq as CoverageIstanbulOptions, an as CoverageOptions, ak as CoverageProvider, al as CoverageProviderModule, am as CoverageReporter, a9 as DeepMerge, D as DoneCallback, ae as Environment, E as EnvironmentOptions, ad as EnvironmentReturn, ai as ErrorWithDiff, a as File, x as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, a8 as MergeInsertions, ac as ModuleCache, M as ModuleGraphData, aa as MutableArray, a5 as Nullable, aj as OnServerRestartHandler, O as OnTestFailedHandler, ah as ParsedStack, ag as Position, d as RawErrsMap, c as Reporter, a0 as ResolveIdFunction, b as ResolvedConfig, ao as ResolvedCoverageOptions, g as RootAndTarget, l as RunMode, R as RuntimeConfig, K as RuntimeContext, S as SequenceHooks, P as SnapshotData, X as SnapshotMatchOptions, Y as SnapshotResult, W as SnapshotStateOptions, _ as SnapshotSummary, Q as SnapshotUpdateState, p as Suite, w as SuiteAPI, z as SuiteCollector, G as SuiteFactory, y as SuiteHooks, s as Task, n as TaskBase, o as TaskResult, T as TaskResultPack, m as TaskState, q as Test, v as TestAPI, L as TestContext, t as TestFunction, u as TestOptions, e as TscErrorInfo, r as TypeCheck, k as TypecheckConfig, Z as UncheckedSnapshot, U as UserConfig, af as UserConsoleLog, N as Vitest, V as VitestEnvironment, j as VitestRunMode, $ as WorkerContext, a3 as WorkerGlobalState, a2 as WorkerRPC } from './types-c41bae41.js';
1
+ import { s as spyOn, f as fn, M as MaybeMockedDeep, a as MaybeMocked, b as MaybePartiallyMocked, c as MaybePartiallyMockedDeep, E as EnhancedSpy } from './index-761e769b.js';
2
+ export { A as AssertType, E as EnhancedSpy, q as ExpectTypeOf, x as Mock, y as MockContext, w as MockInstance, z as Mocked, B as MockedClass, u as MockedFunction, v as MockedObject, S as SpyInstance, j as afterAll, l as afterEach, r as assertType, h as beforeAll, k as beforeEach, g as bench, n as createExpect, e as describe, m as expect, p as expectTypeOf, i as it, o as onTestFailed, d as suite, t as test } from './index-761e769b.js';
3
+ import { D as DoneCallback, F as FakeTimerInstallOpts, M as MockFactoryWithHelper, R as RuntimeConfig, a as File, T as TaskResultPack, b as ResolvedConfig, c as ModuleGraphData, d as Reporter } from './types-bae746aa.js';
4
+ export { a2 as AfterSuiteRunMeta, A as ApiConfig, a8 as ArgumentsType, a7 as Arrayable, a5 as Awaitable, ap as BaseCoverageOptions, av as BenchFunction, at as Benchmark, aw as BenchmarkAPI, au as BenchmarkResult, as as BenchmarkUserOptions, B as BuiltinEnvironment, j as CSSModuleScopeStrategy, C as CollectLineNumbers, g as CollectLines, ac as Constructable, i as Context, ar as CoverageC8Options, aq as CoverageIstanbulOptions, an as CoverageOptions, ak as CoverageProvider, al as CoverageProviderModule, am as CoverageReporter, aa as DeepMerge, D as DoneCallback, af as Environment, E as EnvironmentOptions, ae as EnvironmentReturn, ai as ErrorWithDiff, a as File, y as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, a9 as MergeInsertions, ad as ModuleCache, c as ModuleGraphData, ab as MutableArray, a6 as Nullable, aj as OnServerRestartHandler, O as OnTestFailedHandler, ah as ParsedStack, e as RawErrsMap, d as Reporter, a1 as ResolveIdFunction, b as ResolvedConfig, ao as ResolvedCoverageOptions, h as RootAndTarget, m as RunMode, R as RuntimeConfig, L as RuntimeContext, S as SequenceHooks, Q as SnapshotData, Y as SnapshotMatchOptions, Z as SnapshotResult, X as SnapshotStateOptions, $ as SnapshotSummary, W as SnapshotUpdateState, q as Suite, x as SuiteAPI, G as SuiteCollector, K as SuiteFactory, z as SuiteHooks, t as Task, o as TaskBase, p as TaskResult, T as TaskResultPack, n as TaskState, r as Test, w as TestAPI, N as TestContext, u as TestFunction, v as TestOptions, f as TscErrorInfo, s as TypeCheck, l as TypecheckConfig, _ as UncheckedSnapshot, U as UserConfig, ag as UserConsoleLog, P as Vitest, V as VitestEnvironment, k as VitestRunMode, a0 as WorkerContext, a4 as WorkerGlobalState, a3 as WorkerRPC } from './types-bae746aa.js';
5
5
  import { TransformResult } from 'vite';
6
6
  import * as chai from 'chai';
7
7
  export { chai };
@@ -69,7 +69,7 @@ declare class VitestUtils {
69
69
  * @param path Path to the module. Can be aliased, if your config supports it
70
70
  * @param factory Factory for the mocked module. Has the highest priority.
71
71
  */
72
- mock(path: string, factory?: () => any): void;
72
+ mock(path: string, factory?: MockFactoryWithHelper): void;
73
73
  /**
74
74
  * Removes module from mocked registry. All subsequent calls to import will
75
75
  * return original module even if it was mocked.
@@ -90,7 +90,7 @@ declare class VitestUtils {
90
90
  * @param path Path to the module. Can be aliased, if your config supports it
91
91
  * @returns Actual module without spies
92
92
  */
93
- importActual<T>(path: string): Promise<T>;
93
+ importActual<T = unknown>(path: string): Promise<T>;
94
94
  /**
95
95
  * Imports a module with all of its properties and nested properties mocked.
96
96
  * For the rules applied, see docs.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export { b as bench, c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.4cd984be.js';
2
- import { e as dist } from './chunk-utils-import.afe2ffde.js';
3
- export { a as afterAll, d as afterEach, f as assertType, b as beforeAll, c as beforeEach, k as getRunningMode, h as isFirstRun, l as isWatchMode, o as onTestFailed, g as runOnce, v as vi, j as vitest, w as withCallback } from './chunk-utils-import.afe2ffde.js';
1
+ export { b as bench, c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.f51aa930.js';
2
+ import { e as dist } from './chunk-utils-import.e7f64637.js';
3
+ export { a as afterAll, d as afterEach, f as assertType, b as beforeAll, c as beforeEach, k as getRunningMode, h as isFirstRun, l as isWatchMode, o as onTestFailed, g as runOnce, v as vi, j as vitest, w as withCallback } from './chunk-utils-import.e7f64637.js';
4
4
  import * as chai from 'chai';
5
5
  export { chai };
6
6
  export { assert, should } from 'chai';
@@ -16,7 +16,7 @@ import './vendor-_commonjsHelpers.addc3445.js';
16
16
  import './chunk-runtime-rpc.54d72169.js';
17
17
  import './chunk-utils-timers.715da787.js';
18
18
  import 'node:fs';
19
- import './chunk-utils-source-map.59ba6b0a.js';
19
+ import './chunk-utils-source-map.5278ee22.js';
20
20
  import 'fs';
21
21
  import './spy.js';
22
22
  import 'tinyspy';
package/dist/node.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { j as VitestRunMode, U as UserConfig, N as Vitest, ax as MockMap, ay as TestSequencer } from './types-c41bae41.js';
2
- export { ay as TestSequencer, aA as TestSequencerConstructor, N as Vitest, az as startVitest } from './types-c41bae41.js';
1
+ import { k as VitestRunMode, U as UserConfig, P as Vitest, ax as MockFactory, ay as MockMap, az as TestSequencer } from './types-bae746aa.js';
2
+ export { az as TestSequencer, aB as TestSequencerConstructor, P as Vitest, aA as startVitest } from './types-bae746aa.js';
3
3
  import { UserConfig as UserConfig$1, Plugin } from 'vite';
4
4
  import { ViteNodeRunner } from 'vite-node/client';
5
5
  import { ViteNodeRunnerOptions } from 'vite-node';
@@ -26,23 +26,23 @@ declare class VitestMocker {
26
26
  private get moduleCache();
27
27
  getSuiteFilepath(): string;
28
28
  getMocks(): {
29
- [x: string]: string | (() => unknown) | null;
29
+ [x: string]: string | MockFactory | null;
30
30
  };
31
31
  private resolvePath;
32
32
  private resolveMocks;
33
33
  private callFunctionMock;
34
34
  getMockPath(dep: string): string;
35
- getDependencyMock(id: string): string | (() => unknown) | null;
35
+ getDependencyMock(id: string): string | MockFactory | null;
36
36
  normalizePath(path: string): string;
37
37
  resolveMockPath(mockPath: string, external: string | null): string | null;
38
38
  mockObject(object: Record<Key, any>, mockExports?: Record<Key, any>): Record<Key, any>;
39
39
  unmockPath(path: string): void;
40
- mockPath(originalId: string, path: string, external: string | null, factory?: () => any): void;
40
+ mockPath(originalId: string, path: string, external: string | null, factory?: MockFactory): void;
41
41
  importActual<T>(rawId: string, importee: string): Promise<T>;
42
42
  importMock(rawId: string, importee: string): Promise<any>;
43
43
  initializeSpyModule(): Promise<void>;
44
44
  requestWithMock(url: string, callstack: string[]): Promise<any>;
45
- queueMock(id: string, importer: string, factory?: () => unknown): void;
45
+ queueMock(id: string, importer: string, factory?: MockFactory): void;
46
46
  queueUnmock(id: string, importer: string): void;
47
47
  }
48
48
 
package/dist/node.js CHANGED
@@ -1,5 +1,5 @@
1
- export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-snapshot-manager.e54d78b8.js';
2
- export { V as VitestRunner } from './chunk-runtime-mocker.3fa602ba.js';
1
+ export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-snapshot-manager.70695b70.js';
2
+ export { V as VitestRunner } from './chunk-runtime-mocker.887bf8c8.js';
3
3
  import './chunk-utils-env.3fdc1793.js';
4
4
  import 'tty';
5
5
  import 'node:url';
@@ -39,7 +39,7 @@ import 'tinypool';
39
39
  import './vendor-index.783e7f3e.js';
40
40
  import 'perf_hooks';
41
41
  import './chunk-utils-timers.715da787.js';
42
- import './chunk-utils-source-map.59ba6b0a.js';
42
+ import './chunk-utils-source-map.5278ee22.js';
43
43
  import 'crypto';
44
44
  import 'vite-node/utils';
45
45
  import './vendor-index.9c919048.js';
package/dist/suite.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import 'util';
2
2
  import 'chai';
3
3
  import './chunk-typecheck-constants.06e1fe5b.js';
4
- export { b as bench, f as clearCollectorContext, q as createSuiteHooks, h as defaultSuite, d as describe, g as getCurrentSuite, i as it, s as suite, t as test } from './chunk-runtime-chain.4cd984be.js';
4
+ export { b as bench, f as clearCollectorContext, q as createSuiteHooks, h as defaultSuite, d as describe, g as getCurrentSuite, i as it, s as suite, t as test } from './chunk-runtime-chain.f51aa930.js';
5
5
  import 'node:path';
6
6
  import './chunk-utils-env.3fdc1793.js';
7
7
  import 'tty';
@@ -12,7 +12,7 @@ import './vendor-_commonjsHelpers.addc3445.js';
12
12
  import './chunk-runtime-rpc.54d72169.js';
13
13
  import './chunk-utils-timers.715da787.js';
14
14
  import 'node:fs';
15
- import './chunk-utils-source-map.59ba6b0a.js';
15
+ import './chunk-utils-source-map.5278ee22.js';
16
16
  import 'fs';
17
17
  import './spy.js';
18
18
  import 'tinyspy';
@@ -234,6 +234,7 @@ declare class Typechecker {
234
234
  start(): Promise<void>;
235
235
  getResult(): ErrorsCache;
236
236
  getTestFiles(): File[];
237
+ getTestPacks(): TaskResultPack[];
237
238
  }
238
239
 
239
240
  type RunWithFiles = (files: string[], invalidates?: string[]) => Promise<void>;
@@ -409,7 +410,9 @@ declare class Vitest {
409
410
  onAfterSetServer(fn: OnServerRestartHandler): void;
410
411
  }
411
412
 
412
- type MockMap = Map<string, Record<string, string | null | (() => unknown)>>;
413
+ type MockFactoryWithHelper = (importOriginal: <T = unknown>() => Promise<T>) => any;
414
+ type MockFactory = () => any;
415
+ type MockMap = Map<string, Record<string, string | null | MockFactory>>;
413
416
 
414
417
  interface TestSequencer {
415
418
  /**
@@ -838,17 +841,11 @@ interface UserConsoleLog {
838
841
  time: number;
839
842
  size: number;
840
843
  }
841
- interface Position {
842
- source?: string;
843
- line: number;
844
- column: number;
845
- }
846
844
  interface ParsedStack {
847
845
  method: string;
848
846
  file: string;
849
847
  line: number;
850
848
  column: number;
851
- sourcePos?: Position;
852
849
  }
853
850
  interface ErrorWithDiff extends Error {
854
851
  name: string;
@@ -972,6 +969,7 @@ interface Suite extends TaskBase {
972
969
  tasks: Task[];
973
970
  filepath?: string;
974
971
  benchmark?: Bench;
972
+ projectName?: string;
975
973
  }
976
974
  interface File extends Suite {
977
975
  filepath: string;
@@ -1454,6 +1452,10 @@ interface EnvironmentOptions {
1454
1452
  }
1455
1453
  type VitestRunMode = 'test' | 'benchmark' | 'typecheck';
1456
1454
  interface InlineConfig {
1455
+ /**
1456
+ * Name of the project. Will be used to display in the reporter.
1457
+ */
1458
+ name?: string;
1457
1459
  /**
1458
1460
  * Benchmark options.
1459
1461
  *
@@ -2243,4 +2245,4 @@ type Context = RootAndTarget & {
2243
2245
  lastActivePath?: string;
2244
2246
  };
2245
2247
 
2246
- export { WorkerContext as $, ApiConfig as A, BuiltinEnvironment as B, CollectLineNumbers as C, DoneCallback as D, EnvironmentOptions as E, FakeTimerInstallOpts as F, SuiteFactory as G, HookListener as H, InlineConfig as I, JSDOMOptions as J, RuntimeContext as K, TestContext as L, ModuleGraphData as M, Vitest as N, OnTestFailedHandler as O, SnapshotData as P, SnapshotUpdateState as Q, RuntimeConfig as R, SequenceHooks as S, TaskResultPack as T, UserConfig as U, VitestEnvironment as V, SnapshotStateOptions as W, SnapshotMatchOptions as X, SnapshotResult as Y, UncheckedSnapshot as Z, SnapshotSummary as _, File as a, ResolveIdFunction as a0, AfterSuiteRunMeta as a1, WorkerRPC as a2, WorkerGlobalState as a3, Awaitable as a4, Nullable as a5, Arrayable as a6, ArgumentsType$1 as a7, MergeInsertions as a8, DeepMerge as a9, TestSequencerConstructor as aA, MutableArray as aa, Constructable as ab, ModuleCache as ac, EnvironmentReturn as ad, Environment as ae, UserConsoleLog as af, Position as ag, ParsedStack as ah, ErrorWithDiff as ai, OnServerRestartHandler as aj, CoverageProvider as ak, CoverageProviderModule as al, CoverageReporter as am, CoverageOptions as an, ResolvedCoverageOptions as ao, BaseCoverageOptions as ap, CoverageIstanbulOptions as aq, CoverageC8Options as ar, BenchmarkUserOptions as as, Benchmark as at, BenchmarkResult as au, BenchFunction as av, BenchmarkAPI as aw, MockMap as ax, TestSequencer as ay, startVitest as az, ResolvedConfig as b, Reporter as c, RawErrsMap as d, TscErrorInfo as e, CollectLines as f, RootAndTarget as g, Context as h, CSSModuleScopeStrategy as i, VitestRunMode as j, TypecheckConfig as k, RunMode as l, TaskState as m, TaskBase as n, TaskResult as o, Suite as p, Test as q, TypeCheck as r, Task as s, TestFunction as t, TestOptions as u, TestAPI as v, SuiteAPI as w, HookCleanupCallback as x, SuiteHooks as y, SuiteCollector as z };
2248
+ export { SnapshotSummary as $, ApiConfig as A, BuiltinEnvironment as B, CollectLineNumbers as C, DoneCallback as D, EnvironmentOptions as E, FakeTimerInstallOpts as F, SuiteCollector as G, HookListener as H, InlineConfig as I, JSDOMOptions as J, SuiteFactory as K, RuntimeContext as L, MockFactoryWithHelper as M, TestContext as N, OnTestFailedHandler as O, Vitest as P, SnapshotData as Q, RuntimeConfig as R, SequenceHooks as S, TaskResultPack as T, UserConfig as U, VitestEnvironment as V, SnapshotUpdateState as W, SnapshotStateOptions as X, SnapshotMatchOptions as Y, SnapshotResult as Z, UncheckedSnapshot as _, File as a, WorkerContext as a0, ResolveIdFunction as a1, AfterSuiteRunMeta as a2, WorkerRPC as a3, WorkerGlobalState as a4, Awaitable as a5, Nullable as a6, Arrayable as a7, ArgumentsType$1 as a8, MergeInsertions as a9, startVitest as aA, TestSequencerConstructor as aB, DeepMerge as aa, MutableArray as ab, Constructable as ac, ModuleCache as ad, EnvironmentReturn as ae, Environment as af, UserConsoleLog as ag, ParsedStack as ah, ErrorWithDiff as ai, OnServerRestartHandler as aj, CoverageProvider as ak, CoverageProviderModule as al, CoverageReporter as am, CoverageOptions as an, ResolvedCoverageOptions as ao, BaseCoverageOptions as ap, CoverageIstanbulOptions as aq, CoverageC8Options as ar, BenchmarkUserOptions as as, Benchmark as at, BenchmarkResult as au, BenchFunction as av, BenchmarkAPI as aw, MockFactory as ax, MockMap as ay, TestSequencer as az, ResolvedConfig as b, ModuleGraphData as c, Reporter as d, RawErrsMap as e, TscErrorInfo as f, CollectLines as g, RootAndTarget as h, Context as i, CSSModuleScopeStrategy as j, VitestRunMode as k, TypecheckConfig as l, RunMode as m, TaskState as n, TaskBase as o, TaskResult as p, Suite as q, Test as r, TypeCheck as s, Task as t, TestFunction as u, TestOptions as v, TestAPI as w, SuiteAPI as x, HookCleanupCallback as y, SuiteHooks as z };
package/dist/worker.js CHANGED
@@ -3,7 +3,7 @@ import { c as createBirpc } from './vendor-index.783e7f3e.js';
3
3
  import { workerId } from 'tinypool';
4
4
  import { ModuleCacheMap } from 'vite-node/client';
5
5
  import { g as getWorkerState } from './chunk-typecheck-constants.06e1fe5b.js';
6
- import { e as executeInViteNode } from './chunk-runtime-mocker.3fa602ba.js';
6
+ import { e as executeInViteNode } from './chunk-runtime-mocker.887bf8c8.js';
7
7
  import { r as rpc } from './chunk-runtime-rpc.54d72169.js';
8
8
  import { p as processError } from './chunk-runtime-error.f5c8aaf2.js';
9
9
  import 'tty';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vitest",
3
3
  "type": "module",
4
- "version": "0.26.1",
4
+ "version": "0.26.3",
5
5
  "description": "A blazing fast unit test framework powered by Vite",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -114,12 +114,12 @@
114
114
  "tinypool": "^0.3.0",
115
115
  "tinyspy": "^1.0.2",
116
116
  "vite": "^3.0.0 || ^4.0.0",
117
- "vite-node": "0.26.1"
117
+ "vite-node": "0.26.3"
118
118
  },
119
119
  "devDependencies": {
120
120
  "@antfu/install-pkg": "^0.1.1",
121
121
  "@edge-runtime/vm": "2.0.2",
122
- "@sinonjs/fake-timers": "^10.0.0",
122
+ "@sinonjs/fake-timers": "^10.0.2",
123
123
  "@types/diff": "^5.0.2",
124
124
  "@types/jsdom": "^20.0.1",
125
125
  "@types/micromatch": "^4.0.2",
@@ -155,7 +155,7 @@
155
155
  "strip-ansi": "^7.0.1",
156
156
  "typescript": "^4.9.4",
157
157
  "ws": "^8.11.0",
158
- "@vitest/ui": "0.26.1"
158
+ "@vitest/ui": "0.26.3"
159
159
  },
160
160
  "scripts": {
161
161
  "build": "rimraf dist && rollup -c",