vitest 0.0.118 → 0.0.119

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/cli.js CHANGED
@@ -7,8 +7,8 @@ import process$1 from 'process';
7
7
  import { m as mergeStream, g as getStream, c as crossSpawn } from './index-6e709f57.js';
8
8
  import require$$0, { constants } from 'os';
9
9
  import { s as signalExit } from './index-648e7ab2.js';
10
- import { e as ensurePackageInstalled } from './index-80671389.js';
11
- import { c as createVitest } from './index-62869b66.js';
10
+ import { e as ensurePackageInstalled } from './index-090545ef.js';
11
+ import { c as createVitest } from './index-478354a1.js';
12
12
  import './_commonjsHelpers-c9e3b764.js';
13
13
  import 'fs';
14
14
  import 'stream';
@@ -18,10 +18,10 @@ import 'url';
18
18
  import 'tty';
19
19
  import 'local-pkg';
20
20
  import 'vite';
21
- import './constants-56bfb5ab.js';
21
+ import './constants-22bbd600.js';
22
22
  import './magic-string.es-94000aea.js';
23
23
  import 'perf_hooks';
24
- import './diff-d87307c6.js';
24
+ import './diff-a295cb37.js';
25
25
  import 'module';
26
26
  import 'worker_threads';
27
27
  import 'tinypool';
@@ -1700,8 +1700,9 @@ function execa(file, args, options) {
1700
1700
  return mergePromise(spawned, handlePromiseOnce);
1701
1701
  }
1702
1702
 
1703
- var version = "0.0.118";
1703
+ var version = "0.0.119";
1704
1704
 
1705
+ const CLOSE_TIMEOUT = 1e3;
1705
1706
  const cli = cac("vitest");
1706
1707
  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("-o, --open", "open UI", { default: false }).option("-t, --testNamePattern <pattern>", "run test names with the specified pattern").option("--api", "listen to port and serve API").option("--threads", "enabled threads", { default: true }).option("--silent", "silent console output from tests").option("--reporter <name>", "reporter").option("--coverage", "use c8 for coverage").option("--run", "do not watch").option("--global", "inject apis globally").option("--dom", "mock browser api with happy-dom").option("--environment <env>", "runner environment", { default: "node" }).option("--passWithNoTests", "pass when no tests found").help();
1707
1708
  cli.command("run [...filters]").action(run);
@@ -1751,18 +1752,35 @@ async function run(cliFilters, options) {
1751
1752
  await ctx.close();
1752
1753
  }
1753
1754
  if (!ctx.config.watch) {
1754
- setTimeout(() => process.exit(), 1e3).unref();
1755
+ setTimeout(() => process.exit(), CLOSE_TIMEOUT).unref();
1755
1756
  }
1756
1757
  }
1758
+ function closeServerAndExitProcess(ctx) {
1759
+ const closePromise = ctx.close();
1760
+ let timeout;
1761
+ const timeoutPromise = new Promise((resolve, reject) => {
1762
+ timeout = setTimeout(() => reject(new Error(`close timed out after ${CLOSE_TIMEOUT}ms`)), CLOSE_TIMEOUT);
1763
+ });
1764
+ Promise.race([closePromise, timeoutPromise]).then(() => {
1765
+ clearTimeout(timeout);
1766
+ process.exit(0);
1767
+ }, (err) => {
1768
+ clearTimeout(timeout);
1769
+ console.error("error during close", err);
1770
+ process.exit(1);
1771
+ });
1772
+ }
1757
1773
  function registerConsoleShortcuts(ctx) {
1758
1774
  require$$0$1.emitKeypressEvents(process.stdin);
1759
1775
  process.stdin.setRawMode(true);
1760
1776
  process.stdin.on("keypress", (str, key) => {
1761
- if (str === "" || str === "" || key && key.ctrl && key.name === "c")
1762
- process.exit();
1777
+ if (str === "" || str === "" || key && key.ctrl && key.name === "c") {
1778
+ closeServerAndExitProcess(ctx);
1779
+ return;
1780
+ }
1763
1781
  if (ctx.runningPromise)
1764
1782
  return;
1765
1783
  if (ctx.isFirstRun)
1766
- process.exit();
1784
+ closeServerAndExitProcess(ctx);
1767
1785
  });
1768
1786
  }
@@ -1,5 +1,5 @@
1
1
  import { fileURLToPath } from 'url';
2
- import { k as resolve } from './index-80671389.js';
2
+ import { k as resolve } from './index-090545ef.js';
3
3
 
