vitest 0.15.0 → 0.16.0
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/{chunk-api-setup.ff687d0e.mjs → chunk-api-setup.f43cd039.mjs} +1 -1
- package/dist/{chunk-integrations-globals.df0878f4.mjs → chunk-integrations-globals.d0c363a6.mjs} +2 -2
- package/dist/{chunk-runtime-chain.ce7f4b92.mjs → chunk-runtime-chain.7103058b.mjs} +10 -3
- package/dist/{chunk-runtime-mocker.2f3cbfe5.mjs → chunk-runtime-mocker.110e3634.mjs} +1 -1
- package/dist/{chunk-vite-node-externalize.db158bfb.mjs → chunk-vite-node-externalize.58e10976.mjs} +12 -12
- package/dist/{chunk-vite-node-utils.c0a0e1b3.mjs → chunk-vite-node-utils.7450fc0c.mjs} +3 -3
- package/dist/cli.mjs +2 -2
- package/dist/entry.mjs +2 -2
- package/dist/index.d.ts +31 -24
- package/dist/index.mjs +1 -1
- package/dist/node.d.ts +5 -4
- package/dist/node.mjs +3 -3
- package/dist/{vendor-entry.7ec02ea2.mjs → vendor-entry.efeeaa5c.mjs} +5 -3
- package/dist/worker.mjs +6 -5
- package/package.json +9 -9
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { promises } from 'fs';
|
|
2
|
-
import { c as createBirpc } from './chunk-vite-node-utils.
|
|
2
|
+
import { c as createBirpc } from './chunk-vite-node-utils.7450fc0c.mjs';
|
|
3
3
|
import require$$0$1 from 'stream';
|
|
4
4
|
import require$$0 from 'zlib';
|
|
5
5
|
import require$$3 from 'net';
|
package/dist/{chunk-integrations-globals.df0878f4.mjs → chunk-integrations-globals.d0c363a6.mjs}
RENAMED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { g as globalApis } from './chunk-constants.7b9cfc82.mjs';
|
|
2
|
-
import { i as index } from './vendor-entry.
|
|
2
|
+
import { i as index } from './vendor-entry.efeeaa5c.mjs';
|
|
3
3
|
import 'url';
|
|
4
4
|
import './chunk-utils-global.79a8b1cc.mjs';
|
|
5
5
|
import 'tty';
|
|
6
6
|
import 'local-pkg';
|
|
7
7
|
import 'path';
|
|
8
8
|
import 'fs';
|
|
9
|
-
import './chunk-runtime-chain.
|
|
9
|
+
import './chunk-runtime-chain.7103058b.mjs';
|
|
10
10
|
import 'chai';
|
|
11
11
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
12
12
|
import './chunk-runtime-rpc.5e78af38.mjs';
|
|
@@ -737,7 +737,7 @@ class SnapshotState {
|
|
|
737
737
|
this._uncheckedKeys.delete(uncheckedKey);
|
|
738
738
|
});
|
|
739
739
|
}
|
|
740
|
-
|
|
740
|
+
_inferInlineSnapshotStack(stacks) {
|
|
741
741
|
const promiseIndex = stacks.findIndex((i) => i.method.match(/__VITEST_(RESOLVES|REJECTS)__/));
|
|
742
742
|
if (promiseIndex !== -1)
|
|
743
743
|
return stacks[promiseIndex + 3];
|
|
@@ -750,11 +750,12 @@ class SnapshotState {
|
|
|
750
750
|
const error = options.error || new Error("Unknown error");
|
|
751
751
|
const stacks = parseStacktrace(error, true);
|
|
752
752
|
stacks.forEach((i) => i.file = slash(i.file));
|
|
753
|
-
const stack = this.
|
|
753
|
+
const stack = this._inferInlineSnapshotStack(stacks);
|
|
754
754
|
if (!stack) {
|
|
755
755
|
throw new Error(`Vitest: Couldn't infer stack frame for inline snapshot.
|
|
756
756
|
${JSON.stringify(stacks)}`);
|
|
757
757
|
}
|
|
758
|
+
stack.column--;
|
|
758
759
|
this._inlineSnapshots.push(__spreadValues$3({
|
|
759
760
|
snapshot: receivedSerialized
|
|
760
761
|
}, stack));
|
|
@@ -921,6 +922,10 @@ class SnapshotClient {
|
|
|
921
922
|
clearTest() {
|
|
922
923
|
this.test = void 0;
|
|
923
924
|
}
|
|
925
|
+
skipTestSnapshots(test) {
|
|
926
|
+
var _a;
|
|
927
|
+
(_a = this.snapshotState) == null ? void 0 : _a.markSnapshotsAsCheckedForTest(test.name);
|
|
928
|
+
}
|
|
924
929
|
assert(options) {
|
|
925
930
|
const {
|
|
926
931
|
test = this.test,
|
|
@@ -1854,7 +1859,9 @@ function createExpect(test) {
|
|
|
1854
1859
|
}
|
|
1855
1860
|
const globalExpect = createExpect();
|
|
1856
1861
|
Object.defineProperty(globalThis, GLOBAL_EXPECT, {
|
|
1857
|
-
value: globalExpect
|
|
1862
|
+
value: globalExpect,
|
|
1863
|
+
writable: true,
|
|
1864
|
+
configurable: true
|
|
1858
1865
|
});
|
|
1859
1866
|
|
|
1860
1867
|
const collectorContext = {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as normalizeRequestId, i as isNodeBuiltin, b as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.
|
|
1
|
+
import { n as normalizeRequestId, i as isNodeBuiltin, b as toFilePath, V as ViteNodeRunner } from './chunk-vite-node-utils.7450fc0c.mjs';
|
|
2
2
|
import { normalizePath } from 'vite';
|
|
3
3
|
import { a as getWorkerState, J as isWindows, K as mergeSlashes, d as dirname, m as resolve, l as basename, L as getType, M as getAllProperties, s as slash } from './chunk-utils-global.79a8b1cc.mjs';
|
|
4
4
|
import { existsSync, readdirSync } from 'fs';
|
package/dist/{chunk-vite-node-externalize.db158bfb.mjs → chunk-vite-node-externalize.58e10976.mjs}
RENAMED
|
@@ -12,7 +12,7 @@ import require$$0$1 from 'util';
|
|
|
12
12
|
import require$$0$2 from 'stream';
|
|
13
13
|
import require$$2 from 'events';
|
|
14
14
|
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
15
|
-
import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.
|
|
15
|
+
import { i as isNodeBuiltin, a as isValidNodeImport, s as slash$1, t as toArray, b as toFilePath, w as withInlineSourcemap, c as createBirpc, V as ViteNodeRunner } from './chunk-vite-node-utils.7450fc0c.mjs';
|
|
16
16
|
import createDebug from 'debug';
|
|
17
17
|
import { MessageChannel } from 'worker_threads';
|
|
18
18
|
import { createHash } from 'crypto';
|
|
@@ -26,7 +26,7 @@ import childProcess from 'child_process';
|
|
|
26
26
|
import MagicString from './chunk-magic-string.efe26975.mjs';
|
|
27
27
|
import { p as prompts } from './vendor-index.98e769c1.mjs';
|
|
28
28
|
|
|
29
|
-
var version = "0.
|
|
29
|
+
var version = "0.16.0";
|
|
30
30
|
|
|
31
31
|
class EndError extends Error {
|
|
32
32
|
constructor(value) {
|
|
@@ -6866,7 +6866,8 @@ class ViteNodeServer {
|
|
|
6866
6866
|
async resolveId(id, importer) {
|
|
6867
6867
|
if (importer && !importer.startsWith(this.server.config.root))
|
|
6868
6868
|
importer = join(this.server.config.root, importer);
|
|
6869
|
-
|
|
6869
|
+
const mode = importer && this.getTransformMode(importer) || "ssr";
|
|
6870
|
+
return this.server.pluginContainer.resolveId(id, importer, { ssr: mode === "ssr" });
|
|
6870
6871
|
}
|
|
6871
6872
|
async fetchModule(id) {
|
|
6872
6873
|
if (!this.fetchPromiseMap.has(id)) {
|
|
@@ -7045,8 +7046,7 @@ function createPool(ctx) {
|
|
|
7045
7046
|
const pool = new Tinypool(options);
|
|
7046
7047
|
const runWithFiles = (name) => {
|
|
7047
7048
|
let id = 0;
|
|
7048
|
-
|
|
7049
|
-
async function runFiles(files, invalidates = []) {
|
|
7049
|
+
async function runFiles(config, files, invalidates = []) {
|
|
7050
7050
|
const { workerPort, port } = createChannel(ctx);
|
|
7051
7051
|
const workerId = ++id;
|
|
7052
7052
|
const data = {
|
|
@@ -7054,8 +7054,7 @@ function createPool(ctx) {
|
|
|
7054
7054
|
config,
|
|
7055
7055
|
files,
|
|
7056
7056
|
invalidates,
|
|
7057
|
-
workerId
|
|
7058
|
-
poolId: !ctx.config.threads ? 1 : (workerId - 1) % maxThreads + 1
|
|
7057
|
+
workerId
|
|
7059
7058
|
};
|
|
7060
7059
|
try {
|
|
7061
7060
|
await pool.run(data, { transferList: [workerPort], name });
|
|
@@ -7065,6 +7064,7 @@ function createPool(ctx) {
|
|
|
7065
7064
|
}
|
|
7066
7065
|
}
|
|
7067
7066
|
return async (files, invalidates) => {
|
|
7067
|
+
const config = ctx.getSerializableConfig();
|
|
7068
7068
|
if (config.shard) {
|
|
7069
7069
|
const { index, count } = config.shard;
|
|
7070
7070
|
const shardSize = Math.ceil(files.length / count);
|
|
@@ -7080,9 +7080,9 @@ function createPool(ctx) {
|
|
|
7080
7080
|
}).sort((a, b) => a.hash < b.hash ? -1 : a.hash > b.hash ? 1 : 0).slice(shardStart, shardEnd).map(({ file }) => file);
|
|
7081
7081
|
}
|
|
7082
7082
|
if (!ctx.config.threads) {
|
|
7083
|
-
await runFiles(files);
|
|
7083
|
+
await runFiles(config, files);
|
|
7084
7084
|
} else {
|
|
7085
|
-
const results = await Promise.allSettled(files.map((file) => runFiles([file], invalidates)));
|
|
7085
|
+
const results = await Promise.allSettled(files.map((file) => runFiles(config, [file], invalidates)));
|
|
7086
7086
|
const errors = results.filter((r) => r.status === "rejected").map((r) => r.reason);
|
|
7087
7087
|
if (errors.length > 0)
|
|
7088
7088
|
throw new AggregateErrorPonyfill(errors, "Errors occurred while running tests. For more information, see serialized error.");
|
|
@@ -7158,7 +7158,7 @@ const F_DOWN = "\u2193";
|
|
|
7158
7158
|
const F_DOWN_RIGHT = "\u21B3";
|
|
7159
7159
|
const F_POINTER = "\u276F";
|
|
7160
7160
|
const F_DOT = "\xB7";
|
|
7161
|
-
const F_CHECK = "\
|
|
7161
|
+
const F_CHECK = "\u2713";
|
|
7162
7162
|
const F_CROSS = "\xD7";
|
|
7163
7163
|
const F_LONG_DASH = "\u23AF";
|
|
7164
7164
|
|
|
@@ -10818,7 +10818,7 @@ function CSSEnablerPlugin(ctx) {
|
|
|
10818
10818
|
if (!isCSS(id))
|
|
10819
10819
|
return;
|
|
10820
10820
|
if (!shouldProcessCSS(id))
|
|
10821
|
-
return "";
|
|
10821
|
+
return { code: "" };
|
|
10822
10822
|
}
|
|
10823
10823
|
};
|
|
10824
10824
|
}
|
|
@@ -10936,7 +10936,7 @@ async function VitestPlugin(options = {}, ctx = new Vitest()) {
|
|
|
10936
10936
|
await ctx.setServer(options, server);
|
|
10937
10937
|
haveStarted = true;
|
|
10938
10938
|
if (options.api && options.watch)
|
|
10939
|
-
(await import('./chunk-api-setup.
|
|
10939
|
+
(await import('./chunk-api-setup.f43cd039.mjs')).setup(ctx);
|
|
10940
10940
|
} catch (err) {
|
|
10941
10941
|
ctx.printError(err, true);
|
|
10942
10942
|
process.exit(1);
|
|
@@ -8727,7 +8727,7 @@ function moduleResolve(specifier, base, conditions) {
|
|
|
8727
8727
|
const DEFAULT_CONDITIONS_SET = /* @__PURE__ */ new Set(["node", "import"]);
|
|
8728
8728
|
const DEFAULT_URL = pathToFileURL(process.cwd());
|
|
8729
8729
|
const DEFAULT_EXTENSIONS = [".mjs", ".cjs", ".js", ".json"];
|
|
8730
|
-
const NOT_FOUND_ERRORS = /* @__PURE__ */ new Set(["ERR_MODULE_NOT_FOUND", "ERR_UNSUPPORTED_DIR_IMPORT", "MODULE_NOT_FOUND"]);
|
|
8730
|
+
const NOT_FOUND_ERRORS = /* @__PURE__ */ new Set(["ERR_MODULE_NOT_FOUND", "ERR_UNSUPPORTED_DIR_IMPORT", "MODULE_NOT_FOUND", "ERR_PACKAGE_PATH_NOT_EXPORTED"]);
|
|
8731
8731
|
function _tryModuleResolve(id, url, conditions) {
|
|
8732
8732
|
try {
|
|
8733
8733
|
return moduleResolve(id, url, conditions);
|
|
@@ -8851,7 +8851,7 @@ function mergeSlashes(str) {
|
|
|
8851
8851
|
function normalizeRequestId(id, base) {
|
|
8852
8852
|
if (base && id.startsWith(base))
|
|
8853
8853
|
id = `/${id.slice(base.length)}`;
|
|
8854
|
-
return id.replace(/^\/@id\/__x00__/, "\0").replace(/^\/@id\//, "").replace(/^__vite-browser-external:/, "").replace(/^(node|file):/, "").replace(/^\/+/, "/").replace(/\?v=\w+/, "?").replace(/&v=\w+/, "").replace(/\?t=\w+/, "?").replace(/&t=\w+/, "").replace(/\?import/, "?").replace(/&import/, "").replace(/\?+$/, "");
|
|
8854
|
+
return id.replace(/^\/@id\/__x00__/, "\0").replace(/^\/@id\//, "").replace(/^__vite-browser-external:/, "").replace(/^(node|file):/, "").replace(/^\/+/, "/").replace(/\?v=\w+/, "?").replace(/&v=\w+/, "").replace(/\?t=\w+/, "?").replace(/&t=\w+/, "").replace(/\?import/, "?").replace(/&import/, "").replace(/\?&/, "?").replace(/\?+$/, "");
|
|
8855
8855
|
}
|
|
8856
8856
|
function normalizeModuleId(id) {
|
|
8857
8857
|
return id.replace(/\\/g, "/").replace(/^\/@fs\//, "/").replace(/^file:\//, "/").replace(/^\/+/, "/");
|
|
@@ -8860,7 +8860,7 @@ function isPrimitive(v) {
|
|
|
8860
8860
|
return v !== Object(v);
|
|
8861
8861
|
}
|
|
8862
8862
|
function toFilePath(id, root) {
|
|
8863
|
-
let absolute = slash(id).startsWith("/@fs/") ? id.slice(4) : id.startsWith(
|
|
8863
|
+
let absolute = slash(id).startsWith("/@fs/") ? id.slice(4) : id.startsWith(root) ? id : id.startsWith("/") ? slash(resolve(root, id.slice(1))) : id;
|
|
8864
8864
|
if (absolute.startsWith("//"))
|
|
8865
8865
|
absolute = absolute.slice(1);
|
|
8866
8866
|
return isWindows && absolute.startsWith("/") ? fileURLToPath$2(pathToFileURL(absolute.slice(1)).href) : absolute;
|
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
2
|
import { p as picocolors } from './chunk-utils-global.79a8b1cc.mjs';
|
|
3
|
-
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.
|
|
3
|
+
import { v as version, s as startVitest, d as divider } from './chunk-vite-node-externalize.58e10976.mjs';
|
|
4
4
|
import 'tty';
|
|
5
5
|
import 'local-pkg';
|
|
6
6
|
import 'path';
|
|
@@ -16,7 +16,7 @@ import 'os';
|
|
|
16
16
|
import 'util';
|
|
17
17
|
import 'stream';
|
|
18
18
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
19
|
-
import './chunk-vite-node-utils.
|
|
19
|
+
import './chunk-vite-node-utils.7450fc0c.mjs';
|
|
20
20
|
import 'vm';
|
|
21
21
|
import 'assert';
|
|
22
22
|
import 'debug';
|
package/dist/entry.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export { r as run } from './vendor-entry.
|
|
1
|
+
export { r as run } from './vendor-entry.efeeaa5c.mjs';
|
|
2
2
|
import 'fs';
|
|
3
3
|
import './chunk-utils-global.79a8b1cc.mjs';
|
|
4
4
|
import 'tty';
|
|
5
5
|
import 'local-pkg';
|
|
6
6
|
import 'path';
|
|
7
|
-
import './chunk-runtime-chain.
|
|
7
|
+
import './chunk-runtime-chain.7103058b.mjs';
|
|
8
8
|
import 'chai';
|
|
9
9
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
10
10
|
import './chunk-runtime-rpc.5e78af38.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -496,7 +496,7 @@ declare type DeepMerge<F, S> = MergeInsertions<{
|
|
|
496
496
|
declare type MutableArray<T extends readonly any[]> = {
|
|
497
497
|
-readonly [k in keyof T]: T[k];
|
|
498
498
|
};
|
|
499
|
-
interface Constructable {
|
|
499
|
+
interface Constructable$1 {
|
|
500
500
|
new (...args: any[]): any;
|
|
501
501
|
}
|
|
502
502
|
interface ModuleCache {
|
|
@@ -768,14 +768,14 @@ declare type SuiteAPI<ExtraContext = {}> = ChainableFunction<'concurrent' | 'onl
|
|
|
768
768
|
skipIf(condition: any): SuiteAPI<ExtraContext>;
|
|
769
769
|
runIf(condition: any): SuiteAPI<ExtraContext>;
|
|
770
770
|
};
|
|
771
|
-
declare type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return
|
|
771
|
+
declare type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return>;
|
|
772
|
+
declare type HookCleanupCallback = (() => Awaitable<unknown>) | void;
|
|
772
773
|
interface SuiteHooks {
|
|
773
|
-
beforeAll: HookListener<[Suite | File],
|
|
774
|
+
beforeAll: HookListener<[Suite | File], HookCleanupCallback>[];
|
|
774
775
|
afterAll: HookListener<[Suite | File]>[];
|
|
775
|
-
beforeEach: HookListener<[TestContext, Suite],
|
|
776
|
+
beforeEach: HookListener<[TestContext, Suite], HookCleanupCallback>[];
|
|
776
777
|
afterEach: HookListener<[TestContext, Suite]>[];
|
|
777
778
|
}
|
|
778
|
-
declare type HookCleanupCallback = (() => Awaitable<void>) | void;
|
|
779
779
|
interface SuiteCollector<ExtraContext = {}> {
|
|
780
780
|
readonly name: string;
|
|
781
781
|
readonly mode: RunMode;
|
|
@@ -1339,7 +1339,7 @@ declare class SnapshotState {
|
|
|
1339
1339
|
updated: number;
|
|
1340
1340
|
constructor(testFilePath: string, snapshotPath: string, options: SnapshotStateOptions);
|
|
1341
1341
|
markSnapshotsAsCheckedForTest(testName: string): void;
|
|
1342
|
-
private
|
|
1342
|
+
private _inferInlineSnapshotStack;
|
|
1343
1343
|
private _addSnapshot;
|
|
1344
1344
|
clear(): void;
|
|
1345
1345
|
save(): Promise<SaveStatus>;
|
|
@@ -1460,8 +1460,8 @@ declare global {
|
|
|
1460
1460
|
nthCalledWith<E extends any[]>(nthCall: number, ...args: E): void;
|
|
1461
1461
|
toHaveBeenLastCalledWith<E extends any[]>(...args: E): void;
|
|
1462
1462
|
lastCalledWith<E extends any[]>(...args: E): void;
|
|
1463
|
-
toThrow(expected?: string | Constructable | RegExp | Error): void;
|
|
1464
|
-
toThrowError(expected?: string | Constructable | RegExp | Error): void;
|
|
1463
|
+
toThrow(expected?: string | Constructable$1 | RegExp | Error): void;
|
|
1464
|
+
toThrowError(expected?: string | Constructable$1 | RegExp | Error): void;
|
|
1465
1465
|
toReturn(): void;
|
|
1466
1466
|
toHaveReturned(): void;
|
|
1467
1467
|
toReturnTimes(times: number): void;
|
|
@@ -1499,7 +1499,6 @@ declare type BirpcReturn<RemoteFunctions> = {
|
|
|
1499
1499
|
|
|
1500
1500
|
interface WorkerContext {
|
|
1501
1501
|
workerId: number;
|
|
1502
|
-
poolId: number;
|
|
1503
1502
|
port: MessagePort;
|
|
1504
1503
|
config: ResolvedConfig;
|
|
1505
1504
|
files: string[];
|
|
@@ -1542,7 +1541,7 @@ interface MockResultThrow {
|
|
|
1542
1541
|
value: any;
|
|
1543
1542
|
}
|
|
1544
1543
|
declare type MockResult<T> = MockResultReturn<T> | MockResultThrow | MockResultIncomplete;
|
|
1545
|
-
interface
|
|
1544
|
+
interface MockContext<TArgs, TReturns> {
|
|
1546
1545
|
calls: TArgs[];
|
|
1547
1546
|
instances: TReturns[];
|
|
1548
1547
|
invocationCallOrder: number[];
|
|
@@ -1560,10 +1559,9 @@ declare type Classes<T> = {
|
|
|
1560
1559
|
[K in keyof T]: T[K] extends new (...args: any[]) => any ? K : never;
|
|
1561
1560
|
}[keyof T] & (string | symbol);
|
|
1562
1561
|
interface SpyInstance<TArgs extends any[] = any[], TReturns = any> {
|
|
1563
|
-
(...args: TArgs): TReturns;
|
|
1564
1562
|
getMockName(): string;
|
|
1565
1563
|
mockName(n: string): this;
|
|
1566
|
-
mock:
|
|
1564
|
+
mock: MockContext<TArgs, TReturns>;
|
|
1567
1565
|
mockClear(): this;
|
|
1568
1566
|
mockReset(): this;
|
|
1569
1567
|
mockRestore(): void;
|
|
@@ -1578,15 +1576,17 @@ interface SpyInstance<TArgs extends any[] = any[], TReturns = any> {
|
|
|
1578
1576
|
mockRejectedValue(obj: any): this;
|
|
1579
1577
|
mockRejectedValueOnce(obj: any): this;
|
|
1580
1578
|
}
|
|
1581
|
-
interface
|
|
1582
|
-
|
|
1579
|
+
interface MockInstance<A extends any[] = any[], R = any> extends SpyInstance<A, R> {
|
|
1580
|
+
}
|
|
1581
|
+
interface Mock<TArgs extends any[] = any, TReturns = any> extends SpyInstance<TArgs, TReturns> {
|
|
1583
1582
|
new (...args: TArgs): TReturns;
|
|
1583
|
+
(...args: TArgs): TReturns;
|
|
1584
1584
|
}
|
|
1585
|
-
declare type MaybeMockedConstructor<T> = T extends new (...args: Array<any>) => infer R ?
|
|
1586
|
-
declare type MockedFunction<T extends Procedure> =
|
|
1585
|
+
declare type MaybeMockedConstructor<T> = T extends new (...args: Array<any>) => infer R ? Mock<ConstructorParameters<T>, R> : T;
|
|
1586
|
+
declare type MockedFunction<T extends Procedure> = Mock<Parameters<T>, ReturnType<T>> & {
|
|
1587
1587
|
[K in keyof T]: T[K];
|
|
1588
1588
|
};
|
|
1589
|
-
declare type MockedFunctionDeep<T extends Procedure> =
|
|
1589
|
+
declare type MockedFunctionDeep<T extends Procedure> = Mock<Parameters<T>, ReturnType<T>> & MockedObjectDeep<T>;
|
|
1590
1590
|
declare type MockedObject<T> = MaybeMockedConstructor<T> & {
|
|
1591
1591
|
[K in Methods<T>]: T[K] extends Procedure ? MockedFunction<T[K]> : T[K];
|
|
1592
1592
|
} & {
|
|
@@ -1599,16 +1599,23 @@ declare type MockedObjectDeep<T> = MaybeMockedConstructor<T> & {
|
|
|
1599
1599
|
};
|
|
1600
1600
|
declare type MaybeMockedDeep<T> = T extends Procedure ? MockedFunctionDeep<T> : T extends object ? MockedObjectDeep<T> : T;
|
|
1601
1601
|
declare type MaybeMocked<T> = T extends Procedure ? MockedFunction<T> : T extends object ? MockedObject<T> : T;
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
new (...args: T extends new (...args: any) => any ? ConstructorParameters<T> : never): T;
|
|
1605
|
-
(...args: Parameters<T>): ReturnType<T>;
|
|
1602
|
+
interface Constructable {
|
|
1603
|
+
new (...args: any[]): any;
|
|
1606
1604
|
}
|
|
1605
|
+
declare type MockedClass<T extends Constructable> = MockInstance<InstanceType<T>, T extends new (...args: infer P) => any ? P : never> & {
|
|
1606
|
+
prototype: T extends {
|
|
1607
|
+
prototype: any;
|
|
1608
|
+
} ? Mocked<T['prototype']> : never;
|
|
1609
|
+
} & T;
|
|
1610
|
+
declare type Mocked<T> = {
|
|
1611
|
+
[P in keyof T]: T[P] extends (...args: infer Args) => infer Returns ? MockInstance<Args, Returns> : T[P] extends Constructable ? MockedClass<T[P]> : T[P];
|
|
1612
|
+
} & T;
|
|
1613
|
+
declare type EnhancedSpy<TArgs extends any[] = any[], TReturns = any> = SpyInstance<TArgs, TReturns> & SpyImpl<TArgs, TReturns>;
|
|
1607
1614
|
declare function spyOn<T, S extends Properties<Required<T>>>(obj: T, methodName: S, accessType: 'get'): SpyInstance<[], T[S]>;
|
|
1608
1615
|
declare function spyOn<T, G extends Properties<Required<T>>>(obj: T, methodName: G, accessType: 'set'): SpyInstance<[T[G]], void>;
|
|
1609
1616
|
declare function spyOn<T, M extends (Methods<Required<T>> | Classes<Required<T>>)>(obj: T, methodName: M): Required<T>[M] extends (...args: infer A) => infer R | (new (...args: infer A) => infer R) ? SpyInstance<A, R> : never;
|
|
1610
|
-
declare function fn<TArgs extends any[] = any[], R = any>():
|
|
1611
|
-
declare function fn<TArgs extends any[] = any[], R = any>(implementation: (...args: TArgs) => R):
|
|
1617
|
+
declare function fn<TArgs extends any[] = any[], R = any>(): Mock<TArgs, R>;
|
|
1618
|
+
declare function fn<TArgs extends any[] = any[], R = any>(implementation: (...args: TArgs) => R): Mock<TArgs, R>;
|
|
1612
1619
|
|
|
1613
1620
|
declare const suite: SuiteAPI<{}>;
|
|
1614
1621
|
declare const test: TestAPI<{}>;
|
|
@@ -1765,4 +1772,4 @@ interface WebSocketHandlers {
|
|
|
1765
1772
|
interface WebSocketEvents extends Pick<Reporter, 'onCollected' | 'onFinished' | 'onTaskUpdate' | 'onUserConsoleLog'> {
|
|
1766
1773
|
}
|
|
1767
1774
|
|
|
1768
|
-
export { ApiConfig, ArgumentsType$1 as ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, C8Options, Constructable, CoverageReporter, DeepMerge, DoneCallback, EnhancedSpy, Environment, EnvironmentOptions, EnvironmentReturn, ErrorWithDiff, File, HookCleanupCallback, HookListener, InlineConfig, JSDOMOptions, MergeInsertions, MockedFunction, MockedObject, ModuleCache, ModuleGraphData, MutableArray, Nullable, ParsedStack, Position, Reporter, ResolveIdFunction, ResolvedC8Options, ResolvedConfig, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState,
|
|
1775
|
+
export { ApiConfig, ArgumentsType$1 as ArgumentsType, Arrayable, Awaitable, BuiltinEnvironment, C8Options, Constructable$1 as Constructable, CoverageReporter, DeepMerge, DoneCallback, EnhancedSpy, Environment, EnvironmentOptions, EnvironmentReturn, ErrorWithDiff, File, HookCleanupCallback, HookListener, InlineConfig, JSDOMOptions, MergeInsertions, Mock, MockContext, MockInstance, Mocked, MockedClass, MockedFunction, MockedObject, ModuleCache, ModuleGraphData, MutableArray, Nullable, ParsedStack, Position, Reporter, ResolveIdFunction, ResolvedC8Options, ResolvedConfig, RunMode, RuntimeContext, SnapshotData, SnapshotMatchOptions, SnapshotResult, SnapshotStateOptions, SnapshotSummary, SnapshotUpdateState, SpyInstance, Suite, SuiteAPI, SuiteCollector, SuiteFactory, SuiteHooks, Task, TaskBase, TaskResult, TaskResultPack, TaskState, Test, TestAPI, TestContext, TestFunction, TransformResultWithSource, UncheckedSnapshot, UserConfig, UserConsoleLog, Vitest, WebSocketEvents, WebSocketHandlers, WorkerContext, WorkerGlobalState, WorkerRPC, afterAll, afterEach, beforeAll, beforeEach, createExpect, describe, globalExpect as expect, getRunningMode, isFirstRun, isWatchMode, it, runOnce, suite, test, vi, vitest, withCallback };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { c as afterAll, f as afterEach, b as beforeAll, e as beforeEach, g as createExpect, d as describe, h as expect, k as getRunningMode, a as isFirstRun, l as isWatchMode, i as it, r as runOnce, s as suite, t as test, j as vi, v as vitest, w as withCallback } from './chunk-runtime-chain.
|
|
1
|
+
export { c as afterAll, f as afterEach, b as beforeAll, e as beforeEach, g as createExpect, d as describe, h as expect, k as getRunningMode, a as isFirstRun, l as isWatchMode, i as it, r as runOnce, s as suite, t as test, j as vi, v as vitest, w as withCallback } from './chunk-runtime-chain.7103058b.mjs';
|
|
2
2
|
export { assert, default as chai, should } from 'chai';
|
|
3
3
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
4
4
|
import './chunk-runtime-rpc.5e78af38.mjs';
|
package/dist/node.d.ts
CHANGED
|
@@ -604,11 +604,12 @@ interface Test<ExtraContext = {}> extends TaskBase {
|
|
|
604
604
|
context: TestContext & ExtraContext;
|
|
605
605
|
}
|
|
606
606
|
declare type Task = Test | Suite | File;
|
|
607
|
-
declare type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return
|
|
607
|
+
declare type HookListener<T extends any[], Return = void> = (...args: T) => Awaitable<Return>;
|
|
608
|
+
declare type HookCleanupCallback = (() => Awaitable<unknown>) | void;
|
|
608
609
|
interface SuiteHooks {
|
|
609
|
-
beforeAll: HookListener<[Suite | File],
|
|
610
|
+
beforeAll: HookListener<[Suite | File], HookCleanupCallback>[];
|
|
610
611
|
afterAll: HookListener<[Suite | File]>[];
|
|
611
|
-
beforeEach: HookListener<[TestContext, Suite],
|
|
612
|
+
beforeEach: HookListener<[TestContext, Suite], HookCleanupCallback>[];
|
|
612
613
|
afterEach: HookListener<[TestContext, Suite]>[];
|
|
613
614
|
}
|
|
614
615
|
interface TestContext {
|
|
@@ -1158,7 +1159,7 @@ declare class SnapshotState {
|
|
|
1158
1159
|
updated: number;
|
|
1159
1160
|
constructor(testFilePath: string, snapshotPath: string, options: SnapshotStateOptions);
|
|
1160
1161
|
markSnapshotsAsCheckedForTest(testName: string): void;
|
|
1161
|
-
private
|
|
1162
|
+
private _inferInlineSnapshotStack;
|
|
1162
1163
|
private _addSnapshot;
|
|
1163
1164
|
clear(): void;
|
|
1164
1165
|
save(): Promise<SaveStatus>;
|
package/dist/node.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.
|
|
2
|
-
export { V as VitestRunner } from './chunk-runtime-mocker.
|
|
1
|
+
export { V as VitestPlugin, c as createVitest, s as startVitest } from './chunk-vite-node-externalize.58e10976.mjs';
|
|
2
|
+
export { V as VitestRunner } from './chunk-runtime-mocker.110e3634.mjs';
|
|
3
3
|
import './chunk-utils-global.79a8b1cc.mjs';
|
|
4
4
|
import 'tty';
|
|
5
5
|
import 'local-pkg';
|
|
@@ -17,7 +17,7 @@ import 'util';
|
|
|
17
17
|
import 'stream';
|
|
18
18
|
import 'events';
|
|
19
19
|
import './vendor-_commonjsHelpers.4da45ef5.mjs';
|
|
20
|
-
import './chunk-vite-node-utils.
|
|
20
|
+
import './chunk-vite-node-utils.7450fc0c.mjs';
|
|
21
21
|
import 'vm';
|
|
22
22
|
import 'assert';
|
|
23
23
|
import 'debug';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { promises } from 'fs';
|
|
2
2
|
import { t as isNode, a as getWorkerState, h as safeClearTimeout, f as safeSetTimeout, C as toArray, N as deepClone, L as getType, q as relative, O as partitionSuiteChildren, P as hasTests, v as hasFailed, e as getFullName, r as resetModules } from './chunk-utils-global.79a8b1cc.mjs';
|
|
3
3
|
import { importModule } from 'local-pkg';
|
|
4
|
-
import { s as suite, t as test, d as describe, i as it, r as runOnce, a as isFirstRun, b as beforeAll, c as afterAll, e as beforeEach, f as afterEach, w as withCallback, g as createExpect, h as globalExpect, v as vitest, j as vi, k as getRunningMode, l as isWatchMode, m as resetRunOnceCounter, R as RealDate, n as clearCollectorContext, o as defaultSuite, p as setHooks, q as getHooks, u as collectorContext, x as getSnapshotClient, y as setState, G as GLOBAL_EXPECT, z as getFn, A as getState } from './chunk-runtime-chain.
|
|
4
|
+
import { s as suite, t as test, d as describe, i as it, r as runOnce, a as isFirstRun, b as beforeAll, c as afterAll, e as beforeEach, f as afterEach, w as withCallback, g as createExpect, h as globalExpect, v as vitest, j as vi, k as getRunningMode, l as isWatchMode, m as resetRunOnceCounter, R as RealDate, n as clearCollectorContext, o as defaultSuite, p as setHooks, q as getHooks, u as collectorContext, x as getSnapshotClient, y as setState, G as GLOBAL_EXPECT, z as getFn, A as getState } from './chunk-runtime-chain.7103058b.mjs';
|
|
5
5
|
import chai, { assert, should, util } from 'chai';
|
|
6
6
|
import { r as rpc } from './chunk-runtime-rpc.5e78af38.mjs';
|
|
7
7
|
import { t as takeCoverage, p as pLimit } from './chunk-defaults.dc6dc23d.mjs';
|
|
@@ -438,7 +438,7 @@ async function setupGlobalEnv(config) {
|
|
|
438
438
|
if (isNode)
|
|
439
439
|
await setupConsoleLogSpy();
|
|
440
440
|
if (config.globals)
|
|
441
|
-
(await import('./chunk-integrations-globals.
|
|
441
|
+
(await import('./chunk-integrations-globals.d0c363a6.mjs')).registerApiGlobally();
|
|
442
442
|
}
|
|
443
443
|
function setupDefines(defines) {
|
|
444
444
|
for (const key in defines)
|
|
@@ -858,8 +858,10 @@ async function sendTasksUpdate() {
|
|
|
858
858
|
}
|
|
859
859
|
async function runTest(test) {
|
|
860
860
|
var _a, _b;
|
|
861
|
-
if (test.mode !== "run")
|
|
861
|
+
if (test.mode !== "run") {
|
|
862
|
+
getSnapshotClient().skipTestSnapshots(test);
|
|
862
863
|
return;
|
|
864
|
+
}
|
|
863
865
|
if (((_a = test.result) == null ? void 0 : _a.state) === "fail") {
|
|
864
866
|
updateTask(test);
|
|
865
867
|
return;
|
package/dist/worker.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { m as resolve, a as getWorkerState } from './chunk-utils-global.79a8b1cc.mjs';
|
|
2
|
-
import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.
|
|
2
|
+
import { c as createBirpc, M as ModuleCacheMap } from './chunk-vite-node-utils.7450fc0c.mjs';
|
|
3
|
+
import { workerId } from 'tinypool';
|
|
3
4
|
import { d as distDir } from './chunk-constants.7b9cfc82.mjs';
|
|
4
|
-
import { e as executeInViteNode } from './chunk-runtime-mocker.
|
|
5
|
+
import { e as executeInViteNode } from './chunk-runtime-mocker.110e3634.mjs';
|
|
5
6
|
import { r as rpc } from './chunk-runtime-rpc.5e78af38.mjs';
|
|
6
7
|
import 'tty';
|
|
7
8
|
import 'local-pkg';
|
|
@@ -55,9 +56,9 @@ async function startViteNode(ctx) {
|
|
|
55
56
|
function init(ctx) {
|
|
56
57
|
if (typeof __vitest_worker__ !== "undefined" && ctx.config.threads && ctx.config.isolate)
|
|
57
58
|
throw new Error(`worker for ${ctx.files.join(",")} already initialized by ${getWorkerState().ctx.files.join(",")}. This is probably an internal bug of Vitest.`);
|
|
58
|
-
const { config, port, workerId
|
|
59
|
-
process.env.VITEST_WORKER_ID = String(workerId);
|
|
60
|
-
process.env.VITEST_POOL_ID = String(
|
|
59
|
+
const { config, port, workerId: workerId$1 } = ctx;
|
|
60
|
+
process.env.VITEST_WORKER_ID = String(workerId$1);
|
|
61
|
+
process.env.VITEST_POOL_ID = String(workerId);
|
|
61
62
|
globalThis.__vitest_worker__ = {
|
|
62
63
|
ctx,
|
|
63
64
|
moduleCache,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitest",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
4
4
|
"description": "A blazing fast unit test framework powered by Vite",
|
|
5
5
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"chai": "^4.3.6",
|
|
84
84
|
"debug": "^4.3.4",
|
|
85
85
|
"local-pkg": "^0.4.1",
|
|
86
|
-
"tinypool": "^0.1
|
|
87
|
-
"tinyspy": "^0.3.
|
|
86
|
+
"tinypool": "^0.2.1",
|
|
87
|
+
"tinyspy": "^0.3.3",
|
|
88
88
|
"vite": "^2.9.12"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"@types/natural-compare": "^1.4.1",
|
|
97
97
|
"@types/prompts": "^2.4.0",
|
|
98
98
|
"@types/sinonjs__fake-timers": "^8.1.2",
|
|
99
|
-
"@vitest/ui": "0.
|
|
99
|
+
"@vitest/ui": "0.16.0",
|
|
100
100
|
"birpc": "^0.2.3",
|
|
101
101
|
"c8": "^7.11.3",
|
|
102
102
|
"cac": "^6.7.12",
|
|
@@ -112,19 +112,19 @@
|
|
|
112
112
|
"log-update": "^5.0.1",
|
|
113
113
|
"magic-string": "^0.26.2",
|
|
114
114
|
"micromatch": "^4.0.5",
|
|
115
|
-
"mlly": "^0.5.
|
|
115
|
+
"mlly": "^0.5.3",
|
|
116
116
|
"natural-compare": "^1.4.0",
|
|
117
117
|
"p-limit": "^4.0.0",
|
|
118
118
|
"pathe": "^0.2.0",
|
|
119
119
|
"picocolors": "^1.0.0",
|
|
120
|
-
"pkg-types": "^0.3.
|
|
120
|
+
"pkg-types": "^0.3.3",
|
|
121
121
|
"pretty-format": "^27.5.1",
|
|
122
122
|
"prompts": "^2.4.2",
|
|
123
|
-
"rollup": "^2.75.
|
|
123
|
+
"rollup": "^2.75.7",
|
|
124
124
|
"source-map-js": "^1.0.2",
|
|
125
125
|
"strip-ansi": "^7.0.1",
|
|
126
|
-
"typescript": "^4.7.
|
|
127
|
-
"vite-node": "0.
|
|
126
|
+
"typescript": "^4.7.4",
|
|
127
|
+
"vite-node": "0.16.0",
|
|
128
128
|
"ws": "^8.8.0"
|
|
129
129
|
},
|
|
130
130
|
"scripts": {
|