vitest 0.0.105 → 0.0.106

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
@@ -1,7 +1,7 @@
1
1
  import require$$0 from 'readline';
2
2
  import { EventEmitter } from 'events';
3
- import { e as ensurePackageInstalled } from './utils-5307e690.js';
4
- import { c as createVitest } from './index-1da01554.js';
3
+ import { e as ensurePackageInstalled } from './utils-92ec89d1.js';
4
+ import { c as createVitest } from './index-8cc284f9.js';
5
5
  import 'tty';
6
6
  import 'local-pkg';
7
7
  import 'path';
@@ -13,11 +13,11 @@ import 'fs';
13
13
  import 'os';
14
14
  import 'util';
15
15
  import 'stream';
16
- import './constants-9320a46c.js';
16
+ import './constants-82dad049.js';
17
17
  import 'url';
18
18
  import 'perf_hooks';
19
- import './error-4e165107.js';
20
- import './index-4cf13e25.js';
19
+ import './error-e81aa23d.js';
20
+ import './index-84978a77.js';
21
21
  import 'assert';
22
22
  import 'worker_threads';
23
23
  import 'tinypool';
@@ -635,7 +635,7 @@ class CAC extends EventEmitter {
635
635
 
636
636
  const cac = (name = "") => new CAC(name);
637
637
 
638
- var version = "0.0.105";
638
+ var version = "0.0.106";
639
639
 
640
640
  const cli = cac("vitest");
641
641
  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();
@@ -1,9 +1,9 @@
1
1
  import { fileURLToPath } from 'url';
2
- import { m as resolve } from './utils-5307e690.js';
2
+ import { m as resolve } from './utils-92ec89d1.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 = [
package/dist/entry.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import fs, { promises } from 'fs';
2
- import { w as commonjsRequire, q as commonjsGlobal, x as index, g as getNames, c as c$1, t as toArray, k as basename, y as interpretOnlyMode, z as partitionSuiteChildren, A as hasTests, o as hasFailed, B as clearModuleMocks, b as vi } from './utils-5307e690.js';
2
+ import { w as commonjsRequire, q as commonjsGlobal, x as index, g as getNames, c as c$1, t as toArray, k as basename, y as interpretOnlyMode, z as partitionSuiteChildren, A as hasTests, o as hasFailed, B as clearModuleMocks, b as vi } from './utils-92ec89d1.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 { r as rpc, s as send } from './rpc-7de86f29.js';
8
- import { u as unifiedDiff } from './error-4e165107.js';
8
+ import { u as unifiedDiff } from './error-e81aa23d.js';
9
9
  import { performance } from 'perf_hooks';
10
- import { c as clearContext, b as defaultSuite, e as setHooks, f as getHooks, h as context, j as getFn } from './suite-101bab76.js';
10
+ import { c as clearContext, b as defaultSuite, e as setHooks, f as getHooks, h as context, j as getFn } from './suite-ff89a82e.js';
11
11
  import { n as nanoid } from './index-9e71c815.js';
12
12
  import { format as format$1 } from 'util';
13
13
  import 'tty';
@@ -3907,7 +3907,7 @@ async function setupGlobalEnv(config) {
3907
3907
  setupConsoleLogSpy();
3908
3908
  await setupChai();
3909
3909
  if (config.global)
3910
- (await import('./global-a3634033.js')).registerApiGlobally();
3910
+ (await import('./global-0f4da031.js')).registerApiGlobally();
3911
3911
  }
3912
3912
  function setupConsoleLogSpy() {
3913
3913
  const stdout = new Writable({
@@ -1,6 +1,6 @@
1
1
  import { existsSync, promises } from 'fs';
2
2
  import { format } from 'util';
3
- import { p as notNullish, c, r as relative } from './utils-5307e690.js';
3
+ import { p as notNullish, c, r as relative } from './utils-92ec89d1.js';
4
4
 
5
5
  function Diff() {}
6
6
  Diff.prototype = {
@@ -4564,7 +4564,7 @@ async function getSourcePos(ctx, nearest) {
4564
4564
  return pos;
4565
4565
  }
4566
4566
  function displayDiff(actual, expected) {
4567
- console.error(c.gray(unifiedDiff(stringify(actual), stringify(expected))));
4567
+ console.error(c.gray(unifiedDiff(format(actual), format(expected))) + "\n");
4568
4568
  }
4569
4569
  function printErrorMessage(error) {
4570
4570
  const errorName = error.name || error.nameStr || "Unknown Error";
@@ -4648,9 +4648,6 @@ function generateCodeFrame(source, indent = 0, start = 0, end, range = 2) {
4648
4648
  res = res.map((line) => " ".repeat(indent) + line);
4649
4649
  return res.join("\n");
4650
4650
  }
4651
- function stringify(obj) {
4652
- return format(obj);
4653
- }
4654
4651
  const stackFnCallRE = /at (.*) \((.+):(\d+):(\d+)\)$/;
4655
4652
  const stackBarePathRE = /at ?(.*) (.+):(\d+):(\d+)$/;
4656
4653
  function parseStack(stack) {
@@ -4680,49 +4677,43 @@ function unifiedDiff(actual, expected) {
4680
4677
  let expectedLinesCount = 0;
4681
4678
  let actualLinesCount = 0;
4682
4679
  function preprocess(line) {
4680
+ if (!line)
4681
+ return;
4683
4682
  if (line[0] === "+") {
4684
4683
  if (expectedLinesCount >= diffLimit)
4685
4684
  return;
4686
4685
  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
- };
4686
+ line = line[0] + " " + line.slice(1);
4687
+ const isLastLine = expectedLinesCount === diffLimit;
4688
+ return indent + c.red(`${formatLine(line)} ${isLastLine ? renderTruncateMessage(indent) : ""}`);
4694
4689
  }
4695
4690
  if (line[0] === "-") {
4696
4691
  if (actualLinesCount >= diffLimit)
4697
4692
  return;
4698
4693
  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
- };
4694
+ line = line[0] + " " + line.slice(1);
4695
+ const isLastLine = actualLinesCount === diffLimit;
4696
+ return indent + c.green(`${formatLine(line)} ${isLastLine ? renderTruncateMessage(indent) : ""}`);
4706
4697
  }
4707
4698
  if (line.match(/@@/))
4708
- return () => "--";
4699
+ return "--";
4709
4700
  if (line.match(/\\ No newline/))
4710
4701
  return null;
4711
- return () => indent + " " + line;
4702
+ return indent + " " + line;
4712
4703
  }
4713
4704
  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) {
4705
+ const lines = msg.split("\n").slice(5);
4706
+ const cleanLines = lines.map(preprocess).filter(Boolean);
4707
+ if (expectedLinesCount === 1 && actualLinesCount === 1 && lines.length === 2) {
4717
4708
  return `
4718
- ${indent}${c.green("- expected")} ${cleanLines[0](true)}
4719
- ${indent}${c.red("+ actual")} ${cleanLines[1](true)}`;
4709
+ ${indent}${c.green("- expected")} ${cleanLines[0]}
4710
+ ${indent}${c.red("+ actual")} ${cleanLines[1]}`;
4720
4711
  }
4721
4712
  return `
4722
4713
  ${indent}${c.green("- expected")}
4723
4714
  ${indent}${c.red("+ actual")}
4724
4715
 
4725
- ${cleanLines.map((l) => l()).join("\n")}`;
4716
+ ${cleanLines.join("\n")}`;
4726
4717
  }
4727
4718
  function formatLine(line) {
4728
4719
  return cliTruncate(line, (process.stdout.columns || 80) - 1);
@@ -4731,8 +4722,5 @@ function renderTruncateMessage(indent) {
4731
4722
  return `
4732
4723
  ${indent}${c.dim("[...truncated]")}`;
4733
4724
  }
4734
- function notBlank(line) {
4735
- return typeof line !== "undefined" && line !== null;
4736
- }
4737
4725
 
4738
4726
  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 };
@@ -1,13 +1,13 @@
1
- import { g as globalApis } from './constants-9320a46c.js';
2
- import { i as index } from './index-a76b4291.js';
1
+ import { g as globalApis } from './constants-82dad049.js';
2
+ import { i as index } from './index-77f19d39.js';
3
3
  import 'url';
4
- import './utils-5307e690.js';
4
+ import './utils-92ec89d1.js';
5
5
  import 'tty';
6
6
  import 'local-pkg';
7
7
  import 'path';
8
8
  import 'chai';
9
9
  import 'tinyspy';
10
- import './suite-101bab76.js';
10
+ import './suite-ff89a82e.js';
11
11
  import './index-9e71c815.js';
12
12
 
13
13
  function registerApiGlobally() {
@@ -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 { q as commonjsGlobal } from './utils-5307e690.js';
6
- import { a as signalExit, b as onetime$1 } from './index-4cf13e25.js';
5
+ import { q as commonjsGlobal } from './utils-92ec89d1.js';
6
+ import { a as signalExit, b as onetime$1 } from './index-84978a77.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,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-101bab76.js';
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-ff89a82e.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-5307e690.js';
3
+ import { s as spies, a as spyOn, f as fn, v as vitest, b as vi } from './utils-92ec89d1.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 { q as commonjsGlobal } from './utils-5307e690.js';
1
+ import { q as commonjsGlobal } from './utils-92ec89d1.js';
2
2
  import assert$1 from 'assert';
3
3
  import require$$2 from 'events';
4
4
 
@@ -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-5307e690.js';
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-92ec89d1.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-9320a46c.js';
10
+ import { d as defaultInclude, a as defaultExclude, b as defaultPort, c as distDir, e as configFiles } from './constants-82dad049.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-4e165107.js';
13
- import { o as onetime, s as signalExit } from './index-4cf13e25.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 './error-e81aa23d.js';
13
+ import { o as onetime, s as signalExit } from './index-84978a77.js';
14
14
  import { MessageChannel } from 'worker_threads';
15
15
  import { pathToFileURL } from 'url';
16
16
  import { Tinypool } from 'tinypool';
@@ -9113,7 +9113,7 @@ async function createVitest(options, viteOverrides = {}) {
9113
9113
  ctx.setServer(options, server2);
9114
9114
  haveStarted = true;
9115
9115
  if (options.api)
9116
- server2.middlewares.use((await import('./middleware-c66abe08.js')).default(ctx));
9116
+ server2.middlewares.use((await import('./middleware-0c8d46aa.js')).default(ctx));
9117
9117
  }
9118
9118
  },
9119
9119
  MocksPlugin()
package/dist/index.d.ts CHANGED
@@ -605,7 +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 _systemDate;
608
+ private _mockedDate;
609
609
  constructor();
610
610
  useFakeTimers(): void;
611
611
  useRealTimers(): void;
@@ -614,9 +614,9 @@ declare class VitestUtils {
614
614
  advanceTimersByTime(ms: number): void | Promise<void>;
615
615
  advanceTimersToNextTimer(): void | Promise<void>;
616
616
  getTimerCount(): number;
617
- setSystemDate(date: string | number | Date): void;
618
- resetSystemDate(): void;
619
- getSystemDate(): string | number | Date;
617
+ mockCurrentDate(date: string | number | Date): void;
618
+ restoreCurrentDate(): void;
619
+ getMockedDate(): string | number | Date | null;
620
620
  spyOn: typeof spyOn;
621
621
  fn: typeof fn;
622
622
  mock(path: string): void;
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- export { d as describe, i as it, s as suite, t as test } from './suite-101bab76.js';
2
- export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach } from './index-a76b4291.js';
1
+ export { d as describe, i as it, s as suite, t as test } from './suite-ff89a82e.js';
2
+ export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach } from './index-77f19d39.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-5307e690.js';
4
+ export { f as fn, s as spies, a as spyOn, b as vi, v as vitest } from './utils-92ec89d1.js';
5
5
  import './index-9e71c815.js';
6
6
  import 'tty';
7
7
  import 'local-pkg';
@@ -1,6 +1,6 @@
1
- import { A as API_PATH } from './constants-9320a46c.js';
1
+ import { A as API_PATH } from './constants-82dad049.js';
2
2
  import 'url';
3
- import './utils-5307e690.js';
3
+ import './utils-92ec89d1.js';
4
4
  import 'tty';
5
5
  import 'local-pkg';
6
6
  import 'path';
package/dist/node.js CHANGED
@@ -1,5 +1,5 @@
1
- export { c as createVitest } from './index-1da01554.js';
2
- import './utils-5307e690.js';
1
+ export { c as createVitest } from './index-8cc284f9.js';
2
+ import './utils-92ec89d1.js';
3
3
  import 'tty';
4
4
  import 'local-pkg';
5
5
  import 'path';
@@ -12,11 +12,11 @@ import 'os';
12
12
  import 'util';
13
13
  import 'stream';
14
14
  import 'events';
15
- import './constants-9320a46c.js';
15
+ import './constants-82dad049.js';
16
16
  import 'url';
17
17
  import 'perf_hooks';
18
- import './error-4e165107.js';
19
- import './index-4cf13e25.js';
18
+ import './error-e81aa23d.js';
19
+ import './index-84978a77.js';
20
20
  import 'assert';
21
21
  import 'worker_threads';
22
22
  import 'tinypool';
@@ -1,5 +1,5 @@
1
1
  import { n as nanoid } from './index-9e71c815.js';
2
- import { n as noop } from './utils-5307e690.js';
2
+ import { n as noop } from './utils-92ec89d1.js';
3
3
 
4
4
  var __defProp = Object.defineProperty;
5
5
  var __defProps = Object.defineProperties;
@@ -635,7 +635,7 @@ class VitestUtils {
635
635
  this.spyOn = spyOn;
636
636
  this.fn = fn;
637
637
  this._timers = new FakeTimers();
638
- this._systemDate = null;
638
+ this._mockedDate = null;
639
639
  }
640
640
  useFakeTimers() {
641
641
  return this._timers.useFakeTimers();
@@ -658,16 +658,16 @@ class VitestUtils {
658
658
  getTimerCount() {
659
659
  return this._timers.getTimerCount();
660
660
  }
661
- setSystemDate(date) {
662
- this._systemDate = date;
661
+ mockCurrentDate(date) {
662
+ this._mockedDate = date;
663
663
  mockdate.set(date);
664
664
  }
665
- resetSystemDate() {
666
- this._systemDate = null;
665
+ restoreCurrentDate() {
666
+ this._mockedDate = null;
667
667
  mockdate.reset();
668
668
  }
669
- getSystemDate() {
670
- return this._systemDate || Date.now();
669
+ getMockedDate() {
670
+ return this._mockedDate;
671
671
  }
672
672
  mock(path) {
673
673
  }
@@ -796,7 +796,7 @@ async function ensurePackageInstalled(dependency, promptInstall = !process.env.C
796
796
  message: c.reset(`Do you want to install ${c.green(dependency)}?`)
797
797
  });
798
798
  if (install) {
799
- await (await import('./index-5d224425.js')).installPackage(dependency, { dev: true });
799
+ await (await import('./index-1ede1cc5.js')).installPackage(dependency, { dev: true });
800
800
  return true;
801
801
  }
802
802
  return false;
package/dist/utils.js CHANGED
@@ -1,4 +1,4 @@
1
- export { B as clearModuleMocks, e as ensurePackageInstalled, g as getNames, l as getSuites, C as getTasks, h as getTests, o as hasFailed, A as hasTests, y as interpretOnlyMode, u as mergeSlashes, n as noop, p as notNullish, z as partitionSuiteChildren, m as resolvePath, d as slash, t as toArray } from './utils-5307e690.js';
1
+ export { B as clearModuleMocks, e as ensurePackageInstalled, g as getNames, l as getSuites, C as getTasks, h as getTests, o as hasFailed, A as hasTests, y as interpretOnlyMode, u as mergeSlashes, n as noop, p as notNullish, z as partitionSuiteChildren, m as resolvePath, d as slash, t as toArray } from './utils-92ec89d1.js';
2
2
  import 'local-pkg';
3
3
  import 'tty';
4
4
  import 'path';
package/dist/worker.js CHANGED
@@ -1,6 +1,6 @@
1
- import { d as slash, m as resolve, j as dirname$2, a as spyOn, u as mergeSlashes, s as spies, k as basename$2 } from './utils-5307e690.js';
1
+ import { d as slash, m as resolve, j as dirname$2, a as spyOn, u as mergeSlashes, s as spies, k as basename$2 } from './utils-92ec89d1.js';
2
2
  import { n as nanoid } from './index-9e71c815.js';
3
- import { c as distDir } from './constants-9320a46c.js';
3
+ import { c as distDir } from './constants-82dad049.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 fs, { promises, realpathSync, statSync, Stats, readdirSync, existsSync } from 'fs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vitest",
3
- "version": "0.0.105",
3
+ "version": "0.0.106",
4
4
  "description": "A blazing fast unit test framework powered by Vite",
5
5
  "keywords": [
6
6
  "vite",