vitest 0.23.0 → 0.23.1

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.mjs CHANGED
@@ -1,21 +1,21 @@
1
- export { c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.2af36ddf.mjs';
2
- export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach } from './chunk-runtime-hooks.75ce0575.mjs';
3
- export { a as setupGlobalEnv, s as startTests } from './chunk-runtime-error.ed9b4f70.mjs';
1
+ export { c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.8bfc559b.mjs';
2
+ export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach } from './chunk-runtime-hooks.c6b06bd8.mjs';
3
+ export { a as setupGlobalEnv, s as startTests } from './chunk-runtime-error.252dd130.mjs';
4
4
  import * as chai from 'chai';
5
5
  export { chai };
6
6
  export { assert, should } from 'chai';
7
7
  import 'util';
8
- import './chunk-mock-date.0d86eaa5.mjs';
8
+ import './chunk-mock-date.f63a5ff2.mjs';
9
9
  import 'path';
10
10
  import './chunk-constants.6196597b.mjs';
11
11
  import 'tty';
12
12
  import 'url';
13
13
  import 'local-pkg';
14
14
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
15
- import './chunk-runtime-rpc.3fe371e9.mjs';
15
+ import './chunk-runtime-rpc.48bd94e3.mjs';
16
16
  import './chunk-utils-timers.b48455ed.mjs';
17
17
  import 'fs';
18
- import './chunk-utils-source-map.70ee97e1.mjs';
18
+ import './chunk-utils-source-map.a1647f5f.mjs';
19
19
  import './spy.mjs';
20
20
  import 'tinyspy';
21
21
  import 'perf_hooks';
@@ -1,5 +1,5 @@
1
1
  import { promises } from 'fs';
2
- import { c as createBirpc } from './chunk-vite-node-client.74ebe3d5.mjs';
2
+ import { c as createBirpc } from './chunk-vite-node-client.998e04d0.mjs';
3
3
  import require$$0$1 from 'stream';
4
4
  import require$$0 from 'zlib';
5
5
  import require$$3 from 'net';
@@ -10,16 +10,16 @@ import require$$1 from 'https';
10
10
  import require$$2$1 from 'http';
11
11
  import url from 'url';
12
12
  import { A as API_PATH } from './chunk-constants.6196597b.mjs';
13
- import { i as interpretSourcePos, p as parseStacktrace } from './chunk-utils-source-map.70ee97e1.mjs';
13
+ import { i as interpretSourcePos, p as parseStacktrace } from './chunk-utils-source-map.a1647f5f.mjs';
14
14
  import 'module';
15
15
  import 'vm';
16
- import './chunk-vite-node-utils.68573626.mjs';
16
+ import './chunk-vite-node-utils.8a9b3014.mjs';
17
17
  import 'path';
18
18
  import 'assert';
19
19
  import 'util';
20
20
  import 'debug';
21
21
  import 'tty';
22
- import './chunk-mock-date.0d86eaa5.mjs';
22
+ import './chunk-mock-date.f63a5ff2.mjs';
23
23
  import 'local-pkg';
24
24
 
25
25
  /*! (c) 2020 Andrea Giammarchi */
@@ -1,18 +1,18 @@
1
1
  import { k as globalApis } from './chunk-constants.6196597b.mjs';
2
- import { i as index } from './chunk-runtime-hooks.75ce0575.mjs';
2
+ import { i as index } from './chunk-runtime-hooks.c6b06bd8.mjs';
3
3
  import 'tty';
4
4
  import 'url';
5
5
  import 'path';
6
- import './chunk-runtime-chain.2af36ddf.mjs';
6
+ import './chunk-runtime-chain.8bfc559b.mjs';
7
7
  import 'util';
8
- import './chunk-mock-date.0d86eaa5.mjs';
8
+ import './chunk-mock-date.f63a5ff2.mjs';
9
9
  import 'local-pkg';
10
10
  import 'chai';
11
11
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
12
- import './chunk-runtime-rpc.3fe371e9.mjs';
12
+ import './chunk-runtime-rpc.48bd94e3.mjs';
13
13
  import './chunk-utils-timers.b48455ed.mjs';
14
14
  import 'fs';
15
- import './chunk-utils-source-map.70ee97e1.mjs';
15
+ import './chunk-utils-source-map.a1647f5f.mjs';
16
16
  import './spy.mjs';
17
17
  import 'tinyspy';
18
18
 
