vitest 0.0.104 → 0.0.108

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/LICENSE.md CHANGED
@@ -1147,6 +1147,35 @@ Repository: unjs/mlly
1147
1147
 
1148
1148
  ---------------------------------------
1149
1149
 
1150
+ ## mockdate
1151
+ License: MIT
1152
+ By: Bob Lauer
1153
+ Repository: https://github.com/boblauer/MockDate.git
1154
+
1155
+ > The MIT License (MIT)
1156
+ >
1157
+ > Copyright (c) 2014 Bob Lauer
1158
+ >
1159
+ > Permission is hereby granted, free of charge, to any person obtaining a copy
1160
+ > of this software and associated documentation files (the "Software"), to deal
1161
+ > in the Software without restriction, including without limitation the rights
1162
+ > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1163
+ > copies of the Software, and to permit persons to whom the Software is
1164
+ > furnished to do so, subject to the following conditions:
1165
+ >
1166
+ > The above copyright notice and this permission notice shall be included in all
1167
+ > copies or substantial portions of the Software.
1168
+ >
1169
+ > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1170
+ > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1171
+ > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1172
+ > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1173
+ > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1174
+ > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1175
+ > SOFTWARE.
1176
+
1177
+ ---------------------------------------
1178
+
1150
1179
  ## nanoid
1151
1180
  License: MIT
1152
1181
  By: Andrey Sitnik
@@ -1,7 +1,11 @@
1
1
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2
2
 
3
+ function getDefaultExportFromCjs (x) {
4
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5
+ }
6
+
3
7
  function commonjsRequire (path) {
4
8
  throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
5
9
  }
6
10
 
7
- export { commonjsRequire as a, commonjsGlobal as c };
11
+ export { commonjsRequire as a, commonjsGlobal as c, getDefaultExportFromCjs as g };
package/dist/cli.js CHANGED
@@ -1,24 +1,22 @@
1
1
  import require$$0 from 'readline';
2
2
  import { EventEmitter } from 'events';
3
- import { e as ensurePackageInstalled } from './utils-49e5008c.js';
4
- import { c as createVitest } from './index-40564dba.js';
3
+ import { e as ensurePackageInstalled } from './utils-d97bd6d9.js';
4
+ import { c as createVitest } from './index-a7df3e65.js';
5
5
  import 'tty';
6
6
  import 'local-pkg';
7
7
  import 'path';
8
- import 'chai';
9
- import 'tinyspy';
10
8
  import 'vite';
11
9
  import 'process';
12
10
  import 'fs';
13
11
  import 'os';
14
12
  import 'util';
15
13
  import 'stream';
16
- import './constants-c4dc2ff5.js';
14
+ import './constants-e762cbc5.js';
17
15
  import 'url';
18
16
  import 'perf_hooks';
19
- import './error-796962c6.js';
20
- import './index-825cb54c.js';
21
- import './_commonjsHelpers-bdec4bbd.js';
17
+ import './diff-46ee5d7d.js';
18
+ import './index-61c8686f.js';
19
+ import './_commonjsHelpers-c9e3b764.js';
22
20
  import 'assert';
23
21
  import 'worker_threads';
24
22
  import 'tinypool';