4
4
  const distDir = resolve(fileURLToPath(import.meta.url), "../../dist");
5
5
  const defaultInclude = ["**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"];
@@ -1,5 +1,5 @@
1
1
  import { existsSync, promises } from 'fs';
2
- import { o as notNullish, c, r as relative } from './index-80671389.js';
2
+ import { o as notNullish, c, r as relative } from './index-090545ef.js';
3
3
 
4
4
  function Diff() {}
5
5
  Diff.prototype = {
package/dist/entry.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import fs, { promises } from 'fs';
2
- import { f as equals, h as iterableEquality, j as subsetEquality, k as isA, J as JestChaiExpect, l as clearContext, m as defaultSuite, n as setHooks, o as getHooks, p as context, s as setState, q as getFn, b as getState, e as vi } from './vi-85b65e90.js';
2
+ import { f as equals, h as iterableEquality, j as subsetEquality, k as isA, J as JestChaiExpect, l as clearContext, m as defaultSuite, n as setHooks, o as getHooks, p as context, s as setState, q as getFn, b as getState, e as vi } from './vi-092f86e3.js';
3
3
  import { Console } from 'console';
4
4
  import { Writable } from 'stream';
5
5
  import { importModule } from 'local-pkg';
6
6
  import chai$1, { expect, util } from 'chai';
7
7
  import { a as commonjsRequire, c as commonjsGlobal } from './_commonjsHelpers-c9e3b764.js';
8
- import { q as index, s as slash, u as getNames, c as c$1, t as toArray, r as relative, v as partitionSuiteChildren, w as hasTests, h as hasFailed } from './index-80671389.js';
8
+ import { u as index, s as slash, v as getNames, c as c$1, t as toArray, r as relative, w as partitionSuiteChildren, x as hasTests, h as hasFailed } from './index-090545ef.js';
9
9
  import { r as rpc } from './rpc-8c7cc374.js';
10
- import { l as getOriginalPos, m as posToNumber, n as parseStack, u as unifiedDiff } from './diff-d87307c6.js';
10
+ import { l as getOriginalPos, m as posToNumber, n as parseStack, u as unifiedDiff } from './diff-a295cb37.js';
11
11
  import { performance } from 'perf_hooks';
12
12
  import { createHash } from 'crypto';
13
13
  import { format as format$1 } from 'util';
@@ -3532,7 +3532,7 @@ async function setupGlobalEnv(config) {
3532
3532
  setupConsoleLogSpy();
3533
3533
  await setupChai();
3534
3534
  if (config.global)
3535
- (await import('./global-fc93e939.js')).registerApiGlobally();
3535
+ (await import('./global-8f03a13e.js')).registerApiGlobally();
3536
3536
  }
3537
3537
  function setupConsoleLogSpy() {
3538
3538
  const stdout = new Writable({
@@ -3663,28 +3663,32 @@ async function collectTests(paths, config) {
3663
3663
  process.stdout.write("\0");
3664
3664
  }
3665
3665
  calculateHash(file);
3666
+ interpretTaskModes(file, config.testNamePattern);
3666
3667
  files.push(file);
3667
3668
  }
3668
- interpretTaskModes(files, config.testNamePattern);
3669
3669
  return files;
3670
3670
  }
3671
- function interpretTaskModes(tasks, namePattern) {
3672
- if (tasks.some((t) => t.mode === "only")) {
3673
- tasks.forEach((t) => {
3674
- if (t.mode === "run")
3671
+ function interpretTaskModes(suite, namePattern, onlyMode) {
3672
+ if (onlyMode === void 0)
3673
+ onlyMode = someTasksAreOnly(suite);
3674
+ suite.tasks.forEach((t) => {
3675
+ if (onlyMode) {
3676
+ if (t.type === "suite" && someTasksAreOnly(t)) {
3677
+ if (t.mode === "only")
3678
+ t.mode = "run";
3679
+ interpretTaskModes(t, namePattern, onlyMode);
3680
+ } else if (t.mode === "run") {
3675
3681
  t.mode = "skip";
3676
- else if (t.mode === "only")
3682
+ } else if (t.mode === "only") {
3677
3683
  t.mode = "run";
3678
- });
3679
- }
3680
- tasks.forEach((t) => {
3684
+ }
3685
+ }
3681
3686
  if (t.type === "test") {
3682
3687
  if (namePattern && !t.name.match(namePattern))
3683
3688
  t.mode = "skip";
3684
3689
  } else if (t.type === "suite") {
3685
3690
  if (t.mode === "skip")
3686
- t.tasks.forEach((c) => c.mode === "run" && (c.mode = "skip"));
3687
- interpretTaskModes(t.tasks, namePattern);
3691
+ skipAllTasks(t);
3688
3692
  if (t.mode === "run") {
3689
3693
  if (t.tasks.every((i) => i.mode !== "run"))
3690
3694
  t.mode = "skip";
@@ -3692,6 +3696,18 @@ function interpretTaskModes(tasks, namePattern) {
3692
3696
  }
3693
3697
  });
3694
3698
  }
3699
+ function someTasksAreOnly(suite) {
3700
+ return suite.tasks.some((t) => t.mode === "only" || t.type === "suite" && someTasksAreOnly(t));
3701
+ }
3702
+ function skipAllTasks(suite) {
3703
+ suite.tasks.forEach((t) => {
3704
+ if (t.mode === "run") {
3705
+ t.mode = "skip";
3706
+ if (t.type === "suite")
3707
+ skipAllTasks(t);
3708
+ }
3709
+ });
3710
+ }
3695
3711
  function calculateHash(parent) {
3696
3712
  parent.tasks.forEach((t, idx) => {
3697
3713
  t.id = `${parent.id}_${idx}`;
@@ -1,11 +1,11 @@
1
- import { g as globalApis } from './constants-56bfb5ab.js';
2
- import { i as index } from './index-be3cc31e.js';
1
+ import { g as globalApis } from './constants-22bbd600.js';
2
+ import { i as index } from './index-31a38185.js';
3
3
  import 'url';
4
- import './index-80671389.js';
4
+ import './index-090545ef.js';
5
5
  import 'tty';
6
6
  import 'local-pkg';
7
7
  import 'path';
8
- import './vi-85b65e90.js';
8
+ import './vi-092f86e3.js';
9
9
  import './_commonjsHelpers-c9e3b764.js';
10
10
  import './jest-mock-4a754991.js';
11
11
  import 'chai';
@@ -365,4 +365,4 @@ function toFilePath(id, root) {
365
365
  return isWindows && absolute.startsWith("/") ? fileURLToPath(pathToFileURL(absolute.slice(1)).href) : absolute;
366
366
  }
367
367
 
368
- export { isAbsolute as a, basename as b, c, dirname as d, ensurePackageInstalled as e, getSuites as f, getFullName as g, hasFailed as h, isObject as i, getTests as j, resolve as k, deepMerge as l, toFilePath as m, noop as n, notNullish as o, mergeSlashes as p, index as q, relative as r, slash as s, toArray as t, getNames as u, partitionSuiteChildren as v, hasTests as w, isWindows as x, getTasks as y };
368
+ export { isAbsolute as a, basename as b, c, dirname as d, ensurePackageInstalled as e, getSuites as f, getFullName as g, hasFailed as h, isObject as i, getTests as j, resolve as k, deepMerge as l, toFilePath as m, noop as n, notNullish as o, mergeSlashes as p, join as q, relative as r, slash as s, toArray as t, index as u, getNames as v, partitionSuiteChildren as w, hasTests as x, isWindows as y, getTasks as z };
@@ -1,4 +1,4 @@
1
- import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, b as getState, s as setState, c as suite, t as test, d as describe, i as it, v as vitest, e as vi } from './vi-85b65e90.js';
1
+ import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, b as getState, s as setState, c as suite, t as test, d as describe, i as it, v as vitest, e as vi } from './vi-092f86e3.js';
2
2
  import chai, { assert, should } from 'chai';
3
3
  import { s as spies, a as spyOn, f as fn } from './jest-mock-4a754991.js';
4
4
 
@@ -1,4 +1,4 @@
1
- import { c, s as slash$1, a as isAbsolute, r as relative, d as dirname, b as basename, g as getFullName, h as hasFailed, f as getSuites, j as getTests, t as toArray, k as resolve, l as deepMerge, m as toFilePath, n as noop$1 } from './index-80671389.js';
1
+ import { c, s as slash$1, a as isAbsolute, r as relative, d as dirname, b as basename, g as getFullName, h as hasFailed, f as getSuites, j as getTests, t as toArray, k as resolve, l as deepMerge, m as toFilePath, n as noop$1 } from './index-090545ef.js';
2
2
  import { createServer, mergeConfig } from 'vite';
3
3
  import path$a from 'path';
4
4
  import process$1 from 'process';
@@ -7,10 +7,10 @@ import require$$0 from 'os';
7
7
  import require$$0$1 from 'util';
8
8
  import require$$0$2 from 'stream';
9
9
  import require$$2 from 'events';
10
- import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-56bfb5ab.js';
10
+ import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-22bbd600.js';
11
11
  import MagicString from './magic-string.es-94000aea.js';
12
12
  import { performance } from 'perf_hooks';
13
- import { F as F_POINTER, a as F_DOWN, s as stripAnsi, b as F_LONG_DASH, c as F_DOWN_RIGHT, d as F_DOT, e as F_CHECK, f as F_CROSS, g as F_RIGHT, p as printError, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as cliTruncate } from './diff-d87307c6.js';
13
+ import { F as F_POINTER, a as F_DOWN, s as stripAnsi, b as F_LONG_DASH, c as F_DOWN_RIGHT, d as F_DOT, e as F_CHECK, f as F_CROSS, g as F_RIGHT, p as printError, h as stringWidth, i as ansiStyles, j as sliceAnsi, k as cliTruncate } from './diff-a295cb37.js';
14
14
  import { o as onetime, s as signalExit } from './index-648e7ab2.js';
15
15
  import { createRequire } from 'module';
16
16
  import { pathToFileURL } from 'url';
@@ -7873,7 +7873,7 @@ function resolveC8Options(options, root) {
7873
7873
  }
7874
7874
  async function cleanCoverage(options, clean = true) {
7875
7875
  if (clean && existsSync(options.reportsDirectory))
7876
- await promises.rmdir(options.reportsDirectory, { recursive: true });
7876
+ await promises.rm(options.reportsDirectory, { recursive: true, force: true });
7877
7877
  if (!existsSync(options.tempDirectory))
7878
7878
  await promises.mkdir(options.tempDirectory, { recursive: true });
7879
7879
  }
@@ -7881,13 +7881,11 @@ const require2 = createRequire(import.meta.url);
7881
7881
  async function reportCoverage(ctx) {
7882
7882
  const createReport = require2("c8/lib/report");
7883
7883
  const report = createReport(ctx.config.coverage);
7884
- await report.getCoverageMapFromAllCoverageFiles();
7885
7884
  Array.from(ctx.visitedFilesMap.entries()).filter((i) => !i[0].includes("/node_modules/")).forEach(([file, map]) => {
7886
7885
  const url = pathToFileURL(file).href;
7886
+ const sources = map.sources.length ? map.sources.map((i) => pathToFileURL(i).href) : [url];
7887
7887
  report.sourceMapCache[url] = {
7888
- data: __spreadProps$1(__spreadValues$1({}, map), {
7889
- sources: map.sources.map((i) => pathToFileURL(i).href) || [url]
7890
- })
7888
+ data: __spreadProps$1(__spreadValues$1({}, map), { sources })
7891
7889
  };
7892
7890
  });
7893
7891
  await report.run();
@@ -8004,10 +8002,24 @@ async function _transformRequest(ctx, id) {
8004
8002
  if (result)
8005
8003
  result = await ctx.server.ssrTransform(result.code, result.map, id);
8006
8004
  }
8005
+ if (result)
8006
+ withInlineSourcemap(result);
8007
8007
  if ((result == null ? void 0 : result.map) && process.env.NODE_V8_COVERAGE)
8008
8008
  ctx.visitedFilesMap.set(toFilePath(id, ctx.config.root), result.map);
8009
8009
  return result;
8010
8010
  }
8011
+ let SOURCEMAPPING_URL = "sourceMa";
8012
+ SOURCEMAPPING_URL += "ppingURL";
8013
+ async function withInlineSourcemap(result) {
8014
+ const { code, map } = result;
8015
+ if (code.includes(`${SOURCEMAPPING_URL}=`))
8016
+ return result;
8017
+ if (map)
8018
+ result.code = `${code}
8019
+
8020
+ //# ${SOURCEMAPPING_URL}=data:application/json;charset=utf-8;base64,${Buffer.from(JSON.stringify(map), "utf-8").toString("base64")}`;
8021
+ return result;
8022
+ }
8011
8023
 
8012
8024
  function createPool(ctx) {
8013
8025
  if (ctx.config.threads)
@@ -8289,8 +8301,17 @@ class Vitest {
8289
8301
  }
8290
8302
  async close() {
8291
8303
  var _a;
8292
- await ((_a = this.pool) == null ? void 0 : _a.close());
8293
- await this.server.close();
8304
+ if (!this.closingPromise) {
8305
+ this.closingPromise = Promise.allSettled([
8306
+ (_a = this.pool) == null ? void 0 : _a.close(),
8307
+ this.server.close()
8308
+ ].filter(Boolean)).then((results) => {
8309
+ results.filter((r) => r.status === "rejected").forEach((err) => {
8310
+ this.error("error during close", err.reason);
8311
+ });
8312
+ });
8313
+ }
8314
+ return this.closingPromise;
8294
8315
  }
8295
8316
  async report(name, ...args) {
8296
8317
  await Promise.all(this.reporters.map((r) => {
@@ -8336,7 +8357,7 @@ async function createVitest(options, viteOverrides = {}) {
8336
8357
  await ctx.setServer(options, server2);
8337
8358
  haveStarted = true;
8338
8359
  if (options.api)
8339
- (await import('./setup-b87afd31.js')).setup(ctx);
8360
+ (await import('./setup-638014f2.js')).setup(ctx);
8340
8361
  }
8341
8362
  },
8342
8363
  MocksPlugin()
package/dist/index.d.ts CHANGED
@@ -204,6 +204,7 @@ declare class Vitest {
204
204
  changedTests: Set<string>;
205
205
  visitedFilesMap: Map<string, RawSourceMap>;
206
206
  runningPromise?: Promise<void>;
207
+ closingPromise?: Promise<void>;
207
208
  isFirstRun: boolean;
208
209
  restartsCount: number;
209
210
  private _onRestartListeners;
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- export { d as describe, i as it, c as suite, t as test, e as vi, v as vitest } from './vi-85b65e90.js';
2
- export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-be3cc31e.js';
1
+ export { d as describe, i as it, c as suite, t as test, e as vi, v as vitest } from './vi-092f86e3.js';
2
+ export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach, e as expect } from './index-31a38185.js';
3
3
  export { f as fn, s as spies, a as spyOn } from './jest-mock-4a754991.js';
4
4
  export { assert, default as chai, should } from 'chai';
5
- import './index-80671389.js';
5
+ import './index-090545ef.js';
6
6
  import 'url';
7
7
  import 'tty';
8
8
  import 'local-pkg';
package/dist/node.d.ts CHANGED
@@ -440,6 +440,7 @@ declare class Vitest {
440
440
  changedTests: Set<string>;
441
441
  visitedFilesMap: Map<string, RawSourceMap>;
442
442
  runningPromise?: Promise<void>;
443
+ closingPromise?: Promise<void>;
443
444
  isFirstRun: boolean;
444
445
  restartsCount: number;
445
446
  private _onRestartListeners;
package/dist/node.js CHANGED
@@ -1,5 +1,5 @@
1
- export { c as createVitest } from './index-62869b66.js';
2
- import './index-80671389.js';
1
+ export { c as createVitest } from './index-478354a1.js';
2
+ import './index-090545ef.js';
3
3
  import 'url';
4
4
  import 'tty';
5
5
  import 'local-pkg';
@@ -11,10 +11,10 @@ import 'os';
11
11
  import 'util';
12
12
  import 'stream';
13
13
  import 'events';
14
- import './constants-56bfb5ab.js';
14
+ import './constants-22bbd600.js';
15
15
  import './magic-string.es-94000aea.js';
16
16
  import 'perf_hooks';
17
- import './diff-d87307c6.js';
17
+ import './diff-a295cb37.js';
18
18
  import './index-648e7ab2.js';
19
19
  import './_commonjsHelpers-c9e3b764.js';
20
20
  import 'assert';
@@ -9,8 +9,8 @@ import require$$2 from 'events';
9
9
  import require$$1 from 'https';
10
10
  import require$$2$1 from 'http';
11
11
  import require$$7 from 'url';
12
- import { A as API_PATH } from './constants-56bfb5ab.js';
13
- import './index-80671389.js';
12
+ import { A as API_PATH } from './constants-22bbd600.js';
13
+ import './index-090545ef.js';
14
14
  import 'tty';
15
15
  import 'local-pkg';
16
16
  import 'path';
package/dist/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- export { l as deepMerge, e as ensurePackageInstalled, g as getFullName, u as getNames, f as getSuites, y as getTasks, j as getTests, h as hasFailed, w as hasTests, i as isObject, x as isWindows, p as mergeSlashes, n as noop, o as notNullish, v as partitionSuiteChildren, k as resolvePath, s as slash, t as toArray, m as toFilePath } from './index-80671389.js';
1
+ export { l as deepMerge, e as ensurePackageInstalled, g as getFullName, v as getNames, f as getSuites, z as getTasks, j as getTests, h as hasFailed, x as hasTests, i as isObject, y as isWindows, p as mergeSlashes, n as noop, o as notNullish, w as partitionSuiteChildren, k as resolvePath, s as slash, t as toArray, m as toFilePath } from './index-090545ef.js';
2
2
  import 'url';
3
3
  import 'tty';
4
4
  import 'local-pkg';
@@ -1,4 +1,4 @@
1
- import { n as noop, i as isObject } from './index-80671389.js';
1
+ import { n as noop, i as isObject } from './index-090545ef.js';
2
2
  import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-c9e3b764.js';
3
3
  import { a as spyOn, f as fn, s as spies } from './jest-mock-4a754991.js';
4
4
 
package/dist/worker.js CHANGED
@@ -1,6 +1,6 @@
1
- import { k as resolve, d as dirname$2, b as basename$2, p as mergeSlashes, s as slash, m as toFilePath } from './index-80671389.js';
1
+ import { d as dirname$2, b as basename$2, k as resolve, p as mergeSlashes, q as join$2, s as slash, m as toFilePath } from './index-090545ef.js';
2
2
  import { c as createBirpc } from './index-e909c175.js';
3
- import { c as distDir } from './constants-56bfb5ab.js';
3
+ import { c as distDir } from './constants-22bbd600.js';
4
4
  import { builtinModules, createRequire } from 'module';
5
5
  import { pathToFileURL, fileURLToPath as fileURLToPath$2, URL as URL$1 } from 'url';
6
6
  import vm from 'vm';
@@ -9218,13 +9218,15 @@ var __spreadValues = (a, b) => {
9218
9218
  };
9219
9219
  function resolveMockPath(mockPath, root, nmName) {
9220
9220
  if (nmName) {
9221
- const mockFolder = resolve(root, "__mocks__");
9221
+ const mockDirname = dirname$2(nmName);
9222
+ const baseFilename = basename$2(nmName);
9223
+ const mockFolder = resolve(root, "__mocks__", mockDirname);
9222
9224
  if (!existsSync(mockFolder))
9223
9225
  return null;
9224
9226
  const files = readdirSync(mockFolder);
9225
9227
  for (const file of files) {
9226
9228
  const [basename2] = file.split(".");
9227
- if (basename2 === nmName)
9229
+ if (basename2 === baseFilename)
9228
9230
  return resolve(mockFolder, file).replace(root, "");
9229
9231
  }
9230
9232
  return null;
@@ -9306,6 +9308,11 @@ function createMocker(root, mockMap) {
9306
9308
  s.mockClear();
9307
9309
  });
9308
9310
  }
9311
+ function resolveDependency(dep) {
9312
+ if (dep.startsWith("/node_modules/"))
9313
+ return mergeSlashes(`/@fs/${join$2(root, dep)}`);
9314
+ return dep;
9315
+ }
9309
9316
  return {
9310
9317
  mockPath,
9311
9318
  unmockPath,
@@ -9313,7 +9320,8 @@ function createMocker(root, mockMap) {
9313
9320
  getActualPath,
9314
9321
  mockObject,
9315
9322
  getSuiteFilepath,
9316
- resolveMockPath
9323
+ resolveMockPath,
9324
+ resolveDependency
9317
9325
  };
9318
9326
  }
9319
9327
 
@@ -9374,7 +9382,8 @@ async function executeInViteNode(options) {
9374
9382
  mockPath,
9375
9383
  clearMocks,
9376
9384
  unmockPath,
9377
- resolveMockPath
9385
+ resolveMockPath,
9386
+ resolveDependency
9378
9387
  } = createMocker(root, mockMap);
9379
9388
  const result = [];
9380
9389
  for (const file of files)
@@ -9397,7 +9406,7 @@ async function executeInViteNode(options) {
9397
9406
  var _a;
9398
9407
  if (canMock) {
9399
9408
  const mocks2 = mockMap[suite || ""] || {};
9400
- const mock = mocks2[dep];
9409
+ const mock = mocks2[resolveDependency(dep)];
9401
9410
  if (typeof mock === "function")
9402
9411
  return callFunctionMock(dep, mock);
9403
9412
  if (typeof mock === "string")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest",
3
- "version": "0.0.118",
3
+ "version": "0.0.119",
4
4
  "description": "A blazing fast unit test framework powered by Vite",
5
5
  "keywords": [
6
6
  "vite",