vitest 0.0.106 → 0.0.110

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.
@@ -0,0 +1,11 @@
1
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
2
+
3
+ function getDefaultExportFromCjs (x) {
4
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
5
+ }
6
+
7
+ function commonjsRequire (path) {
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.');
9
+ }
10
+
11
+ export { commonjsRequire as a, commonjsGlobal as c, getDefaultExportFromCjs as g };
package/dist/cli.js CHANGED
@@ -1,23 +1,22 @@
1
1
  import require$$0 from 'readline';
2
2
  import { EventEmitter } from 'events';
3
- import { e as ensurePackageInstalled } from './utils-92ec89d1.js';
4
- import { c as createVitest } from './index-8cc284f9.js';
3
+ import { e as ensurePackageInstalled } from './utils-d97bd6d9.js';
4
+ import { c as createVitest } from './index-b183bb20.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-82dad049.js';
14
+ import './constants-e762cbc5.js';
17
15
  import 'url';
18
16
  import 'perf_hooks';
19
- import './error-e81aa23d.js';
20
- import './index-84978a77.js';
17
+ import './diff-46ee5d7d.js';
18
+ import './index-61c8686f.js';
19
+ import './_commonjsHelpers-c9e3b764.js';
21
20
  import 'assert';
22
21
  import 'worker_threads';
23
22
  import 'tinypool';
@@ -635,10 +634,10 @@ class CAC extends EventEmitter {
635
634
 
636
635
  const cac = (name = "") => new CAC(name);
637
636
 
638
- var version = "0.0.106";
637
+ var version = "0.0.110";
639
638
 
640
639
  const cli = cac("vitest");
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();
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();
642
641
  cli.command("run [...filters]").action(run);
643
642
  cli.command("watch [...filters]").action(dev);
644
643
  cli.command("dev [...filters]").action(dev);
@@ -1,5 +1,5 @@
1
1
  import { fileURLToPath } from 'url';
2
- import { m as resolve } from './utils-92ec89d1.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}"];
@@ -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-92ec89d1.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(format(actual), format(expected))) + "\n");
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";
@@ -4672,55 +4671,66 @@ function parseStack(stack) {
4672
4671
  function unifiedDiff(actual, expected) {
4673
4672
  if (actual === expected)
4674
4673
  return "";
4675
- const diffLimit = 10;
4676
4674
  const indent = " ";
4677
- let expectedLinesCount = 0;
4678
- 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;
4679
4684
  function preprocess(line) {
4680
- if (!line)
4685
+ if (!line || line.match(/\\ No newline/))
4681
4686
  return;
4682
- if (line[0] === "+") {
4683
- if (expectedLinesCount >= diffLimit)
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)
4684
4698
  return;
4685
- expectedLinesCount++;
4686
- line = line[0] + " " + line.slice(1);
4687
- const isLastLine = expectedLinesCount === diffLimit;
4688
- return indent + c.red(`${formatLine(line)} ${isLastLine ? renderTruncateMessage(indent) : ""}`);
4689
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) => {
4690
4706
  if (line[0] === "-") {
4691
- if (actualLinesCount >= diffLimit)
4692
- return;
4693
- actualLinesCount++;
4694
- line = line[0] + " " + line.slice(1);
4695
- const isLastLine = actualLinesCount === diffLimit;
4696
- return indent + c.green(`${formatLine(line)} ${isLastLine ? renderTruncateMessage(indent) : ""}`);
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)}`);
4697
4717
  }
4698
4718
  if (line.match(/@@/))
4699
4719
  return "--";
4700
- if (line.match(/\\ No newline/))
4701
- return null;
4702
- return indent + " " + line;
4703
- }
4704
- const msg = createPatch("string", actual, expected);
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) {
4708
- return `
4709
- ${indent}${c.green("- expected")} ${cleanLines[0]}
4710
- ${indent}${c.red("+ actual")} ${cleanLines[1]}`;
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), "");
4711
4729
  }
4712
- return `
4713
- ${indent}${c.green("- expected")}
4714
- ${indent}${c.red("+ actual")}
4715
-
4716
- ${cleanLines.join("\n")}`;
4730
+ return formatted.map((i) => indent + i).join("\n");
4717
4731
  }
4718
4732
  function formatLine(line) {
4719
- return cliTruncate(line, (process.stdout.columns || 80) - 1);
4720
- }
4721
- function renderTruncateMessage(indent) {
4722
- return `
4723
- ${indent}${c.dim("[...truncated]")}`;
4733
+ return cliTruncate(line, (process.stdout.columns || 80) - 4);
4724
4734
  }
4725
4735
 
4726
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 };