@@ -221,7 +221,7 @@ function getWorkerState() {
221
221
  var _a;
222
222
  const isNode = typeof process < "u" && typeof process.stdout < "u" && !((_a = process.versions) == null ? void 0 : _a.deno) && !globalThis.window;
223
223
  const isBrowser = typeof window !== "undefined";
224
- const isWindows = isNode && process.platform === "win32";
224
+ isNode && process.platform === "win32";
225
225
  const getRunMode = () => getWorkerState().config.mode;
226
226
  const isRunningInTest = () => getRunMode() === "test";
227
227
  const isRunningInBenchmark = () => getRunMode() === "benchmark";
@@ -329,4 +329,4 @@ function createDefer() {
329
329
  return p;
330
330
  }
331
331
 
332
- export { AggregateErrorPonyfill as A, hasFailedSnapshot as B, getSuites as C, deepMerge as D, ensurePackageInstalled as E, stdout as F, isWindows as G, mergeSlashes as H, getAllMockableProperties as I, RealDate as R, resetModules as a, getCallLastIndex as b, getNames as c, assertTypes as d, getFullName as e, isRunningInTest as f, getWorkerState as g, isRunningInBenchmark as h, isObject as i, notNullish as j, deepClone as k, getType as l, mockDate as m, noop as n, isNode as o, relativePath as p, isBrowser as q, resetDate as r, slash as s, toArray as t, partitionSuiteChildren as u, shuffle as v, hasTests as w, hasFailed as x, createDefer as y, getTests as z };
332
+ export { AggregateErrorPonyfill as A, hasFailedSnapshot as B, getSuites as C, deepMerge as D, ensurePackageInstalled as E, stdout as F, mergeSlashes as G, getAllMockableProperties as H, RealDate as R, resetModules as a, getCallLastIndex as b, getNames as c, assertTypes as d, getFullName as e, isRunningInTest as f, getWorkerState as g, isRunningInBenchmark as h, isObject as i, notNullish as j, deepClone as k, getType as l, mockDate as m, noop as n, isNode as o, relativePath as p, isBrowser as q, resetDate as r, slash as s, toArray as t, partitionSuiteChildren as u, shuffle as v, hasTests as w, hasFailed as x, createDefer as y, getTests as z };
@@ -1,12 +1,12 @@
1
1
  import util$1 from 'util';
2
- import { i as isObject, b as getCallLastIndex, s as slash, g as getWorkerState, c as getNames, d as assertTypes, e as getFullName, f as isRunningInTest, n as noop, h as isRunningInBenchmark } from './chunk-mock-date.0d86eaa5.mjs';
2
+ import { i as isObject, b as getCallLastIndex, s as slash, g as getWorkerState, c as getNames, d as assertTypes, e as getFullName, f as isRunningInTest, n as noop, h as isRunningInBenchmark } from './chunk-mock-date.f63a5ff2.mjs';
3
3
  import * as chai$2 from 'chai';
4
4
  import { expect, AssertionError, util } from 'chai';
5
5
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
6
- import { r as rpc } from './chunk-runtime-rpc.3fe371e9.mjs';
6
+ import { r as rpc } from './chunk-runtime-rpc.48bd94e3.mjs';
7
7
  import fs, { promises } from 'fs';
8
8
  import { j as join, d as dirname, p as picocolors } from './chunk-constants.6196597b.mjs';
9
- import { a as plugins_1, f as format_1, g as getOriginalPos, b as posToNumber, n as numberToPos, l as lineSplitRE, p as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils } from './chunk-utils-source-map.70ee97e1.mjs';
9
+ import { a as plugins_1, f as format_1, g as getOriginalPos, b as posToNumber, n as numberToPos, l as lineSplitRE, p as parseStacktrace, u as unifiedDiff, s as stringify, m as matcherUtils } from './chunk-utils-source-map.a1647f5f.mjs';
10
10
  import { isMockFunction } from './spy.mjs';
11
11
  import { s as safeSetTimeout, a as safeClearTimeout } from './chunk-utils-timers.b48455ed.mjs';
12
12
 
@@ -1,12 +1,12 @@
1
1
  import { performance } from 'perf_hooks';
2
2
  import { t as takeCoverageInsideWorker, p as pLimit } from './chunk-integrations-coverage.99c020eb.mjs';
3
- import { r as resetRunOnceCounter, i as index, v as vi } from './chunk-runtime-hooks.75ce0575.mjs';
4
- import { k as deepClone, l as getType, o as isNode, g as getWorkerState, R as RealDate, t as toArray, p as relativePath, q as isBrowser, h as isRunningInBenchmark, u as partitionSuiteChildren, v as shuffle, w as hasTests, x as hasFailed, y as createDefer, e as getFullName } from './chunk-mock-date.0d86eaa5.mjs';
5
- import { f as clearCollectorContext, h as defaultSuite, j as setHooks, k as getHooks, l as collectorContext, m as getBenchmarkFactory, n as getFn, o as setState, G as GLOBAL_EXPECT, p as getState } from './chunk-runtime-chain.2af36ddf.mjs';
6
- import { r as rpc } from './chunk-runtime-rpc.3fe371e9.mjs';
3
+ import { r as resetRunOnceCounter, i as index, v as vi } from './chunk-runtime-hooks.c6b06bd8.mjs';
4
+ import { k as deepClone, l as getType, o as isNode, g as getWorkerState, R as RealDate, t as toArray, p as relativePath, q as isBrowser, h as isRunningInBenchmark, u as partitionSuiteChildren, v as shuffle, w as hasTests, x as hasFailed, y as createDefer, e as getFullName } from './chunk-mock-date.f63a5ff2.mjs';
5
+ import { f as clearCollectorContext, h as defaultSuite, j as setHooks, k as getHooks, l as collectorContext, m as getBenchmarkFactory, n as getFn, o as setState, G as GLOBAL_EXPECT, p as getState } from './chunk-runtime-chain.8bfc559b.mjs';
6
+ import { r as rpc } from './chunk-runtime-rpc.48bd94e3.mjs';
7
7
  import util$1 from 'util';
8
8
  import { util } from 'chai';
9
- import { s as stringify } from './chunk-utils-source-map.70ee97e1.mjs';
9
+ import { s as stringify } from './chunk-utils-source-map.a1647f5f.mjs';
10
10
  import { e as environments } from './chunk-env-node.ceb43f1c.mjs';
11
11
  import { a as safeClearTimeout, s as safeSetTimeout } from './chunk-utils-timers.b48455ed.mjs';
12
12
 
@@ -154,7 +154,7 @@ async function setupGlobalEnv(config) {
154
154
  if (isNode)
155
155
  await setupConsoleLogSpy();
156
156
  if (config.globals)
157
- (await import('./chunk-integrations-globals.ef598c23.mjs')).registerApiGlobally();
157
+ (await import('./chunk-integrations-globals.b1aa52c3.mjs')).registerApiGlobally();
158
158
  }
159
159
  function setupDefines(defines) {
160
160
  for (const key in defines)
@@ -485,7 +485,7 @@ async function sendTasksUpdate() {
485
485
  async function runTest(test) {
486
486
  var _a, _b;
487
487
  if (test.mode !== "run") {
488
- const { getSnapshotClient } = await import('./chunk-runtime-chain.2af36ddf.mjs').then(function (n) { return n.r; });
488
+ const { getSnapshotClient } = await import('./chunk-runtime-chain.8bfc559b.mjs').then(function (n) { return n.r; });
489
489
  getSnapshotClient().skipTestSnapshots(test);
490
490
  return;
491
491
  }
@@ -501,7 +501,7 @@ async function runTest(test) {
501
501
  updateTask(test);
502
502
  clearModuleMocks();
503
503
  if (isNode) {
504
- const { getSnapshotClient } = await import('./chunk-runtime-chain.2af36ddf.mjs').then(function (n) { return n.r; });
504
+ const { getSnapshotClient } = await import('./chunk-runtime-chain.8bfc559b.mjs').then(function (n) { return n.r; });
505
505
  await getSnapshotClient().setTest(test);
506
506
  }
507
507
  const workerState = getWorkerState();
@@ -561,7 +561,7 @@ async function runTest(test) {
561
561
  if (isBrowser && test.result.error)
562
562
  console.error(test.result.error.message, test.result.error.stackStr);
563
563
  if (isNode) {
564
- const { getSnapshotClient } = await import('./chunk-runtime-chain.2af36ddf.mjs').then(function (n) { return n.r; });
564
+ const { getSnapshotClient } = await import('./chunk-runtime-chain.8bfc559b.mjs').then(function (n) { return n.r; });
565
565
  getSnapshotClient().clearTest();
566
566
  }
567
567
  test.result.duration = now() - start;
@@ -754,7 +754,7 @@ async function startTestsBrowser(paths, config) {
754
754
  async function startTestsNode(paths, config) {
755
755
  const files = await collectTests(paths, config);
756
756
  rpc().onCollected(files);
757
- const { getSnapshotClient } = await import('./chunk-runtime-chain.2af36ddf.mjs').then(function (n) { return n.r; });
757
+ const { getSnapshotClient } = await import('./chunk-runtime-chain.8bfc559b.mjs').then(function (n) { return n.r; });
758
758
  getSnapshotClient().clear();
759
759
  await runFiles(files, config);
760
760
  const coverage = await takeCoverageInsideWorker(config.coverage);
@@ -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.2af36ddf.mjs';
2
- import { g as getWorkerState, R as RealDate, r as resetDate, m as mockDate, a as resetModules } from './chunk-mock-date.0d86eaa5.mjs';
3
- import { p as parseStacktrace } from './chunk-utils-source-map.70ee97e1.mjs';
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.8bfc559b.mjs';
2
+ import { g as getWorkerState, R as RealDate, r as resetDate, m as mockDate, a as resetModules } from './chunk-mock-date.f63a5ff2.mjs';
3
+ import { p as parseStacktrace } from './chunk-utils-source-map.a1647f5f.mjs';
4
4
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
5
5
  import util from 'util';
6
6
  import { spyOn, fn, isMockFunction, spies } from './spy.mjs';
@@ -1,8 +1,8 @@
1
- import { V as ViteNodeRunner } from './chunk-vite-node-client.74ebe3d5.mjs';
1
+ import { V as ViteNodeRunner } from './chunk-vite-node-client.998e04d0.mjs';
2
2
  import { normalizePath } from 'vite';
3
- import { g as getWorkerState, G as isWindows, H as mergeSlashes, s as slash, l as getType, I as getAllMockableProperties } from './chunk-mock-date.0d86eaa5.mjs';
3
+ import { g as getWorkerState, G as mergeSlashes, s as slash, l as getType, H as getAllMockableProperties } from './chunk-mock-date.f63a5ff2.mjs';
4
4
  import { existsSync, readdirSync } from 'fs';
5
- import { n as normalizeRequestId, i as isNodeBuiltin, b as toFilePath } from './chunk-vite-node-utils.68573626.mjs';
5
+ import { n as normalizeRequestId, p as pathFromRoot, i as isNodeBuiltin, b as toFilePath } from './chunk-vite-node-utils.8a9b3014.mjs';
6
6
  import { d as dirname, j as join, b as basename, a as resolve, c as distDir } from './chunk-constants.6196597b.mjs';
7
7
 
8
8
  class RefTracker {
@@ -101,12 +101,12 @@ const _VitestMocker = class {
101
101
  return this.getMocks()[id];
102
102
  }
103
103
  normalizePath(path) {
104
- return normalizeRequestId(path.replace(this.root, ""), this.base).replace(/^\/@fs\//, isWindows ? "" : "/");
104
+ return pathFromRoot(this.root, normalizeRequestId(path, this.base));
105
105
  }
106
106
  getFsPath(path, external) {
107
107
  if (external)
108
108
  return mergeSlashes(`/@fs/${path}`);
109
- return normalizeRequestId(path.replace(this.root, ""));
109
+ return normalizeRequestId(path, this.base);
110
110
  }
111
111
  resolveMockPath(mockPath, external) {
112
112
  const path = normalizeRequestId(external || mockPath);
@@ -1,4 +1,4 @@
1
- import { g as getWorkerState } from './chunk-mock-date.0d86eaa5.mjs';
1
+ import { g as getWorkerState } from './chunk-mock-date.f63a5ff2.mjs';
2
2
  import { w as withSafeTimers } from './chunk-utils-timers.b48455ed.mjs';
3
3
 
4
4
  const rpc = () => {
@@ -1,4 +1,4 @@
1
- import { s as slash, j as notNullish } from './chunk-mock-date.0d86eaa5.mjs';
1
+ import { s as slash, j as notNullish } from './chunk-mock-date.f63a5ff2.mjs';
2
2
  import { p as picocolors } from './chunk-constants.6196597b.mjs';
3
3
 
4
4
  var build = {};
@@ -2,7 +2,7 @@ import { createRequire } from 'module';
2
2
  import { pathToFileURL, fileURLToPath } from 'url';
3
3
  import vm from 'vm';
4
4
  import { a as resolve, d as dirname, i as isAbsolute, h as extname } from './chunk-constants.6196597b.mjs';
5
- import { s as slash, n as normalizeRequestId, b as toFilePath, i as isNodeBuiltin, c as isPrimitive, g as getType, d as normalizeModuleId, m as mergeSlashes } from './chunk-vite-node-utils.68573626.mjs';
5
+ import { s as slash, n as normalizeRequestId, b as toFilePath, i as isNodeBuiltin, c as isPrimitive, d as normalizeModuleId, m as mergeSlashes } from './chunk-vite-node-utils.8a9b3014.mjs';
6
6
  import createDebug from 'debug';
7
7
 
8
8
  const debugExecute = createDebug("vite-node:client:execute");
@@ -298,14 +298,9 @@ function defineExport(exports, key, value) {
298
298
  });
299
299
  }
300
300
  function exportAll(exports, sourceModule) {
301
- var _a;
302
301
  if (exports === sourceModule)
303
302
  return;
304
- const type = getType(sourceModule);
305
- if (type !== "Object" && type !== "Module")
306
- return;
307
- const constructor = (_a = sourceModule.constructor) == null ? void 0 : _a.name;
308
- if (constructor && constructor !== "Object")
303
+ if (typeof sourceModule !== "object" || Array.isArray(sourceModule) || !sourceModule)
309
304
  return;
310
305
  for (const key in sourceModule) {
311
306
  if (key !== "default") {
@@ -1,7 +1,7 @@
1
1
  import { a as resolve, j as join, b as basename, d as dirname, c as distDir, e as rootDir, p as picocolors, i as isAbsolute, r as relative, f as configFiles, g as defaultPort, n as normalize, t as toNamespacedPath, E as EXIT_CODE_RESTART } from './chunk-constants.6196597b.mjs';
2
2
  import { p as pLimit, g as getCoverageProvider, C as CoverageProviderMap } from './chunk-integrations-coverage.99c020eb.mjs';
3
3
  import { g as getEnvPackageName } from './chunk-env-node.ceb43f1c.mjs';
4
- import { A as AggregateErrorPonyfill, s as slash$2, o as isNode, p as relativePath, z as getTests, e as getFullName, x as hasFailed, B as hasFailedSnapshot, C as getSuites, j as notNullish, v as shuffle, t as toArray$1, n as noop$1, D as deepMerge, b as getCallLastIndex, E as ensurePackageInstalled, F as stdout } from './chunk-mock-date.0d86eaa5.mjs';
4
+ import { A as AggregateErrorPonyfill, s as slash$2, o as isNode, p as relativePath, z as getTests, e as getFullName, x as hasFailed, B as hasFailedSnapshot, C as getSuites, j as notNullish, v as shuffle, t as toArray$1, n as noop$1, D as deepMerge, b as getCallLastIndex, E as ensurePackageInstalled, F as stdout } from './chunk-mock-date.f63a5ff2.mjs';
5
5
  import { loadConfigFromFile, normalizePath, createServer, mergeConfig } from 'vite';
6
6
  import path$a from 'path';
7
7
  import url, { fileURLToPath } from 'url';
@@ -12,13 +12,13 @@ import util$2 from 'util';
12
12
  import require$$0$1 from 'stream';
13
13
  import require$$2 from 'events';
14
14
  import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
15
- import { c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-client.74ebe3d5.mjs';
15
+ import { c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-client.998e04d0.mjs';
16
16
  import { performance } from 'perf_hooks';
17
17
  import createDebug from 'debug';
18
- import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath, w as withInlineSourcemap } from './chunk-vite-node-utils.68573626.mjs';
18
+ import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath, w as withInlineSourcemap } from './chunk-vite-node-utils.8a9b3014.mjs';
19
19
  import { MessageChannel } from 'worker_threads';
20
20
  import { Tinypool } from 'tinypool';
21
- import { c as stripAnsi, d as cliTruncate, p as parseStacktrace, i as interpretSourcePos, e as stringWidth, h as ansiStyles, j as sliceAnsi, s as stringify$5, u as unifiedDiff, b as posToNumber, l as lineSplitRE } from './chunk-utils-source-map.70ee97e1.mjs';
21
+ import { c as stripAnsi, d as cliTruncate, p as parseStacktrace, i as interpretSourcePos, e as stringWidth, h as ansiStyles, j as sliceAnsi, s as stringify$5, u as unifiedDiff, b as posToNumber, l as lineSplitRE } from './chunk-utils-source-map.a1647f5f.mjs';
22
22
  import { b as safeSetInterval, c as safeClearInterval, s as safeSetTimeout, a as safeClearTimeout } from './chunk-utils-timers.b48455ed.mjs';
23
23
  import { resolveModule } from 'local-pkg';
24
24
  import { createHash } from 'crypto';
@@ -29,7 +29,7 @@ import { stripLiteral } from 'strip-literal';
29
29
  import require$$0$2 from 'readline';
30
30
  import { p as prompts } from './vendor-index.ae96af6e.mjs';
31
31
 
32
- var version$1 = "0.23.0";
32
+ var version$1 = "0.23.1";
33
33
 
34
34
  class EndError extends Error {
35
35
  constructor(value) {
@@ -9373,7 +9373,7 @@ createLogUpdate(process$1.stdout);
9373
9373
 
9374
9374
  createLogUpdate(process$1.stderr);
9375
9375
 
9376
- var version = "0.23.0";
9376
+ var version = "0.23.1";
9377
9377
 
9378
9378
  function fileFromParsedStack(stack) {
9379
9379
  var _a, _b;
@@ -9413,7 +9413,7 @@ async function printError(error, ctx, options = {}) {
9413
9413
  await printError(e.cause, ctx, { fullStack, showCodeFrame: false });
9414
9414
  }
9415
9415
  handleImportOutsideModuleError(e.stack || e.stackStr || "", ctx);
9416
- if (e.showDiff) {
9416
+ if (e.showDiff || e.showDiff === void 0 && e.actual && e.expected) {
9417
9417
  displayDiff(stringify$5(e.actual), stringify$5(e.expected), ctx.logger.console, {
9418
9418
  outputTruncateLength: ctx.config.outputTruncateLength,
9419
9419
  outputDiffLines: ctx.config.outputDiffLines
@@ -10459,7 +10459,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest("test")) {
10459
10459
  try {
10460
10460
  await ctx.setServer(options, server);
10461
10461
  if (options.api && options.watch)
10462
- (await import('./chunk-api-setup.5fc06d1d.mjs')).setup(ctx);
10462
+ (await import('./chunk-api-setup.9e83ca0a.mjs')).setup(ctx);
10463
10463
  } catch (err) {
10464
10464
  ctx.logger.printError(err, true);
10465
10465
  process.exit(1);
@@ -1,10 +1,10 @@
1
+ import { pathToFileURL, fileURLToPath as fileURLToPath$1, URL as URL$1 } from 'url';
2
+ import { a as resolve$1, r as relative } from './chunk-constants.6196597b.mjs';
1
3
  import { builtinModules } from 'module';
2
4
  import fs, { promises, statSync, existsSync, realpathSync, Stats } from 'fs';
3
- import { pathToFileURL, fileURLToPath as fileURLToPath$1, URL as URL$1 } from 'url';
4
5
  import path from 'path';
5
6
  import assert from 'assert';
6
7
  import { format, inspect } from 'util';
7
- import { a as resolve$1 } from './chunk-constants.6196597b.mjs';
8
8
 
9
9
  // This file was generated. Do not modify manually!
10
10
  var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 370, 1, 154, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 161, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 193, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 84, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 406, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 330, 3, 19306, 9, 87, 9, 39, 4, 60, 6, 26, 9, 1014, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4706, 45, 3, 22, 543, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 1418, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 262, 6, 10, 9, 357, 0, 62, 13, 1495, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
@@ -6858,9 +6858,6 @@ const isWindows = process.platform === "win32";
6858
6858
  function slash(str) {
6859
6859
  return str.replace(/\\/g, "/");
6860
6860
  }
6861
- function getType(value) {
6862
- return Object.prototype.toString.apply(value).slice(8, -1);
6863
- }
6864
6861
  function mergeSlashes(str) {
6865
6862
  return str.replace(/\/\//g, "/");
6866
6863
  }
@@ -6875,6 +6872,23 @@ function normalizeModuleId(id) {
6875
6872
  function isPrimitive(v) {
6876
6873
  return v !== Object(v);
6877
6874
  }
6875
+ function pathFromRoot(root, filename) {
6876
+ if (isNodeBuiltin(filename))
6877
+ return filename;
6878
+ filename = filename.replace(/^\/@fs\//, isWindows ? "" : "/");
6879
+ if (!filename.startsWith(root))
6880
+ return filename;
6881
+ const relativePath = relative(root, filename);
6882
+ if (!relativePath.startsWith("/") && !relativePath.startsWith("."))
6883
+ return `/${relativePath}`;
6884
+ let index = 0;
6885
+ for (const char of relativePath) {
6886
+ if (char !== "." && char !== "/")
6887
+ return relativePath.slice(index - 1);
6888
+ index++;
6889
+ }
6890
+ return relativePath;
6891
+ }
6878
6892
  function toFilePath(id, root) {
6879
6893
  let absolute = id.startsWith("/@fs/") ? id.slice(4) : id.startsWith(root) ? id : id.startsWith("/") ? resolve$1(root, id.slice(1)) : id;
6880
6894
  if (absolute.startsWith("//"))
@@ -6902,4 +6916,4 @@ function toArray(array) {
6902
6916
  return [array];
6903
6917
  }
6904
6918
 
6905
- export { isValidNodeImport as a, toFilePath as b, isPrimitive as c, normalizeModuleId as d, getType as g, hasCJSSyntax as h, isNodeBuiltin as i, mergeSlashes as m, normalizeRequestId as n, slash as s, toArray as t, withInlineSourcemap as w };
6919
+ export { isValidNodeImport as a, toFilePath as b, isPrimitive as c, normalizeModuleId as d, hasCJSSyntax as h, isNodeBuiltin as i, mergeSlashes as m, normalizeRequestId as n, pathFromRoot as p, slash as s, toArray as t, withInlineSourcemap as w };
package/dist/cli.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { EventEmitter } from 'events';
2
2
  import { p as picocolors } from './chunk-constants.6196597b.mjs';
3
- import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.41bf722e.mjs';
3
+ import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.3035bd5b.mjs';
4
4
  import 'tty';
5
5
  import 'url';
6
6
  import 'path';
@@ -8,7 +8,7 @@ import './chunk-integrations-coverage.99c020eb.mjs';
8
8
  import 'local-pkg';
9
9
  import './chunk-env-node.ceb43f1c.mjs';
10
10
  import 'console';
11
- import './chunk-mock-date.0d86eaa5.mjs';
11
+ import './chunk-mock-date.f63a5ff2.mjs';
12
12
  import 'vite';
13
13
  import 'process';
14
14
  import 'fs';
@@ -16,16 +16,16 @@ import 'os';
16
16
  import 'util';
17
17
  import 'stream';
18
18
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
19
- import './chunk-vite-node-client.74ebe3d5.mjs';
19
+ import './chunk-vite-node-client.998e04d0.mjs';
20
20
  import 'module';
21
21
  import 'vm';
22
- import './chunk-vite-node-utils.68573626.mjs';
22
+ import './chunk-vite-node-utils.8a9b3014.mjs';
23
23
  import 'assert';
24
24
  import 'debug';
25
25
  import 'perf_hooks';
26
26
  import 'worker_threads';
27
27
  import 'tinypool';
28
- import './chunk-utils-source-map.70ee97e1.mjs';
28
+ import './chunk-utils-source-map.a1647f5f.mjs';
29
29
  import './chunk-utils-timers.b48455ed.mjs';
30
30
  import 'crypto';
31
31
  import './vendor-index.13e3bda3.mjs';
@@ -652,16 +652,20 @@ const cli = cac("vitest");
652
652
  cli.version(version).option("-r, --root <path>", "root path").option("-c, --config <path>", "path to config file").option("-u, --update", "update snapshot").option("-w, --watch", "watch mode").option("-t, --testNamePattern <pattern>", "run tests with full names matching the specified pattern").option("--dir <path>", "base directory to scan for the test files").option("--ui", "enable UI").option("--open", "open UI automatically (default: !process.env.CI))").option("--api [api]", "serve API, available options: --api.port <port>, --api.host [host] and --api.strictPort").option("--threads", "enabled threads (default: true)").option("--silent", "silent console output from tests").option("--isolate", "isolate environment for each test file (default: true)").option("--reporter <name>", "reporter").option("--outputTruncateLength <length>", "diff output length (default: 80)").option("--outputDiffLines <lines>", "number of diff output lines (default: 15)").option("--outputFile <filename/-s>", "write test results to a file when the --reporter=json or --reporter=junit option is also specified, use cac's dot notation for individual outputs of multiple reporters").option("--coverage", "enable coverage report").option("--run", "do not watch").option("--mode <name>", "override Vite mode (default: test)").option("--globals", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--browser", "run tests in browser").option("--environment <env>", "runner environment (default: node)").option("--passWithNoTests", "pass when no tests found").option("--allowOnly", "Allow tests and suites that are marked as only (default: !process.env.CI)").option("--dangerouslyIgnoreUnhandledErrors", "Ignore any unhandled errors that occur").option("--shard <shard>", "Test suite shard to execute in a format of <index>/<count>").option("--changed [since]", "Run tests that are affected by the changed files (default: false)").option("--sequence <options>", "Define in what order to run tests (use --sequence.shuffle to run tests in random order)").option("--no-color", "Removes colors from the console output").option("--segfault-retry <times>", "Return tests on segment fault (default: 0)", { default: 0 }).option("--inspect", "Enable Node.js inspector").option("--inspect-brk", "Enable Node.js inspector with break").help();
653
653
  cli.command("run [...filters]").action(run);
654
654
  cli.command("related [...filters]").action(runRelated);
655
- cli.command("watch [...filters]").action(start);
656
- cli.command("dev [...filters]").action(start);
655
+ cli.command("watch [...filters]").action(watch);
656
+ cli.command("dev [...filters]").action(watch);
657
657
  cli.command("bench [...filters]").action(benchmark);
658
- cli.command("[...filters]").action((filter, options) => start("test", filter, options));
658
+ cli.command("[...filters]").action((filters, options) => start("test", filters, options));
659
659
  cli.parse();
660
660
  async function runRelated(relatedFiles, argv) {
661
661
  argv.related = relatedFiles;
662
662
  argv.passWithNoTests ?? (argv.passWithNoTests = true);
663
663
  await start("test", [], argv);
664
664
  }
665
+ async function watch(cliFilters, options) {
666
+ options.watch = true;
667
+ await start("test", cliFilters, options);
668
+ }
665
669
  async function run(cliFilters, options) {
666
670
  options.run = true;
667
671
  await start("test", cliFilters, options);
package/dist/entry.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import { promises } from 'fs';
2
- import { g as getWorkerState, a as resetModules } from './chunk-mock-date.0d86eaa5.mjs';
2
+ import { g as getWorkerState, a as resetModules } from './chunk-mock-date.f63a5ff2.mjs';
3
3
  import { a as envs } from './chunk-env-node.ceb43f1c.mjs';
4
- import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-error.ed9b4f70.mjs';
4
+ import { a as setupGlobalEnv, s as startTests, w as withEnv } from './chunk-runtime-error.252dd130.mjs';
5
5
  import 'path';
6
6
  import './chunk-constants.6196597b.mjs';
7
7
  import 'tty';
@@ -10,14 +10,14 @@ import 'local-pkg';
10
10
  import 'console';
11
11
  import 'perf_hooks';
12
12
  import './chunk-integrations-coverage.99c020eb.mjs';
13
- import './chunk-runtime-hooks.75ce0575.mjs';
14
- import './chunk-runtime-chain.2af36ddf.mjs';
13
+ import './chunk-runtime-hooks.c6b06bd8.mjs';
14
+ import './chunk-runtime-chain.8bfc559b.mjs';
15
15
  import 'util';
16
16
  import 'chai';
17
17
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
18
- import './chunk-runtime-rpc.3fe371e9.mjs';
18
+ import './chunk-runtime-rpc.48bd94e3.mjs';
19
19
  import './chunk-utils-timers.b48455ed.mjs';
20
- import './chunk-utils-source-map.70ee97e1.mjs';
20
+ import './chunk-utils-source-map.a1647f5f.mjs';
21
21
  import './spy.mjs';
22
22
  import 'tinyspy';
23
23
 
package/dist/index.mjs CHANGED
@@ -1,19 +1,19 @@
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.2af36ddf.mjs';
2
- export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, h as getRunningMode, f as isFirstRun, j as isWatchMode, e as runOnce, v as vi, g as vitest, w as withCallback } from './chunk-runtime-hooks.75ce0575.mjs';
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.8bfc559b.mjs';
2
+ export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, h as getRunningMode, f as isFirstRun, j as isWatchMode, e as runOnce, v as vi, g as vitest, w as withCallback } from './chunk-runtime-hooks.c6b06bd8.mjs';
3
3
  import * as chai from 'chai';
4
4
  export { chai };
5
5
  export { assert, should } from 'chai';
6
6
  import 'util';
7
- import './chunk-mock-date.0d86eaa5.mjs';
7
+ import './chunk-mock-date.f63a5ff2.mjs';
8
8
  import 'path';
9
9
  import './chunk-constants.6196597b.mjs';
10
10
  import 'tty';
11
11
  import 'url';
12
12
  import 'local-pkg';
13
13
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
14
- import './chunk-runtime-rpc.3fe371e9.mjs';
14
+ import './chunk-runtime-rpc.48bd94e3.mjs';
15
15
  import './chunk-utils-timers.b48455ed.mjs';
16
16
  import 'fs';
17
- import './chunk-utils-source-map.70ee97e1.mjs';
17
+ import './chunk-utils-source-map.a1647f5f.mjs';
18
18
  import './spy.mjs';
19
19
  import 'tinyspy';
package/dist/loader.mjs CHANGED
@@ -1,14 +1,14 @@
1
1
  import { pathToFileURL } from 'url';
2
2
  import { readFile } from 'fs/promises';
3
- import { i as isNodeBuiltin, d as normalizeModuleId, h as hasCJSSyntax } from './chunk-vite-node-utils.68573626.mjs';
4
- import { g as getWorkerState } from './chunk-mock-date.0d86eaa5.mjs';
3
+ import { i as isNodeBuiltin, d as normalizeModuleId, h as hasCJSSyntax } from './chunk-vite-node-utils.8a9b3014.mjs';
4
+ import { g as getWorkerState } from './chunk-mock-date.f63a5ff2.mjs';
5
+ import './chunk-constants.6196597b.mjs';
6
+ import 'tty';
7
+ import 'path';
5
8
  import 'module';
6
9
  import 'fs';
7
- import 'path';
8
10
  import 'assert';
9
11
  import 'util';
10
- import './chunk-constants.6196597b.mjs';
11
- import 'tty';
12
12
  import 'local-pkg';
13
13
 
14
14
  var ModuleFormat = /* @__PURE__ */ ((ModuleFormat2) => {
package/dist/node.mjs CHANGED
@@ -1,5 +1,5 @@
1
- export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.41bf722e.mjs';
2
- export { V as VitestRunner } from './chunk-runtime-mocker.fc76f21d.mjs';
1
+ export { B as BaseSequencer, V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.3035bd5b.mjs';
2
+ export { V as VitestRunner } from './chunk-runtime-mocker.d9690273.mjs';
3
3
  import './chunk-constants.6196597b.mjs';
4
4
  import 'tty';
5
5
  import 'url';
@@ -8,7 +8,7 @@ import './chunk-integrations-coverage.99c020eb.mjs';
8
8
  import 'local-pkg';
9
9
  import './chunk-env-node.ceb43f1c.mjs';
10
10
  import 'console';
11
- import './chunk-mock-date.0d86eaa5.mjs';
11
+ import './chunk-mock-date.f63a5ff2.mjs';
12
12
  import 'vite';
13
13
  import 'process';
14
14
  import 'fs';
@@ -17,16 +17,16 @@ import 'util';
17
17
  import 'stream';
18
18
  import 'events';
19
19
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
20
- import './chunk-vite-node-client.74ebe3d5.mjs';
20
+ import './chunk-vite-node-client.998e04d0.mjs';
21
21
  import 'module';
22
22
  import 'vm';
23
- import './chunk-vite-node-utils.68573626.mjs';
23
+ import './chunk-vite-node-utils.8a9b3014.mjs';
24
24
  import 'assert';
25
25
  import 'debug';
26
26
  import 'perf_hooks';
27
27
  import 'worker_threads';
28
28
  import 'tinypool';
29
- import './chunk-utils-source-map.70ee97e1.mjs';
29
+ import './chunk-utils-source-map.a1647f5f.mjs';
30
30
  import './chunk-utils-timers.b48455ed.mjs';
31
31
  import 'crypto';
32
32
  import './vendor-index.13e3bda3.mjs';
package/dist/suite.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import 'util';
2
- import './chunk-mock-date.0d86eaa5.mjs';
3
- 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.2af36ddf.mjs';
2
+ import './chunk-mock-date.f63a5ff2.mjs';
3
+ 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.8bfc559b.mjs';
4
4
  import 'path';
5
5
  import './chunk-constants.6196597b.mjs';
6
6
  import 'tty';
@@ -8,9 +8,9 @@ import 'url';
8
8
  import 'local-pkg';
9
9
  import 'chai';
10
10
  import './vendor-_commonjsHelpers.4da45ef5.mjs';
11
- import './chunk-runtime-rpc.3fe371e9.mjs';
11
+ import './chunk-runtime-rpc.48bd94e3.mjs';
12
12
  import './chunk-utils-timers.b48455ed.mjs';
13
13
  import 'fs';
14
- import './chunk-utils-source-map.70ee97e1.mjs';
14
+ import './chunk-utils-source-map.a1647f5f.mjs';
15
15
  import './spy.mjs';
16
16
  import 'tinyspy';
package/dist/worker.mjs CHANGED
@@ -1,15 +1,15 @@
1
1
  import { a as resolve, c as distDir } from './chunk-constants.6196597b.mjs';
2
- import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-client.74ebe3d5.mjs';
2
+ import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-client.998e04d0.mjs';
3
3
  import { workerId } from 'tinypool';
4
- import { g as getWorkerState } from './chunk-mock-date.0d86eaa5.mjs';
5
- import { e as executeInViteNode } from './chunk-runtime-mocker.fc76f21d.mjs';
6
- import { r as rpc } from './chunk-runtime-rpc.3fe371e9.mjs';
4
+ import { g as getWorkerState } from './chunk-mock-date.f63a5ff2.mjs';
5
+ import { e as executeInViteNode } from './chunk-runtime-mocker.d9690273.mjs';
6
+ import { r as rpc } from './chunk-runtime-rpc.48bd94e3.mjs';
7
7
  import 'tty';
8
8
  import 'url';
9
9
  import 'path';
10
10
  import 'module';
11
11
  import 'vm';
12
- import './chunk-vite-node-utils.68573626.mjs';
12
+ import './chunk-vite-node-utils.8a9b3014.mjs';
13
13
  import 'fs';
14
14
  import 'assert';
15
15
  import 'util';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest",
3
- "version": "0.23.0",
3
+ "version": "0.23.1",
4
4
  "description": "A blazing fast unit test framework powered by Vite",
5
5
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
6
  "license": "MIT",
@@ -113,7 +113,7 @@
113
113
  "@types/natural-compare": "^1.4.1",
114
114
  "@types/prompts": "^2.4.0",
115
115
  "@types/sinonjs__fake-timers": "^8.1.2",
116
- "@vitest/ui": "0.23.0",
116
+ "@vitest/ui": "0.23.1",
117
117
  "birpc": "^0.2.3",
118
118
  "cac": "^6.7.14",
119
119
  "chai-subset": "^1.6.0",
@@ -141,7 +141,7 @@
141
141
  "source-map-js": "^1.0.2",
142
142
  "strip-ansi": "^7.0.1",
143
143
  "typescript": "^4.8.2",
144
- "vite-node": "0.23.0",
144
+ "vite-node": "0.23.1",
145
145
  "ws": "^8.8.1"
146
146
  },
147
147
  "scripts": {