vitest 0.0.107 → 0.0.111
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/_commonjsHelpers-c9e3b764.js +11 -0
- package/dist/cli.js +8 -9
- package/dist/{constants-82dad049.js → constants-2b0310b7.js} +1 -1
- package/dist/{error-e81aa23d.js → diff-66d6bb83.js} +51 -41
- package/dist/entry.js +37 -456
- package/dist/global-201fd559.js +20 -0
- package/dist/{index-77f19d39.js → index-2bb9fd4d.js} +12 -5
- package/dist/{index-84978a77.js → index-61c8686f.js} +1 -1
- package/dist/{index-8cc284f9.js → index-8ab26d25.js} +1768 -1563
- package/dist/{index-1ede1cc5.js → index-9f4b9905.js} +2 -6
- package/dist/index.d.ts +178 -19
- package/dist/index.js +6 -5
- package/dist/jest-mock-a57b745c.js +101 -0
- package/dist/{middleware-0c8d46aa.js → middleware-2028dfa0.js} +2 -4
- package/dist/node.d.ts +62 -1
- package/dist/node.js +6 -7
- package/dist/utils-cb6b1266.js +352 -0
- package/dist/utils.js +1 -3
- package/dist/vi-cb9e4e4e.js +1018 -0
- package/dist/worker.js +142 -72
- package/package.json +6 -6
- package/dist/global-0f4da031.js +0 -19
- package/dist/index-9e71c815.js +0 -12
- package/dist/suite-ff89a82e.js +0 -201
- package/dist/utils-92ec89d1.js +0 -814
|
@@ -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-
|
|
4
|
-
import { c as createVitest } from './index-
|
|
3
|
+
import { e as ensurePackageInstalled } from './utils-cb6b1266.js';
|
|
4
|
+
import { c as createVitest } from './index-8ab26d25.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-
|
|
14
|
+
import './constants-2b0310b7.js';
|
|
17
15
|
import 'url';
|
|
18
16
|
import 'perf_hooks';
|
|
19
|
-
import './
|
|
20
|
-
import './index-
|
|
17
|
+
import './diff-66d6bb83.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.
|
|
637
|
+
var version = "0.0.111";
|
|
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("--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();
|
|
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("--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();
|
|
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 {
|
|
2
|
+
import { h as resolve } from './utils-cb6b1266.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 {
|
|
3
|
-
import { p as notNullish, c, r as relative } from './utils-92ec89d1.js';
|
|
2
|
+
import { k as notNullish, c, r as relative } from './utils-cb6b1266.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(
|
|
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
|
-
|
|
4678
|
-
|
|
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
|
-
|
|
4683
|
-
|
|
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
|
-
|
|
4692
|
-
|
|
4693
|
-
|
|
4694
|
-
|
|
4695
|
-
|
|
4696
|
-
|
|
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
|
-
|
|
4701
|
-
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
|
|
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) -
|
|
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
|
-
export { F_POINTER as F,
|
|
4736
|
+
export { F_POINTER as F, F_DOWN as a, F_LONG_DASH as b, F_DOWN_RIGHT as c, F_DOT as d, F_CHECK as e, F_CROSS as f, F_RIGHT as g, stringWidth as h, ansiStyles as i, sliceAnsi as j, cliTruncate as k, printError as p, stripAnsi as s, unifiedDiff as u };
|