@@ -636,10 +634,10 @@ class CAC extends EventEmitter {
636
634
 
637
635
  const cac = (name = "") => new CAC(name);
638
636
 
639
- var version = "0.0.104";
637
+ var version = "0.0.108";
640
638
 
641
639
  const cli = cac("vitest");
642
- 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 Vitest UI").option("--api", "listen to port and serve API").option("--threads", "enabled threads", { default: true }).option("--silent", "silent").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();
640
+ 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 Vitest UI").option("--api", "listen to port and serve API").option("--threads", "enabled threads", { default: true }).option("--silent", "silent").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();
643
641
  cli.command("run [...filters]").action(run);
644
642
  cli.command("watch [...filters]").action(dev);
645
643
  cli.command("dev [...filters]").action(dev);
@@ -1,9 +1,9 @@
1
1
  import { fileURLToPath } from 'url';
2
- import { m as resolve } from './utils-49e5008c.js';
2
+ import { h as resolve } from './utils-d97bd6d9.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}"];
6
- const defaultExclude = ["node_modules", "dist", ".idea", ".git", ".cache"];
6
+ const defaultExclude = ["**/node_modules/**", "**/dist/**", "**/.{idea,git,cache,output,temp}/**"];
7
7
  const defaultPort = 51204;
8
8
  const API_PATH = "/__vitest_api__";
9
9
  const configFiles = [
@@ -1,6 +1,5 @@
1
1
  import { existsSync, promises } from 'fs';
2
- import { format } from 'util';
3
- import { p as notNullish, c, r as relative } from './utils-49e5008c.js';
2
+ import { k as notNullish, c, r as relative } from './utils-d97bd6d9.js';
4
3
 
5
4
  function Diff() {}
6
5
  Diff.prototype = {
@@ -4564,7 +4563,7 @@ async function getSourcePos(ctx, nearest) {
4564
4563
  return pos;
4565
4564
  }
4566
4565
  function displayDiff(actual, expected) {
4567
- console.error(c.gray(unifiedDiff(stringify(actual), stringify(expected))));
4566
+ console.error(c.gray(unifiedDiff(actual, expected)) + "\n");
4568
4567
  }
4569
4568
  function printErrorMessage(error) {
4570
4569
  const errorName = error.name || error.nameStr || "Unknown Error";
@@ -4648,9 +4647,6 @@ function generateCodeFrame(source, indent = 0, start = 0, end, range = 2) {
4648
4647
  res = res.map((line) => " ".repeat(indent) + line);
4649
4648
  return res.join("\n");
4650
4649
  }
4651
- function stringify(obj) {
4652
- return format(obj);
4653
- }
4654
4650
  const stackFnCallRE = /at (.*) \((.+):(\d+):(\d+)\)$/;
4655
4651
  const stackBarePathRE = /at ?(.*) (.+):(\d+):(\d+)$/;
4656
4652
  function parseStack(stack) {
@@ -4675,64 +4671,66 @@ function parseStack(stack) {
4675
4671
  function unifiedDiff(actual, expected) {
4676
4672
  if (actual === expected)
4677
4673
  return "";
4678
- const diffLimit = 10;
4679
4674
  const indent = " ";
4680
- let expectedLinesCount = 0;
4681
- let actualLinesCount = 0;
4675
+ const diffLimit = 15;
4676
+ const counts = {
4677
+ "+": 0,
4678
+ "-": 0
4679
+ };
4680
+ const expectedLinesCount = 0;
4681
+ const actualLinesCount = 0;
4682
+ let previousState = null;
4683
+ let previousCount = 0;
4682
4684
  function preprocess(line) {
4683
- if (line[0] === "+") {
4684
- if (expectedLinesCount >= diffLimit)
4685
+ if (!line || line.match(/\\ No newline/))
4686
+ return;
4687
+ const char = line[0];
4688
+ if ("-+".includes(char)) {
4689
+ if (previousState !== char) {
4690
+ previousState = char;
4691
+ previousCount = 0;
4692
+ }
4693
+ previousCount++;
4694
+ counts[char]++;
4695
+ if (previousCount === diffLimit)
4696
+ return c.dim(char + " ...");
4697
+ else if (previousCount > diffLimit)
4685
4698
  return;
4686
- expectedLinesCount++;
4687
- return (compact) => {
4688
- if (compact)
4689
- return c.red(formatLine(line.slice(1)));
4690
- line = line[0] + " " + line.slice(1);
4691
- const isLastLine = expectedLinesCount === diffLimit;
4692
- return indent + c.red(`${formatLine(line)} ${isLastLine ? renderTruncateMessage(indent) : ""}`);
4693
- };
4694
4699
  }
4700
+ return line;
4701
+ }
4702
+ const msg = createPatch("string", expected, actual);
4703
+ const lines = msg.split("\n").slice(5).map(preprocess).filter(Boolean);
4704
+ const isCompact = counts["+"] === 1 && counts["-"] === 1 && lines.length === 2;
4705
+ let formatted = lines.map((line) => {
4695
4706
  if (line[0] === "-") {
4696
- if (actualLinesCount >= diffLimit)
4697
- return;
4698
- actualLinesCount++;
4699
- return (compact) => {
4700
- if (compact)
4701
- return c.green(formatLine(line.slice(1)));
4702
- line = line[0] + " " + line.slice(1);
4703
- const isLastLine = actualLinesCount === diffLimit;
4704
- return indent + c.green(`${formatLine(line)} ${isLastLine ? renderTruncateMessage(indent) : ""}`);
4705
- };
4707
+ line = formatLine(line.slice(1));
4708
+ if (isCompact)
4709
+ return c.green(line);
4710
+ return c.green(`- ${formatLine(line)}`);
4711
+ }
4712
+ if (line[0] === "+") {
4713
+ line = formatLine(line.slice(1));
4714
+ if (isCompact)
4715
+ return c.red(line);
4716
+ return c.red(`+ ${formatLine(line)}`);
4706
4717
  }
4707
4718
  if (line.match(/@@/))
4708
- return () => "--";
4709
- if (line.match(/\\ No newline/))
4710
- return null;
4711
- return () => indent + " " + line;
4712
- }
4713
- const msg = createPatch("string", actual, expected);
4714
- const lines = msg.split("\n").splice(5);
4715
- const cleanLines = lines.map(preprocess).filter(notBlank);
4716
- if (expectedLinesCount === 1 && actualLinesCount === 1) {
4717
- return `
4718
- ${indent}${c.green("- expected")} ${cleanLines[0](true)}
4719
- ${indent}${c.red("+ actual")} ${cleanLines[1](true)}`;
4719
+ return "--";
4720
+ return " " + line;
4721
+ });
4722
+ if (isCompact) {
4723
+ formatted = [
4724
+ `${c.green("- Expected")} ${formatted[0]}`,
4725
+ `${c.red("+ Received")} ${formatted[1]}`
4726
+ ];
4727
+ } else {
4728
+ formatted.unshift(c.green("- Expected -" + expectedLinesCount), c.red("+ Received +" + actualLinesCount), "");
4720
4729
  }
4721
- return `
4722
- ${indent}${c.green("- expected")}
4723
- ${indent}${c.red("+ actual")}
4724
-
4725
- ${cleanLines.map((l) => l()).join("\n")}`;
4730
+ return formatted.map((i) => indent + i).join("\n");
4726
4731
  }
4727
4732
  function formatLine(line) {
4728
- return cliTruncate(line, (process.stdout.columns || 80) - 1);
4729
- }
4730
- function renderTruncateMessage(indent) {
4731
- return `
4732
- ${indent}${c.dim("[...truncated]")}`;
4733
- }
4734
- function notBlank(line) {
4735
- return typeof line !== "undefined" && line !== null;
4733
+ return cliTruncate(line, (process.stdout.columns || 80) - 4);
4736
4734
  }
4737
4735
 
4738
4736
  export { F_POINTER as F, ansiStyles as a, stripAnsi as b, sliceAnsi as c, F_DOWN as d, F_LONG_DASH as e, F_DOWN_RIGHT as f, F_DOT as g, F_CHECK as h, F_CROSS as i, cliTruncate as j, F_RIGHT as k, printError as p, stringWidth as s, unifiedDiff as u };
package/dist/entry.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import fs, { promises } from 'fs';
2
- import { u as index, g as getNames, c as c$1, t as toArray, k as basename, w as interpretOnlyMode, x as partitionSuiteChildren, y as hasTests, o as hasFailed, z as clearModuleMocks, b as vi } from './utils-49e5008c.js';
2
+ import { c as clearContext, e as defaultSuite, f as setHooks, h as getHooks, j as context, k as getFn, b as vi } from './vi-9754296d.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
- import { a as commonjsRequire, c as commonjsGlobal } from './_commonjsHelpers-bdec4bbd.js';
7
+ import { a as commonjsRequire, c as commonjsGlobal } from './_commonjsHelpers-c9e3b764.js';
8
+ import { l as index, g as getNames, c as c$1, t as toArray, b as basename, o as interpretOnlyMode, p as partitionSuiteChildren, q as hasTests, j as hasFailed } from './utils-d97bd6d9.js';
8
9
  import { r as rpc, s as send } from './rpc-7de86f29.js';
9
- import { u as unifiedDiff } from './error-796962c6.js';
10
+ import { u as unifiedDiff } from './diff-46ee5d7d.js';
10
11
  import { performance } from 'perf_hooks';
11
- import { c as clearContext, b as defaultSuite, e as setHooks, f as getHooks, h as context, j as getFn } from './suite-8d666d5a.js';
12
- import { n as nanoid } from './index-9e71c815.js';
12
+ import { n as nanoid } from './jest-mock-8498c46d.js';
13
13
  import { format as format$1 } from 'util';
14
14
  import 'tty';
15
15
  import 'path';
@@ -3169,14 +3169,12 @@ const stringify = (object, maxDepth = 10) => {
3169
3169
  try {
3170
3170
  result = format_1(object, {
3171
3171
  maxDepth,
3172
- min: true,
3173
3172
  plugins: PLUGINS
3174
3173
  });
3175
3174
  } catch {
3176
3175
  result = format_1(object, {
3177
3176
  callToJSON: false,
3178
3177
  maxDepth,
3179
- min: true,
3180
3178
  plugins: PLUGINS
3181
3179
  });
3182
3180
  }
@@ -3908,7 +3906,7 @@ async function setupGlobalEnv(config) {
3908
3906
  setupConsoleLogSpy();
3909
3907
  await setupChai();
3910
3908
  if (config.global)
3911
- (await import('./global-166f6789.js')).registerApiGlobally();
3909
+ (await import('./global-e0d00047.js')).registerApiGlobally();
3912
3910
  }
3913
3911
  function setupConsoleLogSpy() {
3914
3912
  const stdout = new Writable({
@@ -3958,7 +3956,7 @@ async function runSetupFiles(config) {
3958
3956
  }
3959
3957
 
3960
3958
  function serializeError(val) {
3961
- if (!val)
3959
+ if (!val || typeof val === "string")
3962
3960
  return val;
3963
3961
  if (typeof val === "function")
3964
3962
  return `Function<${val.name}>`;
@@ -3982,6 +3980,10 @@ function processError(err) {
3982
3980
  err.stackStr = String(err.stack);
3983
3981
  if (err.name)
3984
3982
  err.nameStr = String(err.name);
3983
+ if (typeof err.expected !== "string")
3984
+ err.expected = stringify(err.expected);
3985
+ if (typeof err.actual !== "string")
3986
+ err.actual = stringify(err.actual);
3985
3987
  return serializeError(err);
3986
3988
  }
3987
3989
 
@@ -4136,6 +4138,15 @@ async function startTests(paths, config) {
4136
4138
  await runSuites(files);
4137
4139
  await getSnapshotClient().saveSnap();
4138
4140
  }
4141
+ function clearModuleMocks() {
4142
+ const { clearMocks, mockReset, restoreMocks } = process.__vitest_worker__.config;
4143
+ if (restoreMocks)
4144
+ vi.restoreAllMocks();
4145
+ else if (mockReset)
4146
+ vi.resetAllMocks();
4147
+ else if (clearMocks)
4148
+ vi.clearAllMocks();
4149
+ }
4139
4150
 
4140
4151
  async function run(files, config) {
4141
4152
  var _a;
@@ -0,0 +1,20 @@
1
+ import { g as globalApis } from './constants-e762cbc5.js';
2
+ import { i as index } from './index-0961cf69.js';
3
+ import 'url';
4
+ import './utils-d97bd6d9.js';
5
+ import 'tty';
6
+ import 'local-pkg';
7
+ import 'path';
8
+ import './vi-9754296d.js';
9
+ import './jest-mock-8498c46d.js';
10
+ import 'chai';
11
+ import 'tinyspy';
12
+ import './_commonjsHelpers-c9e3b764.js';
13
+
14
+ function registerApiGlobally() {
15
+ globalApis.forEach((api) => {
16
+ globalThis[api] = index[api];
17
+ });
18
+ }
19
+
20
+ export { registerApiGlobally };
@@ -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 } from './suite-8d666d5a.js';
1
+ import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it, v as vitest, b as vi } from './vi-9754296d.js';
2
2
  import chai, { assert, should, expect } from 'chai';
3
- import { s as spies, a as spyOn, f as fn, v as vitest, b as vi } from './utils-49e5008c.js';
3
+ import { s as spies, a as spyOn, f as fn } from './jest-mock-8498c46d.js';
4
4
 
5
5
  const beforeAll = (fn, timeout) => getCurrentSuite().on("beforeAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
6
6
  const afterAll = (fn, timeout) => getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout()));
@@ -1,4 +1,4 @@
1
- import { c as commonjsGlobal } from './_commonjsHelpers-bdec4bbd.js';
1
+ import { c as commonjsGlobal } from './_commonjsHelpers-c9e3b764.js';
2
2
  import assert$1 from 'assert';
3
3
  import require$$2 from 'events';
4
4
 
@@ -2,8 +2,8 @@ import path$5 from 'path';
2
2
  import fs$5 from 'fs';
3
3
  import require$$0 from 'util';
4
4
  import require$$0$1 from 'child_process';
5
- import { c as commonjsGlobal } from './_commonjsHelpers-bdec4bbd.js';
6
- import { a as signalExit, b as onetime$1 } from './index-825cb54c.js';
5
+ import { c as commonjsGlobal } from './_commonjsHelpers-c9e3b764.js';
6
+ import { a as signalExit, b as onetime$1 } from './index-61c8686f.js';
7
7
  import require$$0$2 from 'os';
8
8
  import require$$0$4 from 'buffer';
9
9
  import require$$0$3 from 'stream';
@@ -1,4 +1,4 @@
1
- import { c, g as getNames, d as slash$1, h as getTests, i as isAbsolute, r as relative, j as dirname, k as basename, l as getSuites, m as resolve, n as noop$1, t as toArray, o as hasFailed } from './utils-49e5008c.js';
1
+ import { c, g as getNames, s as slash$1, a as getTests, i as isAbsolute, r as relative, d as dirname, b as basename, f as getSuites, h as resolve, n as noop$1, t as toArray, j as hasFailed } from './utils-d97bd6d9.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-c4dc2ff5.js';
10
+ import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-e762cbc5.js';
11
11
  import { performance } from 'perf_hooks';
12
- import { s as stringWidth, a as ansiStyles, b as stripAnsi, c as sliceAnsi, F as F_POINTER, d as F_DOWN, e as F_LONG_DASH, f as F_DOWN_RIGHT, g as F_DOT, h as F_CHECK, i as F_CROSS, j as cliTruncate, k as F_RIGHT, p as printError } from './error-796962c6.js';
13
- import { o as onetime, s as signalExit } from './index-825cb54c.js';
12
+ import { s as stringWidth, a as ansiStyles, b as stripAnsi, c as sliceAnsi, F as F_POINTER, d as F_DOWN, e as F_LONG_DASH, f as F_DOWN_RIGHT, g as F_DOT, h as F_CHECK, i as F_CROSS, j as cliTruncate, k as F_RIGHT, p as printError } from './diff-46ee5d7d.js';
13
+ import { o as onetime, s as signalExit } from './index-61c8686f.js';
14
14
  import { MessageChannel } from 'worker_threads';
15
15
  import { pathToFileURL } from 'url';
16
16
  import { Tinypool } from 'tinypool';
@@ -8840,6 +8840,8 @@ function createFakePool(ctx) {
8840
8840
  function createWorkerPool(ctx) {
8841
8841
  const options = {
8842
8842
  filename: workerPath,
8843
+ isolateWorkers: true,
8844
+ concurrentTasksPerWorker: 1,
8843
8845
  useAtomics: false
8844
8846
  };
8845
8847
  if (ctx.config.maxThreads != null)
@@ -9111,7 +9113,7 @@ async function createVitest(options, viteOverrides = {}) {
9111
9113
  ctx.setServer(options, server2);
9112
9114
  haveStarted = true;
9113
9115
  if (options.api)
9114
- server2.middlewares.use((await import('./middleware-0627688d.js')).default(ctx));
9116
+ server2.middlewares.use((await import('./middleware-093a3bde.js')).default(ctx));
9115
9117
  }
9116
9118
  },
9117
9119
  MocksPlugin()
package/dist/index.d.ts CHANGED
@@ -605,6 +605,7 @@ declare function fn<TArgs extends any[] = any[], R = any>(implementation: (...ar
605
605
 
606
606
  declare class VitestUtils {
607
607
  private _timers;
608
+ private _mockedDate;
608
609
  constructor();
609
610
  useFakeTimers(): void;
610
611
  useRealTimers(): void;
@@ -613,6 +614,9 @@ declare class VitestUtils {
613
614
  advanceTimersByTime(ms: number): void | Promise<void>;
614
615
  advanceTimersToNextTimer(): void | Promise<void>;
615
616
  getTimerCount(): number;
617
+ mockCurrentDate(date: string | number | Date): void;
618
+ restoreCurrentDate(): void;
619
+ getMockedDate(): string | number | Date | null;
616
620
  spyOn: typeof spyOn;
617
621
  fn: typeof fn;
618
622
  mock(path: string): void;
package/dist/index.js CHANGED
@@ -1,9 +1,10 @@
1
- export { d as describe, i as it, s as suite, t as test } from './suite-8d666d5a.js';
2
- export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach } from './index-145f6f09.js';
1
+ export { d as describe, i as it, s as suite, t as test, b as vi, v as vitest } from './vi-9754296d.js';
2
+ export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach } from './index-0961cf69.js';
3
3
  export { assert, default as chai, expect, should } from 'chai';
4
- export { f as fn, s as spies, a as spyOn, b as vi, v as vitest } from './utils-49e5008c.js';
5
- import './index-9e71c815.js';
4
+ export { f as fn, s as spies, a as spyOn } from './jest-mock-8498c46d.js';
5
+ import './utils-d97bd6d9.js';
6
6
  import 'tty';
7
7
  import 'local-pkg';
8
8
  import 'path';
9
+ import './_commonjsHelpers-c9e3b764.js';
9
10
  import 'tinyspy';
@@ -0,0 +1,104 @@
1
+ import { util } from 'chai';
2
+ import * as tinyspy from 'tinyspy';
3
+
4
+ let urlAlphabet =
5
+ 'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict';
6
+ let nanoid = (size = 21) => {
7
+ let id = '';
8
+ let i = size;
9
+ while (i--) {
10
+ id += urlAlphabet[(Math.random() * 64) | 0];
11
+ }
12
+ return id
13
+ };
14
+
15
+ const spies = /* @__PURE__ */ new Set();
16
+ function spyOn(obj, method, accessType) {
17
+ const dictionary = {
18
+ get: "getter",
19
+ set: "setter"
20
+ };
21
+ const objMethod = accessType ? { [dictionary[accessType]]: method } : method;
22
+ const stub = tinyspy.spyOn(obj, objMethod);
23
+ return enhanceSpy(stub);
24
+ }
25
+ function enhanceSpy(spy) {
26
+ const stub = spy;
27
+ let implementation;
28
+ const instances = [];
29
+ const mockContext = {
30
+ get calls() {
31
+ return stub.calls;
32
+ },
33
+ get instances() {
34
+ return instances;
35
+ },
36
+ get invocationCallOrder() {
37
+ return [];
38
+ },
39
+ get results() {
40
+ return stub.results.map(([callType, value]) => {
41
+ const type = callType === "error" ? "throw" : "return";
42
+ return { type, value };
43
+ });
44
+ }
45
+ };
46
+ let onceImplementations = [];
47
+ let name = "";
48
+ Object.defineProperty(stub, "name", {
49
+ get: () => name
50
+ });
51
+ stub.getMockName = () => name || "vi.fn()";
52
+ stub.mockName = (n) => {
53
+ name = n;
54
+ return stub;
55
+ };
56
+ stub.mockClear = () => {
57
+ stub.reset();
58
+ return stub;
59
+ };
60
+ stub.mockReset = () => {
61
+ stub.reset();
62
+ implementation = () => void 0;
63
+ onceImplementations = [];
64
+ return stub;
65
+ };
66
+ stub.mockRestore = () => {
67
+ stub.mockReset();
68
+ implementation = void 0;
69
+ return stub;
70
+ };
71
+ stub.getMockImplementation = () => implementation;
72
+ stub.mockImplementation = (fn2) => {
73
+ implementation = fn2;
74
+ return stub;
75
+ };
76
+ stub.mockImplementationOnce = (fn2) => {
77
+ onceImplementations.push(fn2);
78
+ return stub;
79
+ };
80
+ stub.mockReturnThis = () => stub.mockImplementation(function() {
81
+ return this;
82
+ });
83
+ stub.mockReturnValue = (val) => stub.mockImplementation(() => val);
84
+ stub.mockReturnValueOnce = (val) => stub.mockImplementationOnce(() => val);
85
+ stub.mockResolvedValue = (val) => stub.mockImplementation(() => Promise.resolve(val));
86
+ stub.mockResolvedValueOnce = (val) => stub.mockImplementationOnce(() => Promise.resolve(val));
87
+ stub.mockRejectedValue = (val) => stub.mockImplementation(() => Promise.reject(val));
88
+ stub.mockRejectedValueOnce = (val) => stub.mockImplementationOnce(() => Promise.reject(val));
89
+ util.addProperty(stub, "mock", () => mockContext);
90
+ stub.willCall(function(...args) {
91
+ instances.push(this);
92
+ const impl = onceImplementations.shift() || implementation || stub.getOriginal() || (() => {
93
+ });
94
+ return impl.apply(this, args);
95
+ });
96
+ spies.add(stub);
97
+ return stub;
98
+ }
99
+ function fn(implementation) {
100
+ return enhanceSpy(tinyspy.spyOn({ fn: implementation || (() => {
101
+ }) }, "fn"));
102
+ }
103
+
104
+ export { spyOn as a, fn as f, nanoid as n, spies as s };
@@ -1,11 +1,9 @@
1
- import { A as API_PATH } from './constants-c4dc2ff5.js';
1
+ import { A as API_PATH } from './constants-e762cbc5.js';
2
2
  import 'url';
3
- import './utils-49e5008c.js';
3
+ import './utils-d97bd6d9.js';
4
4
  import 'tty';
5
5
  import 'local-pkg';
6
6
  import 'path';
7
- import 'chai';
8
- import 'tinyspy';
9
7
 
10
8
  /*! (c) 2020 Andrea Giammarchi */
11
9
 
package/dist/node.js CHANGED
@@ -1,10 +1,8 @@
1
- export { c as createVitest } from './index-40564dba.js';
2
- import './utils-49e5008c.js';
1
+ export { c as createVitest } from './index-a7df3e65.js';
2
+ import './utils-d97bd6d9.js';
3
3
  import 'tty';
4
4
  import 'local-pkg';
5
5
  import 'path';
6
- import 'chai';
7
- import 'tinyspy';
8
6
  import 'vite';
9
7
  import 'process';
10
8
  import 'fs';
@@ -12,12 +10,12 @@ import 'os';
12
10
  import 'util';
13
11
  import 'stream';
14
12
  import 'events';
15
- import './constants-c4dc2ff5.js';
13
+ import './constants-e762cbc5.js';
16
14
  import 'url';
17
15
  import 'perf_hooks';
18
- import './error-796962c6.js';
19
- import './index-825cb54c.js';
20
- import './_commonjsHelpers-bdec4bbd.js';
16
+ import './diff-46ee5d7d.js';
17
+ import './index-61c8686f.js';
18
+ import './_commonjsHelpers-c9e3b764.js';
21
19
  import 'assert';
22
20
  import 'worker_threads';
23
21
  import 'tinypool';