vitest 0.24.3 → 0.24.5
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/browser.d.ts +3 -3
- package/dist/browser.js +8 -7
- package/dist/{chunk-api-setup.cdeaef6b.js → chunk-api-setup.629f8133.js} +4 -4
- package/dist/{chunk-integrations-globals.10e6725a.js → chunk-integrations-globals.32ef80c3.js} +6 -6
- package/dist/{chunk-mock-date.9fe2b438.js → chunk-mock-date.030959d3.js} +1 -1
- package/dist/{chunk-runtime-chain.072b5677.js → chunk-runtime-chain.37ec5d73.js} +40 -9
- package/dist/chunk-runtime-error.17751c39.js +135 -0
- package/dist/{chunk-runtime-hooks.6963ff8f.js → chunk-runtime-hooks.d748b085.js} +4 -4
- package/dist/{chunk-runtime-mocker.3eb1fcc0.js → chunk-runtime-mocker.41b92ec9.js} +3 -3
- package/dist/chunk-runtime-rpc.b418c0ab.js +30 -0
- package/dist/{chunk-runtime-error.b043a88d.js → chunk-runtime-setup.ab6b6274.js} +11 -142
- package/dist/chunk-utils-source-map.663e2952.js +3429 -0
- package/dist/{chunk-utils-source-map.d9d36eb0.js → chunk-utils-timers.8fca243e.js} +19 -3439
- package/dist/{chunk-vite-node-client.e22799cd.js → chunk-vite-node-client.3868b3ba.js} +10 -12
- package/dist/{chunk-vite-node-externalize.efa824b9.js → chunk-vite-node-externalize.d9033432.js} +28 -24
- package/dist/{chunk-vite-node-utils.835c8b2c.js → chunk-vite-node-utils.2144000e.js} +14 -11
- package/dist/cli-wrapper.js +4 -0
- package/dist/cli.js +14 -8
- package/dist/config.cjs +3 -4
- package/dist/config.d.ts +1 -1
- package/dist/config.js +3 -4
- package/dist/entry.js +8 -7
- package/dist/environments.d.ts +1 -1
- package/dist/{global-732f9b14.d.ts → global-58e8e951.d.ts} +5 -0
- package/dist/{index-40e0cb97.d.ts → index-220c1d70.d.ts} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +6 -6
- package/dist/loader.js +3 -3
- package/dist/node.d.ts +2 -2
- package/dist/node.js +7 -7
- package/dist/suite.js +5 -5
- package/dist/worker.js +9 -7
- package/package.json +8 -7
- package/dist/chunk-runtime-rpc.e583f5e7.js +0 -16
- package/dist/chunk-utils-timers.ab764c0c.js +0 -27
package/dist/browser.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { E as EnhancedSpy, r as Mock, u as MockContext, q as MockInstance, v as Mocked, w as MockedClass, o as MockedFunction, p as MockedObject, S as SpyInstance, j as afterAll, l as afterEach, h as beforeAll, k as beforeEach, n as createExpect, e as describe, m as expect, i as it, d as suite, t as test } from './index-
|
|
2
|
-
import { R as ResolvedConfig } from './global-
|
|
3
|
-
export { L as AfterSuiteRunMeta, A as ApiConfig, Y as ArgumentsType, X as Arrayable, P as Awaitable, ae as BaseCoverageOptions, ak as BenchFunction, ai as Benchmark, al as BenchmarkAPI, aj as BenchmarkResult, ah as BenchmarkUserOptions, B as BuiltinEnvironment, C as CSSModuleScopeStrategy, a0 as Constructable, ag as CoverageC8Options, af as CoverageIstanbulOptions, ac as CoverageOptions, a9 as CoverageProvider, aa as CoverageProviderModule, ab as CoverageReporter, _ as DeepMerge, D as DoneCallback, a3 as Environment, E as EnvironmentOptions, a2 as EnvironmentReturn, a7 as ErrorWithDiff, a as File, n as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, Z as MergeInsertions, a1 as ModuleCache, M as ModuleGraphData, $ as MutableArray, Q as Nullable, a8 as OnServerRestartHandler, a6 as ParsedStack, a5 as Position, b as Reporter, K as ResolveIdFunction, R as ResolvedConfig, ad as ResolvedCoverageOptions, d as RunMode, r as RuntimeContext, u as SnapshotData, x as SnapshotMatchOptions, y as SnapshotResult, w as SnapshotStateOptions, G as SnapshotSummary, v as SnapshotUpdateState, S as Suite, m as SuiteAPI, p as SuiteCollector, q as SuiteFactory, o as SuiteHooks, i as Task, f as TaskBase, g as TaskResult, T as TaskResultPack, e as TaskState, h as Test, l as TestAPI, s as TestContext, j as TestFunction, k as TestOptions, z as UncheckedSnapshot, U as UserConfig, a4 as UserConsoleLog, t as Vitest, V as VitestEnvironment, c as VitestRunMode, W as WorkerContext, O as WorkerGlobalState, N as WorkerRPC } from './global-
|
|
1
|
+
export { E as EnhancedSpy, r as Mock, u as MockContext, q as MockInstance, v as Mocked, w as MockedClass, o as MockedFunction, p as MockedObject, S as SpyInstance, j as afterAll, l as afterEach, h as beforeAll, k as beforeEach, n as createExpect, e as describe, m as expect, i as it, d as suite, t as test } from './index-220c1d70.js';
|
|
2
|
+
import { R as ResolvedConfig } from './global-58e8e951.js';
|
|
3
|
+
export { L as AfterSuiteRunMeta, A as ApiConfig, Y as ArgumentsType, X as Arrayable, P as Awaitable, ae as BaseCoverageOptions, ak as BenchFunction, ai as Benchmark, al as BenchmarkAPI, aj as BenchmarkResult, ah as BenchmarkUserOptions, B as BuiltinEnvironment, C as CSSModuleScopeStrategy, a0 as Constructable, ag as CoverageC8Options, af as CoverageIstanbulOptions, ac as CoverageOptions, a9 as CoverageProvider, aa as CoverageProviderModule, ab as CoverageReporter, _ as DeepMerge, D as DoneCallback, a3 as Environment, E as EnvironmentOptions, a2 as EnvironmentReturn, a7 as ErrorWithDiff, a as File, n as HookCleanupCallback, H as HookListener, I as InlineConfig, J as JSDOMOptions, Z as MergeInsertions, a1 as ModuleCache, M as ModuleGraphData, $ as MutableArray, Q as Nullable, a8 as OnServerRestartHandler, a6 as ParsedStack, a5 as Position, b as Reporter, K as ResolveIdFunction, R as ResolvedConfig, ad as ResolvedCoverageOptions, d as RunMode, r as RuntimeContext, u as SnapshotData, x as SnapshotMatchOptions, y as SnapshotResult, w as SnapshotStateOptions, G as SnapshotSummary, v as SnapshotUpdateState, S as Suite, m as SuiteAPI, p as SuiteCollector, q as SuiteFactory, o as SuiteHooks, i as Task, f as TaskBase, g as TaskResult, T as TaskResultPack, e as TaskState, h as Test, l as TestAPI, s as TestContext, j as TestFunction, k as TestOptions, z as UncheckedSnapshot, U as UserConfig, a4 as UserConsoleLog, t as Vitest, V as VitestEnvironment, c as VitestRunMode, W as WorkerContext, O as WorkerGlobalState, N as WorkerRPC } from './global-58e8e951.js';
|
|
4
4
|
import * as chai from 'chai';
|
|
5
5
|
export { chai };
|
|
6
6
|
export { assert, should } from 'chai';
|
package/dist/browser.js
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
|
-
export { c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.
|
|
2
|
-
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach } from './chunk-runtime-hooks.
|
|
3
|
-
export { a as setupGlobalEnv, s as startTests } from './chunk-runtime-
|
|
1
|
+
export { c as createExpect, d as describe, e as expect, i as it, s as suite, t as test } from './chunk-runtime-chain.37ec5d73.js';
|
|
2
|
+
export { a as afterAll, d as afterEach, b as beforeAll, c as beforeEach } from './chunk-runtime-hooks.d748b085.js';
|
|
3
|
+
export { a as setupGlobalEnv, s as startTests } from './chunk-runtime-setup.ab6b6274.js';
|
|
4
4
|
import * as chai from 'chai';
|
|
5
5
|
export { chai };
|
|
6
6
|
export { assert, should } from 'chai';
|
|
7
7
|
import 'util';
|
|
8
|
-
import './chunk-mock-date.
|
|
8
|
+
import './chunk-mock-date.030959d3.js';
|
|
9
9
|
import 'path';
|
|
10
10
|
import './chunk-utils-env.b1281522.js';
|
|
11
11
|
import 'tty';
|
|
12
12
|
import 'url';
|
|
13
13
|
import 'local-pkg';
|
|
14
14
|
import './vendor-_commonjsHelpers.addc3445.js';
|
|
15
|
-
import './chunk-runtime-rpc.
|
|
16
|
-
import './chunk-utils-timers.
|
|
15
|
+
import './chunk-runtime-rpc.b418c0ab.js';
|
|
16
|
+
import './chunk-utils-timers.8fca243e.js';
|
|
17
17
|
import 'fs';
|
|
18
|
-
import './chunk-utils-source-map.
|
|
18
|
+
import './chunk-utils-source-map.663e2952.js';
|
|
19
19
|
import './spy.js';
|
|
20
20
|
import 'tinyspy';
|
|
21
21
|
import 'perf_hooks';
|
|
22
22
|
import './chunk-integrations-coverage.cca09977.js';
|
|
23
|
+
import './chunk-runtime-error.17751c39.js';
|
|
23
24
|
import './chunk-env-node.700b7e95.js';
|
|
24
25
|
import 'console';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { promises } from 'fs';
|
|
2
|
-
import { c as createBirpc } from './chunk-vite-node-client.
|
|
2
|
+
import { c as createBirpc } from './chunk-vite-node-client.3868b3ba.js';
|
|
3
3
|
import require$$0$1 from 'stream';
|
|
4
4
|
import require$$0 from 'zlib';
|
|
5
5
|
import require$$3 from 'net';
|
|
@@ -10,16 +10,16 @@ import require$$1 from 'https';
|
|
|
10
10
|
import require$$2$1 from 'http';
|
|
11
11
|
import url from 'url';
|
|
12
12
|
import { A as API_PATH } from './chunk-utils-env.b1281522.js';
|
|
13
|
-
import { i as interpretSourcePos, p as parseStacktrace } from './chunk-utils-source-map.
|
|
13
|
+
import { i as interpretSourcePos, p as parseStacktrace } from './chunk-utils-source-map.663e2952.js';
|
|
14
14
|
import 'module';
|
|
15
15
|
import 'vm';
|
|
16
|
-
import './chunk-vite-node-utils.
|
|
16
|
+
import './chunk-vite-node-utils.2144000e.js';
|
|
17
17
|
import 'path';
|
|
18
18
|
import 'assert';
|
|
19
19
|
import 'util';
|
|
20
20
|
import 'debug';
|
|
21
21
|
import 'tty';
|
|
22
|
-
import './chunk-mock-date.
|
|
22
|
+
import './chunk-mock-date.030959d3.js';
|
|
23
23
|
import 'local-pkg';
|
|
24
24
|
|
|
25
25
|
/*! (c) 2020 Andrea Giammarchi */
|
package/dist/{chunk-integrations-globals.10e6725a.js → chunk-integrations-globals.32ef80c3.js}
RENAMED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { m as globalApis } from './chunk-utils-env.b1281522.js';
|
|
2
|
-
import { i as index } from './chunk-runtime-hooks.
|
|
2
|
+
import { i as index } from './chunk-runtime-hooks.d748b085.js';
|
|
3
3
|
import 'tty';
|
|
4
4
|
import 'url';
|
|
5
5
|
import 'path';
|
|
6
|
-
import './chunk-runtime-chain.
|
|
6
|
+
import './chunk-runtime-chain.37ec5d73.js';
|
|
7
7
|
import 'util';
|
|
8
|
-
import './chunk-mock-date.
|
|
8
|
+
import './chunk-mock-date.030959d3.js';
|
|
9
9
|
import 'local-pkg';
|
|
10
10
|
import 'chai';
|
|
11
11
|
import './vendor-_commonjsHelpers.addc3445.js';
|
|
12
|
-
import './chunk-runtime-rpc.
|
|
13
|
-
import './chunk-utils-timers.
|
|
12
|
+
import './chunk-runtime-rpc.b418c0ab.js';
|
|
13
|
+
import './chunk-utils-timers.8fca243e.js';
|
|
14
14
|
import 'fs';
|
|
15
|
-
import './chunk-utils-source-map.
|
|
15
|
+
import './chunk-utils-source-map.663e2952.js';
|
|
16
16
|
import './spy.js';
|
|
17
17
|
import 'tinyspy';
|
|
18
18
|
|
|
@@ -326,4 +326,4 @@ function createDefer() {
|
|
|
326
326
|
return p;
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
-
export { AggregateErrorPonyfill as A, deepMerge as B, ensurePackageInstalled as C, stdout as D, mergeSlashes as E, getAllMockableProperties as F, RealDate as R, resetModules as a, getCallLastIndex as b, getNames as c, assertTypes as d, getFullName as e, isRunningInTest as f, getWorkerState as g, isRunningInBenchmark as h, isObject as i, notNullish as j,
|
|
329
|
+
export { AggregateErrorPonyfill as A, deepMerge as B, ensurePackageInstalled as C, stdout as D, mergeSlashes as E, getAllMockableProperties as F, RealDate as R, resetModules as a, getCallLastIndex as b, getNames as c, assertTypes as d, getFullName as e, isRunningInTest as f, getWorkerState as g, isRunningInBenchmark as h, isObject as i, notNullish as j, relativePath as k, shuffle as l, mockDate as m, noop as n, hasTests as o, partitionSuiteChildren as p, hasFailed as q, resetDate as r, slash as s, toArray as t, createDefer as u, deepClone as v, getType as w, getTests as x, hasFailedSnapshot as y, getSuites as z };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import util$1 from 'util';
|
|
2
|
-
import { i as isObject, b as getCallLastIndex, s as slash, g as getWorkerState, c as getNames, d as assertTypes, e as getFullName, n as noop, f as isRunningInTest, h as isRunningInBenchmark } from './chunk-mock-date.
|
|
2
|
+
import { i as isObject, b as getCallLastIndex, s as slash, g as getWorkerState, c as getNames, d as assertTypes, e as getFullName, n as noop, f as isRunningInTest, h as isRunningInBenchmark } from './chunk-mock-date.030959d3.js';
|
|
3
3
|
import * as chai$2 from 'chai';
|
|
4
4
|
import { expect, AssertionError, util } from 'chai';
|
|
5
5
|
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
|
|
6
|
-
import { r as rpc } from './chunk-runtime-rpc.
|
|
6
|
+
import { r as rpc } from './chunk-runtime-rpc.b418c0ab.js';
|
|
7
7
|
import fs, { promises } from 'fs';
|
|
8
8
|
import { j as join, d as dirname, p as picocolors } from './chunk-utils-env.b1281522.js';
|
|
9
|
-
import {
|
|
9
|
+
import { p as plugins_1, f as format_1, u as unifiedDiff, a as stringify, m as matcherUtils, s as safeSetTimeout, b as safeClearTimeout } from './chunk-utils-timers.8fca243e.js';
|
|
10
|
+
import { g as getOriginalPos, a as posToNumber, n as numberToPos, l as lineSplitRE, p as parseStacktrace } from './chunk-utils-source-map.663e2952.js';
|
|
10
11
|
import { isMockFunction } from './spy.js';
|
|
11
|
-
import { s as safeSetTimeout, a as safeClearTimeout } from './chunk-utils-timers.ab764c0c.js';
|
|
12
12
|
|
|
13
13
|
function createChainable(keys, fn) {
|
|
14
14
|
function create(context) {
|
|
@@ -1447,6 +1447,27 @@ ${spy.mock.calls.map((callArg, i) => {
|
|
|
1447
1447
|
}).join("\n")}`);
|
|
1448
1448
|
msg += picocolors.exports.gray(`
|
|
1449
1449
|
|
|
1450
|
+
Number of calls: ${picocolors.exports.bold(spy.mock.calls.length)}
|
|
1451
|
+
`);
|
|
1452
|
+
return msg;
|
|
1453
|
+
};
|
|
1454
|
+
const formatReturns = (spy, msg, actualReturn) => {
|
|
1455
|
+
msg += picocolors.exports.gray(`
|
|
1456
|
+
|
|
1457
|
+
Received:
|
|
1458
|
+
${spy.mock.results.map((callReturn, i) => {
|
|
1459
|
+
let methodCall = picocolors.exports.bold(` ${ordinalOf(i + 1)} ${spy.getMockName()} call return:
|
|
1460
|
+
|
|
1461
|
+
`);
|
|
1462
|
+
if (actualReturn)
|
|
1463
|
+
methodCall += unifiedDiff(stringify(callReturn.value), stringify(actualReturn), { showLegend: false });
|
|
1464
|
+
else
|
|
1465
|
+
methodCall += stringify(callReturn).split("\n").map((line) => ` ${line}`).join("\n");
|
|
1466
|
+
methodCall += "\n";
|
|
1467
|
+
return methodCall;
|
|
1468
|
+
}).join("\n")}`);
|
|
1469
|
+
msg += picocolors.exports.gray(`
|
|
1470
|
+
|
|
1450
1471
|
Number of calls: ${picocolors.exports.bold(spy.mock.calls.length)}
|
|
1451
1472
|
`);
|
|
1452
1473
|
return msg;
|
|
@@ -1628,12 +1649,22 @@ Number of calls: ${picocolors.exports.bold(spy.mock.calls.length)}
|
|
|
1628
1649
|
const spy = getSpy(this);
|
|
1629
1650
|
const spyName = spy.getMockName();
|
|
1630
1651
|
const pass = spy.mock.results.some(({ type, value: result }) => type === "return" && equals(value, result));
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1652
|
+
const isNot = utils.flag(this, "negate");
|
|
1653
|
+
let msg = utils.getMessage(
|
|
1654
|
+
this,
|
|
1655
|
+
[
|
|
1656
|
+
pass,
|
|
1657
|
+
`expected "${spyName}" to return with: #{exp} at least once`,
|
|
1658
|
+
`expected "${spyName}" to not return with: #{exp}`,
|
|
1659
|
+
value
|
|
1660
|
+
]
|
|
1636
1661
|
);
|
|
1662
|
+
if (pass && isNot || !pass && !isNot) {
|
|
1663
|
+
msg = formatReturns(spy, msg, value);
|
|
1664
|
+
const err = new Error(msg);
|
|
1665
|
+
err.name = "AssertionError";
|
|
1666
|
+
throw err;
|
|
1667
|
+
}
|
|
1637
1668
|
});
|
|
1638
1669
|
def(["toHaveLastReturnedWith", "lastReturnedWith"], function(value) {
|
|
1639
1670
|
const spy = getSpy(this);
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import util$1 from 'util';
|
|
2
|
+
import { util } from 'chai';
|
|
3
|
+
import { a as stringify } from './chunk-utils-timers.8fca243e.js';
|
|
4
|
+
import { v as deepClone, w as getType } from './chunk-mock-date.030959d3.js';
|
|
5
|
+
|
|
6
|
+
const OBJECT_PROTO = Object.getPrototypeOf({});
|
|
7
|
+
function getUnserializableMessage(err) {
|
|
8
|
+
if (err instanceof Error)
|
|
9
|
+
return `<unserializable>: ${err.message}`;
|
|
10
|
+
if (typeof err === "string")
|
|
11
|
+
return `<unserializable>: ${err}`;
|
|
12
|
+
return "<unserializable>";
|
|
13
|
+
}
|
|
14
|
+
function serializeError(val, seen = /* @__PURE__ */ new WeakMap()) {
|
|
15
|
+
if (!val || typeof val === "string")
|
|
16
|
+
return val;
|
|
17
|
+
if (typeof val === "function")
|
|
18
|
+
return `Function<${val.name}>`;
|
|
19
|
+
if (typeof val !== "object")
|
|
20
|
+
return val;
|
|
21
|
+
if (val instanceof Promise || val.constructor && val.constructor.prototype === "AsyncFunction")
|
|
22
|
+
return "Promise";
|
|
23
|
+
if (typeof Element !== "undefined" && val instanceof Element)
|
|
24
|
+
return val.tagName;
|
|
25
|
+
if (typeof val.asymmetricMatch === "function")
|
|
26
|
+
return `${val.toString()} ${util$1.format(val.sample)}`;
|
|
27
|
+
if (seen.has(val))
|
|
28
|
+
return seen.get(val);
|
|
29
|
+
if (Array.isArray(val)) {
|
|
30
|
+
const clone = new Array(val.length);
|
|
31
|
+
seen.set(val, clone);
|
|
32
|
+
val.forEach((e, i) => {
|
|
33
|
+
try {
|
|
34
|
+
clone[i] = serializeError(e, seen);
|
|
35
|
+
} catch (err) {
|
|
36
|
+
clone[i] = getUnserializableMessage(err);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return clone;
|
|
40
|
+
} else {
|
|
41
|
+
const clone = /* @__PURE__ */ Object.create(null);
|
|
42
|
+
seen.set(val, clone);
|
|
43
|
+
let obj = val;
|
|
44
|
+
while (obj && obj !== OBJECT_PROTO) {
|
|
45
|
+
Object.getOwnPropertyNames(obj).forEach((key) => {
|
|
46
|
+
if (key in clone)
|
|
47
|
+
return;
|
|
48
|
+
try {
|
|
49
|
+
clone[key] = serializeError(val[key], seen);
|
|
50
|
+
} catch (err) {
|
|
51
|
+
delete clone[key];
|
|
52
|
+
clone[key] = getUnserializableMessage(err);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
obj = Object.getPrototypeOf(obj);
|
|
56
|
+
}
|
|
57
|
+
return clone;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function normalizeErrorMessage(message) {
|
|
61
|
+
return message.replace(/__vite_ssr_import_\d+__\./g, "");
|
|
62
|
+
}
|
|
63
|
+
function processError(err) {
|
|
64
|
+
if (!err || typeof err !== "object")
|
|
65
|
+
return err;
|
|
66
|
+
if (err.stack)
|
|
67
|
+
err.stackStr = String(err.stack);
|
|
68
|
+
if (err.name)
|
|
69
|
+
err.nameStr = String(err.name);
|
|
70
|
+
const clonedActual = deepClone(err.actual);
|
|
71
|
+
const clonedExpected = deepClone(err.expected);
|
|
72
|
+
const { replacedActual, replacedExpected } = replaceAsymmetricMatcher(clonedActual, clonedExpected);
|
|
73
|
+
err.actual = replacedActual;
|
|
74
|
+
err.expected = replacedExpected;
|
|
75
|
+
if (typeof err.expected !== "string")
|
|
76
|
+
err.expected = stringify(err.expected);
|
|
77
|
+
if (typeof err.actual !== "string")
|
|
78
|
+
err.actual = stringify(err.actual);
|
|
79
|
+
try {
|
|
80
|
+
if (typeof err.message === "string")
|
|
81
|
+
err.message = normalizeErrorMessage(err.message);
|
|
82
|
+
if (typeof err.cause === "object" && typeof err.cause.message === "string")
|
|
83
|
+
err.cause.message = normalizeErrorMessage(err.cause.message);
|
|
84
|
+
} catch {
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
return serializeError(err);
|
|
88
|
+
} catch (e) {
|
|
89
|
+
return serializeError(new Error(`Failed to fully serialize error: ${e == null ? void 0 : e.message}
|
|
90
|
+
Inner error message: ${err == null ? void 0 : err.message}`));
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function isAsymmetricMatcher(data) {
|
|
94
|
+
const type = getType(data);
|
|
95
|
+
return type === "Object" && typeof data.asymmetricMatch === "function";
|
|
96
|
+
}
|
|
97
|
+
function isReplaceable(obj1, obj2) {
|
|
98
|
+
const obj1Type = getType(obj1);
|
|
99
|
+
const obj2Type = getType(obj2);
|
|
100
|
+
return obj1Type === obj2Type && obj1Type === "Object";
|
|
101
|
+
}
|
|
102
|
+
function replaceAsymmetricMatcher(actual, expected, actualReplaced = /* @__PURE__ */ new WeakMap(), expectedReplaced = /* @__PURE__ */ new WeakMap()) {
|
|
103
|
+
if (!isReplaceable(actual, expected))
|
|
104
|
+
return { replacedActual: actual, replacedExpected: expected };
|
|
105
|
+
if (actualReplaced.has(actual) || expectedReplaced.has(expected))
|
|
106
|
+
return { replacedActual: actual, replacedExpected: expected };
|
|
107
|
+
actualReplaced.set(actual, true);
|
|
108
|
+
expectedReplaced.set(expected, true);
|
|
109
|
+
util.getOwnEnumerableProperties(expected).forEach((key) => {
|
|
110
|
+
const expectedValue = expected[key];
|
|
111
|
+
const actualValue = actual[key];
|
|
112
|
+
if (isAsymmetricMatcher(expectedValue)) {
|
|
113
|
+
if (expectedValue.asymmetricMatch(actualValue))
|
|
114
|
+
actual[key] = expectedValue;
|
|
115
|
+
} else if (isAsymmetricMatcher(actualValue)) {
|
|
116
|
+
if (actualValue.asymmetricMatch(expectedValue))
|
|
117
|
+
expected[key] = actualValue;
|
|
118
|
+
} else if (isReplaceable(actualValue, expectedValue)) {
|
|
119
|
+
const replaced = replaceAsymmetricMatcher(
|
|
120
|
+
actualValue,
|
|
121
|
+
expectedValue,
|
|
122
|
+
actualReplaced,
|
|
123
|
+
expectedReplaced
|
|
124
|
+
);
|
|
125
|
+
actual[key] = replaced.replacedActual;
|
|
126
|
+
expected[key] = replaced.replacedExpected;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
return {
|
|
130
|
+
replacedActual: actual,
|
|
131
|
+
replacedExpected: expected
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export { processError as p };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it, b as bench, c as createExpect, e as globalExpect } from './chunk-runtime-chain.
|
|
2
|
-
import { g as getWorkerState, R as RealDate, r as resetDate, m as mockDate, a as resetModules } from './chunk-mock-date.
|
|
3
|
-
import { p as parseStacktrace } from './chunk-utils-source-map.
|
|
1
|
+
import { g as getCurrentSuite, w as withTimeout, a as getDefaultHookTimeout, s as suite, t as test, d as describe, i as it, b as bench, c as createExpect, e as globalExpect } from './chunk-runtime-chain.37ec5d73.js';
|
|
2
|
+
import { g as getWorkerState, R as RealDate, r as resetDate, m as mockDate, a as resetModules } from './chunk-mock-date.030959d3.js';
|
|
3
|
+
import { p as parseStacktrace } from './chunk-utils-source-map.663e2952.js';
|
|
4
4
|
import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
|
|
5
5
|
import util from 'util';
|
|
6
6
|
import { spyOn, fn, isMockFunction, spies } from './spy.js';
|
|
7
|
-
import { s as safeSetTimeout } from './chunk-utils-timers.
|
|
7
|
+
import { s as safeSetTimeout } from './chunk-utils-timers.8fca243e.js';
|
|
8
8
|
import * as chai from 'chai';
|
|
9
9
|
import { assert, should } from 'chai';
|
|
10
10
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { V as ViteNodeRunner } from './chunk-vite-node-client.
|
|
1
|
+
import { V as ViteNodeRunner } from './chunk-vite-node-client.3868b3ba.js';
|
|
2
2
|
import { normalizePath } from 'vite';
|
|
3
|
-
import { g as getWorkerState, E as mergeSlashes, s as slash,
|
|
3
|
+
import { g as getWorkerState, E as mergeSlashes, s as slash, w as getType, F as getAllMockableProperties } from './chunk-mock-date.030959d3.js';
|
|
4
4
|
import { existsSync, readdirSync } from 'fs';
|
|
5
|
-
import { n as normalizeRequestId, p as pathFromRoot, i as isNodeBuiltin, b as toFilePath } from './chunk-vite-node-utils.
|
|
5
|
+
import { n as normalizeRequestId, p as pathFromRoot, i as isNodeBuiltin, b as toFilePath } from './chunk-vite-node-utils.2144000e.js';
|
|
6
6
|
import { d as dirname, j as join, c as basename, l as extname, b as resolve, e as distDir } from './chunk-utils-env.b1281522.js';
|
|
7
7
|
|
|
8
8
|
class RefTracker {
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { g as getWorkerState } from './chunk-mock-date.030959d3.js';
|
|
2
|
+
import { s as safeSetTimeout } from './chunk-utils-timers.8fca243e.js';
|
|
3
|
+
|
|
4
|
+
const safeRandom = Math.random;
|
|
5
|
+
function withSafeTimers(fn) {
|
|
6
|
+
const currentSetTimeout = globalThis.setTimeout;
|
|
7
|
+
const currentRandom = globalThis.Math.random;
|
|
8
|
+
try {
|
|
9
|
+
globalThis.setTimeout = safeSetTimeout;
|
|
10
|
+
globalThis.Math.random = safeRandom;
|
|
11
|
+
const result = fn();
|
|
12
|
+
return result;
|
|
13
|
+
} finally {
|
|
14
|
+
globalThis.setTimeout = currentSetTimeout;
|
|
15
|
+
globalThis.Math.random = currentRandom;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const rpc = () => {
|
|
19
|
+
const { rpc: rpc2 } = getWorkerState();
|
|
20
|
+
return new Proxy(rpc2, {
|
|
21
|
+
get(target, p, handler) {
|
|
22
|
+
const sendCall = Reflect.get(target, p, handler);
|
|
23
|
+
const safeSendCall = (...args) => withSafeTimers(() => sendCall(...args));
|
|
24
|
+
safeSendCall.asEvent = sendCall.asEvent;
|
|
25
|
+
return safeSendCall;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export { rpc as r };
|
|
@@ -1,144 +1,13 @@
|
|
|
1
1
|
import { performance } from 'perf_hooks';
|
|
2
2
|
import { t as takeCoverageInsideWorker, p as pLimit } from './chunk-integrations-coverage.cca09977.js';
|
|
3
|
-
import { r as resetRunOnceCounter, i as index, v as vi } from './chunk-runtime-hooks.
|
|
4
|
-
import {
|
|
5
|
-
import { f as clearCollectorContext, h as defaultSuite, j as setHooks, k as getHooks, l as collectorContext, m as getFn, n as setState, G as GLOBAL_EXPECT, o as getState } from './chunk-runtime-chain.
|
|
6
|
-
import { r as rpc } from './chunk-runtime-rpc.
|
|
7
|
-
import
|
|
8
|
-
import { util } from 'chai';
|
|
9
|
-
import { s as stringify } from './chunk-utils-source-map.d9d36eb0.js';
|
|
3
|
+
import { r as resetRunOnceCounter, i as index, v as vi } from './chunk-runtime-hooks.d748b085.js';
|
|
4
|
+
import { g as getWorkerState, R as RealDate, t as toArray, k as relativePath, h as isRunningInBenchmark, p as partitionSuiteChildren, l as shuffle, o as hasTests, q as hasFailed, u as createDefer, d as assertTypes, e as getFullName } from './chunk-mock-date.030959d3.js';
|
|
5
|
+
import { f as clearCollectorContext, h as defaultSuite, j as setHooks, k as getHooks, l as collectorContext, m as getFn, n as setState, G as GLOBAL_EXPECT, o as getState } from './chunk-runtime-chain.37ec5d73.js';
|
|
6
|
+
import { r as rpc } from './chunk-runtime-rpc.b418c0ab.js';
|
|
7
|
+
import { p as processError } from './chunk-runtime-error.17751c39.js';
|
|
10
8
|
import { e as environments } from './chunk-env-node.700b7e95.js';
|
|
11
9
|
import { i as isNode, a as isBrowser } from './chunk-utils-env.b1281522.js';
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
-
const OBJECT_PROTO = Object.getPrototypeOf({});
|
|
15
|
-
function getUnserializableMessage(err) {
|
|
16
|
-
if (err instanceof Error)
|
|
17
|
-
return `<unserializable>: ${err.message}`;
|
|
18
|
-
if (typeof err === "string")
|
|
19
|
-
return `<unserializable>: ${err}`;
|
|
20
|
-
return "<unserializable>";
|
|
21
|
-
}
|
|
22
|
-
function serializeError(val, seen = /* @__PURE__ */ new WeakMap()) {
|
|
23
|
-
if (!val || typeof val === "string")
|
|
24
|
-
return val;
|
|
25
|
-
if (typeof val === "function")
|
|
26
|
-
return `Function<${val.name}>`;
|
|
27
|
-
if (typeof val !== "object")
|
|
28
|
-
return val;
|
|
29
|
-
if (val instanceof Promise || val.constructor && val.constructor.prototype === "AsyncFunction")
|
|
30
|
-
return "Promise";
|
|
31
|
-
if (typeof Element !== "undefined" && val instanceof Element)
|
|
32
|
-
return val.tagName;
|
|
33
|
-
if (typeof val.asymmetricMatch === "function")
|
|
34
|
-
return `${val.toString()} ${util$1.format(val.sample)}`;
|
|
35
|
-
if (seen.has(val))
|
|
36
|
-
return seen.get(val);
|
|
37
|
-
if (Array.isArray(val)) {
|
|
38
|
-
const clone = new Array(val.length);
|
|
39
|
-
seen.set(val, clone);
|
|
40
|
-
val.forEach((e, i) => {
|
|
41
|
-
try {
|
|
42
|
-
clone[i] = serializeError(e, seen);
|
|
43
|
-
} catch (err) {
|
|
44
|
-
clone[i] = getUnserializableMessage(err);
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
return clone;
|
|
48
|
-
} else {
|
|
49
|
-
const clone = /* @__PURE__ */ Object.create(null);
|
|
50
|
-
seen.set(val, clone);
|
|
51
|
-
let obj = val;
|
|
52
|
-
while (obj && obj !== OBJECT_PROTO) {
|
|
53
|
-
Object.getOwnPropertyNames(obj).forEach((key) => {
|
|
54
|
-
if (key in clone)
|
|
55
|
-
return;
|
|
56
|
-
try {
|
|
57
|
-
clone[key] = serializeError(obj[key], seen);
|
|
58
|
-
} catch (err) {
|
|
59
|
-
delete clone[key];
|
|
60
|
-
clone[key] = getUnserializableMessage(err);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
obj = Object.getPrototypeOf(obj);
|
|
64
|
-
}
|
|
65
|
-
return clone;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function normalizeErrorMessage(message) {
|
|
69
|
-
return message.replace(/__vite_ssr_import_\d+__\./g, "");
|
|
70
|
-
}
|
|
71
|
-
function processError(err) {
|
|
72
|
-
if (!err || typeof err !== "object")
|
|
73
|
-
return err;
|
|
74
|
-
if (err.stack)
|
|
75
|
-
err.stackStr = String(err.stack);
|
|
76
|
-
if (err.name)
|
|
77
|
-
err.nameStr = String(err.name);
|
|
78
|
-
const clonedActual = deepClone(err.actual);
|
|
79
|
-
const clonedExpected = deepClone(err.expected);
|
|
80
|
-
const { replacedActual, replacedExpected } = replaceAsymmetricMatcher(clonedActual, clonedExpected);
|
|
81
|
-
err.actual = replacedActual;
|
|
82
|
-
err.expected = replacedExpected;
|
|
83
|
-
if (typeof err.expected !== "string")
|
|
84
|
-
err.expected = stringify(err.expected);
|
|
85
|
-
if (typeof err.actual !== "string")
|
|
86
|
-
err.actual = stringify(err.actual);
|
|
87
|
-
try {
|
|
88
|
-
if (typeof err.message === "string")
|
|
89
|
-
err.message = normalizeErrorMessage(err.message);
|
|
90
|
-
if (typeof err.cause === "object" && typeof err.cause.message === "string")
|
|
91
|
-
err.cause.message = normalizeErrorMessage(err.cause.message);
|
|
92
|
-
} catch {
|
|
93
|
-
}
|
|
94
|
-
try {
|
|
95
|
-
return serializeError(err);
|
|
96
|
-
} catch (e) {
|
|
97
|
-
return serializeError(new Error(`Failed to fully serialize error: ${e == null ? void 0 : e.message}
|
|
98
|
-
Inner error message: ${err == null ? void 0 : err.message}`));
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
function isAsymmetricMatcher(data) {
|
|
102
|
-
const type = getType(data);
|
|
103
|
-
return type === "Object" && typeof data.asymmetricMatch === "function";
|
|
104
|
-
}
|
|
105
|
-
function isReplaceable(obj1, obj2) {
|
|
106
|
-
const obj1Type = getType(obj1);
|
|
107
|
-
const obj2Type = getType(obj2);
|
|
108
|
-
return obj1Type === obj2Type && obj1Type === "Object";
|
|
109
|
-
}
|
|
110
|
-
function replaceAsymmetricMatcher(actual, expected, actualReplaced = /* @__PURE__ */ new WeakMap(), expectedReplaced = /* @__PURE__ */ new WeakMap()) {
|
|
111
|
-
if (!isReplaceable(actual, expected))
|
|
112
|
-
return { replacedActual: actual, replacedExpected: expected };
|
|
113
|
-
if (actualReplaced.has(actual) || expectedReplaced.has(expected))
|
|
114
|
-
return { replacedActual: actual, replacedExpected: expected };
|
|
115
|
-
actualReplaced.set(actual, true);
|
|
116
|
-
expectedReplaced.set(expected, true);
|
|
117
|
-
util.getOwnEnumerableProperties(expected).forEach((key) => {
|
|
118
|
-
const expectedValue = expected[key];
|
|
119
|
-
const actualValue = actual[key];
|
|
120
|
-
if (isAsymmetricMatcher(expectedValue)) {
|
|
121
|
-
if (expectedValue.asymmetricMatch(actualValue))
|
|
122
|
-
actual[key] = expectedValue;
|
|
123
|
-
} else if (isAsymmetricMatcher(actualValue)) {
|
|
124
|
-
if (actualValue.asymmetricMatch(expectedValue))
|
|
125
|
-
expected[key] = actualValue;
|
|
126
|
-
} else if (isReplaceable(actualValue, expectedValue)) {
|
|
127
|
-
const replaced = replaceAsymmetricMatcher(
|
|
128
|
-
actualValue,
|
|
129
|
-
expectedValue,
|
|
130
|
-
actualReplaced,
|
|
131
|
-
expectedReplaced
|
|
132
|
-
);
|
|
133
|
-
actual[key] = replaced.replacedActual;
|
|
134
|
-
expected[key] = replaced.replacedExpected;
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
return {
|
|
138
|
-
replacedActual: actual,
|
|
139
|
-
replacedExpected: expected
|
|
140
|
-
};
|
|
141
|
-
}
|
|
10
|
+
import { b as safeClearTimeout, s as safeSetTimeout } from './chunk-utils-timers.8fca243e.js';
|
|
142
11
|
|
|
143
12
|
let globalSetup = false;
|
|
144
13
|
async function setupGlobalEnv(config) {
|
|
@@ -155,7 +24,7 @@ async function setupGlobalEnv(config) {
|
|
|
155
24
|
if (isNode)
|
|
156
25
|
await setupConsoleLogSpy();
|
|
157
26
|
if (config.globals)
|
|
158
|
-
(await import('./chunk-integrations-globals.
|
|
27
|
+
(await import('./chunk-integrations-globals.32ef80c3.js')).registerApiGlobally();
|
|
159
28
|
}
|
|
160
29
|
function setupDefines(defines) {
|
|
161
30
|
for (const key in defines)
|
|
@@ -499,7 +368,7 @@ const callCleanupHooks = async (cleanups) => {
|
|
|
499
368
|
async function runTest(test) {
|
|
500
369
|
var _a, _b;
|
|
501
370
|
if (test.mode !== "run") {
|
|
502
|
-
const { getSnapshotClient } = await import('./chunk-runtime-chain.
|
|
371
|
+
const { getSnapshotClient } = await import('./chunk-runtime-chain.37ec5d73.js').then(function (n) { return n.q; });
|
|
503
372
|
getSnapshotClient().skipTestSnapshots(test);
|
|
504
373
|
return;
|
|
505
374
|
}
|
|
@@ -515,7 +384,7 @@ async function runTest(test) {
|
|
|
515
384
|
updateTask(test);
|
|
516
385
|
clearModuleMocks();
|
|
517
386
|
if (isNode) {
|
|
518
|
-
const { getSnapshotClient } = await import('./chunk-runtime-chain.
|
|
387
|
+
const { getSnapshotClient } = await import('./chunk-runtime-chain.37ec5d73.js').then(function (n) { return n.q; });
|
|
519
388
|
await getSnapshotClient().setTest(test);
|
|
520
389
|
}
|
|
521
390
|
const workerState = getWorkerState();
|
|
@@ -575,7 +444,7 @@ async function runTest(test) {
|
|
|
575
444
|
if (isBrowser && test.result.error)
|
|
576
445
|
console.error(test.result.error.message, test.result.error.stackStr);
|
|
577
446
|
if (isNode) {
|
|
578
|
-
const { getSnapshotClient } = await import('./chunk-runtime-chain.
|
|
447
|
+
const { getSnapshotClient } = await import('./chunk-runtime-chain.37ec5d73.js').then(function (n) { return n.q; });
|
|
579
448
|
getSnapshotClient().clearTest();
|
|
580
449
|
}
|
|
581
450
|
test.result.duration = now() - start;
|
|
@@ -780,7 +649,7 @@ async function startTestsBrowser(paths, config) {
|
|
|
780
649
|
async function startTestsNode(paths, config) {
|
|
781
650
|
const files = await collectTests(paths, config);
|
|
782
651
|
rpc().onCollected(files);
|
|
783
|
-
const { getSnapshotClient } = await import('./chunk-runtime-chain.
|
|
652
|
+
const { getSnapshotClient } = await import('./chunk-runtime-chain.37ec5d73.js').then(function (n) { return n.q; });
|
|
784
653
|
getSnapshotClient().clear();
|
|
785
654
|
await runFiles(files, config);
|
|
786
655
|
const coverage = await takeCoverageInsideWorker(config.coverage);
|