@antdv-next/x-sdk 0.0.3 → 0.0.4
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/chat-providers/types/model.d.ts +1 -1
- package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js +76 -0
- package/dist/node_modules/.pnpm/{@voidzero-dev_vite-plus-test@0.1.14_@types_node@24.12.0_@voidzero-dev_vite-plus-core@0._0c620f79340a656256b2ffe23b3e6dd1/node_modules/@voidzero-dev/vite-plus-test/dist/@vitest/expect → @vitest_expect@4.1.10/node_modules/@vitest/expect/dist}/index.js +53 -39
- package/dist/node_modules/.pnpm/{@voidzero-dev_vite-plus-test@0.1.14_@types_node@24.12.0_@voidzero-dev_vite-plus-core@0._0c620f79340a656256b2ffe23b3e6dd1/node_modules/@voidzero-dev/vite-plus-test/dist/@vitest/pretty-format → @vitest_pretty-format@4.1.10/node_modules/@vitest/pretty-format/dist}/index.js +7 -6
- package/dist/node_modules/.pnpm/{@voidzero-dev_vite-plus-test@0.1.14_@types_node@24.12.0_@voidzero-dev_vite-plus-core@0._0c620f79340a656256b2ffe23b3e6dd1/node_modules/@voidzero-dev/vite-plus-test/dist/@vitest/runner → @vitest_runner@4.1.10/node_modules/@vitest/runner/dist}/chunk-artifact.js +14 -7
- package/dist/node_modules/.pnpm/@vitest_runner@4.1.10/node_modules/@vitest/runner/dist/index.js +2 -0
- package/dist/node_modules/.pnpm/@vitest_runner@4.1.10/node_modules/@vitest/runner/dist/utils.js +2 -0
- package/dist/node_modules/.pnpm/{@voidzero-dev_vite-plus-test@0.1.14_@types_node@24.12.0_@voidzero-dev_vite-plus-core@0._0c620f79340a656256b2ffe23b3e6dd1/node_modules/@voidzero-dev/vite-plus-test/dist/@vitest/snapshot → @vitest_snapshot@4.1.10/node_modules/@vitest/snapshot/dist}/index.js +451 -192
- package/dist/node_modules/.pnpm/{@voidzero-dev_vite-plus-test@0.1.14_@types_node@24.12.0_@voidzero-dev_vite-plus-core@0._0c620f79340a656256b2ffe23b3e6dd1/node_modules/@voidzero-dev/vite-plus-test/dist/@vitest/spy → @vitest_spy@4.1.10/node_modules/@vitest/spy/dist}/index.js +1 -1
- package/dist/node_modules/.pnpm/{@voidzero-dev_vite-plus-test@0.1.14_@types_node@24.12.0_@voidzero-dev_vite-plus-core@0._0c620f79340a656256b2ffe23b3e6dd1/node_modules/@voidzero-dev/vite-plus-test/dist/@vitest/utils → @vitest_utils@4.1.10/node_modules/@vitest/utils/dist}/chunk-pathe.M-eThtNZ.js +1 -1
- package/dist/node_modules/.pnpm/{@voidzero-dev_vite-plus-test@0.1.14_@types_node@24.12.0_@voidzero-dev_vite-plus-core@0._0c620f79340a656256b2ffe23b3e6dd1/node_modules/@voidzero-dev/vite-plus-test/dist/@vitest/utils → @vitest_utils@4.1.10/node_modules/@vitest/utils/dist}/diff.js +39 -29
- package/dist/node_modules/.pnpm/{@voidzero-dev_vite-plus-test@0.1.14_@types_node@24.12.0_@voidzero-dev_vite-plus-core@0._0c620f79340a656256b2ffe23b3e6dd1/node_modules/@voidzero-dev/vite-plus-test/dist/@vitest/utils → @vitest_utils@4.1.10/node_modules/@vitest/utils/dist}/display.js +2 -2
- package/dist/node_modules/.pnpm/@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/error.js +34 -0
- package/dist/node_modules/.pnpm/{@voidzero-dev_vite-plus-test@0.1.14_@types_node@24.12.0_@voidzero-dev_vite-plus-core@0._0c620f79340a656256b2ffe23b3e6dd1/node_modules/@voidzero-dev/vite-plus-test/dist/@vitest/utils → @vitest_utils@4.1.10/node_modules/@vitest/utils/dist}/helpers.js +1 -1
- package/dist/node_modules/.pnpm/{@voidzero-dev_vite-plus-test@0.1.14_@types_node@24.12.0_@voidzero-dev_vite-plus-core@0._0c620f79340a656256b2ffe23b3e6dd1/node_modules/@voidzero-dev/vite-plus-test/dist/@vitest/utils → @vitest_utils@4.1.10/node_modules/@vitest/utils/dist}/offset.js +1 -1
- package/dist/node_modules/.pnpm/{@voidzero-dev_vite-plus-test@0.1.14_@types_node@24.12.0_@voidzero-dev_vite-plus-core@0._0c620f79340a656256b2ffe23b3e6dd1/node_modules/@voidzero-dev/vite-plus-test/dist/@vitest/utils → @vitest_utils@4.1.10/node_modules/@vitest/utils/dist}/serialize.js +1 -1
- package/dist/node_modules/.pnpm/{@voidzero-dev_vite-plus-test@0.1.14_@types_node@24.12.0_@voidzero-dev_vite-plus-core@0._0c620f79340a656256b2ffe23b3e6dd1/node_modules/@voidzero-dev/vite-plus-test/dist/@vitest/utils → @vitest_utils@4.1.10/node_modules/@vitest/utils/dist}/source-map.js +2 -2
- package/dist/node_modules/.pnpm/{@voidzero-dev_vite-plus-test@0.1.14_@types_node@24.12.0_@voidzero-dev_vite-plus-core@0._0c620f79340a656256b2ffe23b3e6dd1/node_modules/@voidzero-dev/vite-plus-test/dist/@vitest/utils → @vitest_utils@4.1.10/node_modules/@vitest/utils/dist}/timers.js +1 -1
- package/dist/node_modules/.pnpm/{@voidzero-dev_vite-plus-test@0.1.14_@types_node@24.12.0_@voidzero-dev_vite-plus-core@0._0c620f79340a656256b2ffe23b3e6dd1/node_modules/@voidzero-dev/vite-plus-test/dist/vendor/chai.js → chai@6.2.2/node_modules/chai/index.js} +102 -2
- package/dist/node_modules/.pnpm/{@voidzero-dev_vite-plus-test@0.1.14_@types_node@24.12.0_@voidzero-dev_vite-plus-core@0._0c620f79340a656256b2ffe23b3e6dd1/node_modules/@voidzero-dev/vite-plus-test/dist/vendor/magic-string.js → magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.js} +3 -75
- package/dist/node_modules/.pnpm/tinyrainbow@3.1.1/node_modules/tinyrainbow/dist/index.js +84 -0
- package/dist/node_modules/.pnpm/vitest@4.1.10_@types_node@24.12.0_@vitest_browser-preview@4.1.10_@vitest_coverage-v8@4._55bf307888d746e7433721e12ae091d9/node_modules/vitest/dist/chunks/_commonjsHelpers.D26ty3Ew.js +4 -0
- package/dist/node_modules/.pnpm/{@voidzero-dev_vite-plus-test@0.1.14_@types_node@24.12.0_@voidzero-dev_vite-plus-core@0._0c620f79340a656256b2ffe23b3e6dd1/node_modules/@voidzero-dev/vite-plus-test → vitest@4.1.10_@types_node@24.12.0_@vitest_browser-preview@4.1.10_@vitest_coverage-v8@4._55bf307888d746e7433721e12ae091d9/node_modules/vitest}/dist/chunks/rpc.MzXet3jl.js +1 -1
- package/dist/node_modules/.pnpm/{@voidzero-dev_vite-plus-test@0.1.14_@types_node@24.12.0_@voidzero-dev_vite-plus-core@0._0c620f79340a656256b2ffe23b3e6dd1/node_modules/@voidzero-dev/vite-plus-test/dist/chunks/test.CBQUpOM3.js → vitest@4.1.10_@types_node@24.12.0_@vitest_browser-preview@4.1.10_@vitest_coverage-v8@4._55bf307888d746e7433721e12ae091d9/node_modules/vitest/dist/chunks/test.DNmyFkvJ.js} +369 -318
- package/dist/node_modules/.pnpm/{@voidzero-dev_vite-plus-test@0.1.14_@types_node@24.12.0_@voidzero-dev_vite-plus-core@0._0c620f79340a656256b2ffe23b3e6dd1/node_modules/@voidzero-dev/vite-plus-test → vitest@4.1.10_@types_node@24.12.0_@vitest_browser-preview@4.1.10_@vitest_coverage-v8@4._55bf307888d746e7433721e12ae091d9/node_modules/vitest}/dist/chunks/utils.BX5Fg8C4.js +2 -2
- package/dist/x-chat/__tests__/index.test.js +2 -2
- package/dist/x-conversations/__tests__/index.test.js +2 -2
- package/dist/x-request/__tests__/index.test.js +2 -2
- package/dist/x-stream/__tests__/index.test.js +2 -2
- package/package.json +1 -1
- package/dist/node_modules/.pnpm/@voidzero-dev_vite-plus-test@0.1.14_@types_node@24.12.0_@voidzero-dev_vite-plus-core@0._0c620f79340a656256b2ffe23b3e6dd1/node_modules/@voidzero-dev/vite-plus-test/dist/@vitest/utils/error.js +0 -27
- package/dist/node_modules/.pnpm/@voidzero-dev_vite-plus-test@0.1.14_@types_node@24.12.0_@voidzero-dev_vite-plus-core@0._0c620f79340a656256b2ffe23b3e6dd1/node_modules/@voidzero-dev/vite-plus-test/dist/chunks/_commonjsHelpers.D26ty3Ew.js +0 -4
- package/dist/node_modules/.pnpm/@voidzero-dev_vite-plus-test@0.1.14_@types_node@24.12.0_@voidzero-dev_vite-plus-core@0._0c620f79340a656256b2ffe23b3e6dd1/node_modules/@voidzero-dev/vite-plus-test/dist/vendor/tinyrainbow.js +0 -84
|
@@ -1,320 +1,17 @@
|
|
|
1
|
-
import { assertTypes, createSimpleStackTrace } from "
|
|
2
|
-
import { delay, getSafeTimers } from "
|
|
3
|
-
import { parseSingleStack } from "
|
|
4
|
-
import { G as getNames, j as getCurrentTest } from "
|
|
1
|
+
import { assertTypes, createSimpleStackTrace } from "../../../../../@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/helpers.js";
|
|
2
|
+
import { delay, getSafeTimers } from "../../../../../@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/timers.js";
|
|
3
|
+
import { parseSingleStack } from "../../../../../@vitest_utils@4.1.10/node_modules/@vitest/utils/dist/source-map.js";
|
|
4
|
+
import { G as getNames, j as getCurrentTest } from "../../../../../@vitest_runner@4.1.10/node_modules/@vitest/runner/dist/chunk-artifact.js";
|
|
5
|
+
import "../../../../../@vitest_runner@4.1.10/node_modules/@vitest/runner/dist/index.js";
|
|
6
|
+
import "../../../../../@vitest_runner@4.1.10/node_modules/@vitest/runner/dist/utils.js";
|
|
5
7
|
import { g as getWorkerState, i as isChildProcess, r as resetModules, w as waitForImportsToResolve } from "./utils.BX5Fg8C4.js";
|
|
6
|
-
import { clearAllMocks, fn, isMockFunction, resetAllMocks, restoreAllMocks, spyOn } from "
|
|
7
|
-
import { Assertion, assert as assert$1, expect, use, util as utils_exports } from "
|
|
8
|
-
import { ASYMMETRIC_MATCHERS_OBJECT, ChaiStyleAssertions, GLOBAL_EXPECT, JestAsymmetricMatchers, JestChaiExpect, JestExtend, addCustomEqualityTesters, createAssertionMessage, customMatchers, equals, getState, iterableEquality, recordAsyncExpect, setState, subsetEquality, wrapAssertion } from "
|
|
9
|
-
import { SnapshotClient, addSerializer, stripSnapshotIndentation } from "../@vitest/snapshot/index.js";
|
|
8
|
+
import { clearAllMocks, fn, isMockFunction, resetAllMocks, restoreAllMocks, spyOn } from "../../../../../@vitest_spy@4.1.10/node_modules/@vitest/spy/dist/index.js";
|
|
9
|
+
import { Assertion, assert as assert$1, expect, use, util as utils_exports } from "../../../../../chai@6.2.2/node_modules/chai/index.js";
|
|
10
|
+
import { ASYMMETRIC_MATCHERS_OBJECT, ChaiStyleAssertions, GLOBAL_EXPECT, JestAsymmetricMatchers, JestChaiExpect, JestExtend, addCustomEqualityTesters, createAssertionMessage, customMatchers, equals, getState, iterableEquality, recordAsyncExpect, setState, subsetEquality, wrapAssertion } from "../../../../../@vitest_expect@4.1.10/node_modules/@vitest/expect/dist/index.js";
|
|
10
11
|
import { c as commonjsGlobal } from "./_commonjsHelpers.D26ty3Ew.js";
|
|
11
12
|
import { R as RealDate, b as resetDate, m as mockDate } from "./rpc.MzXet3jl.js";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"matchSnapshot",
|
|
15
|
-
"toMatchSnapshot",
|
|
16
|
-
"toMatchInlineSnapshot",
|
|
17
|
-
"toThrowErrorMatchingSnapshot",
|
|
18
|
-
"toThrowErrorMatchingInlineSnapshot",
|
|
19
|
-
"throws",
|
|
20
|
-
"Throw",
|
|
21
|
-
"throw",
|
|
22
|
-
"toThrow",
|
|
23
|
-
"toThrowError"
|
|
24
|
-
];
|
|
25
|
-
/**
|
|
26
|
-
* Attaches a `cause` property to the error if missing, copies the stack trace from the source, and throws.
|
|
27
|
-
*
|
|
28
|
-
* @param error - The error to throw
|
|
29
|
-
* @param source - Error to copy the stack trace from
|
|
30
|
-
*
|
|
31
|
-
* @throws Always throws the provided error with an amended stack trace
|
|
32
|
-
*/
|
|
33
|
-
function throwWithCause(error, source) {
|
|
34
|
-
if (error.cause == null) error.cause = /* @__PURE__ */ new Error("Matcher did not succeed in time.");
|
|
35
|
-
throw copyStackTrace$1(error, source);
|
|
36
|
-
}
|
|
37
|
-
function createExpectPoll(expect) {
|
|
38
|
-
return function poll(fn, options = {}) {
|
|
39
|
-
const defaults = getWorkerState().config.expect?.poll ?? {};
|
|
40
|
-
const { interval = defaults.interval ?? 50, timeout = defaults.timeout ?? 1e3, message } = options;
|
|
41
|
-
const assertion = expect(null, message).withContext({ poll: true });
|
|
42
|
-
fn = fn.bind(assertion);
|
|
43
|
-
const test = utils_exports.flag(assertion, "vitest-test");
|
|
44
|
-
if (!test) throw new Error("expect.poll() must be called inside a test");
|
|
45
|
-
const proxy = new Proxy(assertion, { get(target, key, receiver) {
|
|
46
|
-
const assertionFunction = Reflect.get(target, key, receiver);
|
|
47
|
-
if (typeof assertionFunction !== "function") return assertionFunction instanceof Assertion ? proxy : assertionFunction;
|
|
48
|
-
if (key === "assert") return assertionFunction;
|
|
49
|
-
if (typeof key === "string" && unsupported.includes(key)) throw new SyntaxError(`expect.poll() is not supported in combination with .${key}(). Use vi.waitFor() if your assertion condition is unstable.`);
|
|
50
|
-
return function(...args) {
|
|
51
|
-
const STACK_TRACE_ERROR = /* @__PURE__ */ new Error("STACK_TRACE_ERROR");
|
|
52
|
-
const promise = async () => {
|
|
53
|
-
const { setTimeout, clearTimeout } = getSafeTimers();
|
|
54
|
-
let executionPhase = "fn";
|
|
55
|
-
let hasTimedOut = false;
|
|
56
|
-
const timerId = setTimeout(() => {
|
|
57
|
-
hasTimedOut = true;
|
|
58
|
-
}, timeout);
|
|
59
|
-
utils_exports.flag(assertion, "_name", key);
|
|
60
|
-
const onSettled = utils_exports.flag(assertion, "_poll.onSettled");
|
|
61
|
-
try {
|
|
62
|
-
while (true) {
|
|
63
|
-
const isLastAttempt = hasTimedOut;
|
|
64
|
-
if (isLastAttempt) utils_exports.flag(assertion, "_isLastPollAttempt", true);
|
|
65
|
-
try {
|
|
66
|
-
executionPhase = "fn";
|
|
67
|
-
const obj = await fn();
|
|
68
|
-
utils_exports.flag(assertion, "object", obj);
|
|
69
|
-
executionPhase = "assertion";
|
|
70
|
-
const output = await assertionFunction.call(assertion, ...args);
|
|
71
|
-
await onSettled?.({
|
|
72
|
-
assertion,
|
|
73
|
-
status: "pass"
|
|
74
|
-
});
|
|
75
|
-
return output;
|
|
76
|
-
} catch (err) {
|
|
77
|
-
if (isLastAttempt || executionPhase === "assertion" && utils_exports.flag(assertion, "_poll.assert_once")) {
|
|
78
|
-
await onSettled?.({
|
|
79
|
-
assertion,
|
|
80
|
-
status: "fail"
|
|
81
|
-
});
|
|
82
|
-
throwWithCause(err, STACK_TRACE_ERROR);
|
|
83
|
-
}
|
|
84
|
-
await delay(interval, setTimeout);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
} finally {
|
|
88
|
-
clearTimeout(timerId);
|
|
89
|
-
}
|
|
90
|
-
};
|
|
91
|
-
let awaited = false;
|
|
92
|
-
test.onFinished ??= [];
|
|
93
|
-
test.onFinished.push(() => {
|
|
94
|
-
if (!awaited) {
|
|
95
|
-
const negated = utils_exports.flag(assertion, "negate") ? "not." : "";
|
|
96
|
-
const assertionString = `expect.${utils_exports.flag(assertion, "_poll.element") ? "element(locator)" : "poll(assertion)"}.${negated}${String(key)}()`;
|
|
97
|
-
throw copyStackTrace$1(/* @__PURE__ */ new Error(`${assertionString} was not awaited. This assertion is asynchronous and must be awaited; otherwise, it is not executed to avoid unhandled rejections:\n\nawait ${assertionString}\n`), STACK_TRACE_ERROR);
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
let resultPromise;
|
|
101
|
-
return {
|
|
102
|
-
then(onFulfilled, onRejected) {
|
|
103
|
-
awaited = true;
|
|
104
|
-
return (resultPromise ||= promise()).then(onFulfilled, onRejected);
|
|
105
|
-
},
|
|
106
|
-
catch(onRejected) {
|
|
107
|
-
awaited = true;
|
|
108
|
-
return (resultPromise ||= promise()).catch(onRejected);
|
|
109
|
-
},
|
|
110
|
-
finally(onFinally) {
|
|
111
|
-
awaited = true;
|
|
112
|
-
return (resultPromise ||= promise()).finally(onFinally);
|
|
113
|
-
},
|
|
114
|
-
[Symbol.toStringTag]: "Promise"
|
|
115
|
-
};
|
|
116
|
-
};
|
|
117
|
-
} });
|
|
118
|
-
return proxy;
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
function copyStackTrace$1(target, source) {
|
|
122
|
-
if (source.stack !== void 0) target.stack = source.stack.replace(source.message, target.message);
|
|
123
|
-
return target;
|
|
124
|
-
}
|
|
125
|
-
var _client;
|
|
126
|
-
function getSnapshotClient() {
|
|
127
|
-
if (!_client) _client = new SnapshotClient({ isEqual: (received, expected) => {
|
|
128
|
-
return equals(received, expected, [iterableEquality, subsetEquality]);
|
|
129
|
-
} });
|
|
130
|
-
return _client;
|
|
131
|
-
}
|
|
132
|
-
function getError(expected, promise) {
|
|
133
|
-
if (typeof expected !== "function") {
|
|
134
|
-
if (!promise) throw new Error(`expected must be a function, received ${typeof expected}`);
|
|
135
|
-
return expected;
|
|
136
|
-
}
|
|
137
|
-
try {
|
|
138
|
-
expected();
|
|
139
|
-
} catch (e) {
|
|
140
|
-
return e;
|
|
141
|
-
}
|
|
142
|
-
throw new Error("snapshot function didn't throw");
|
|
143
|
-
}
|
|
144
|
-
function getTestNames(test) {
|
|
145
|
-
return {
|
|
146
|
-
filepath: test.file.filepath,
|
|
147
|
-
name: getNames(test).slice(1).join(" > "),
|
|
148
|
-
testId: test.id
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
var SnapshotPlugin = (chai, utils) => {
|
|
152
|
-
function getTest(assertionName, obj) {
|
|
153
|
-
const test = utils.flag(obj, "vitest-test");
|
|
154
|
-
if (!test) throw new Error(`'${assertionName}' cannot be used without test context`);
|
|
155
|
-
return test;
|
|
156
|
-
}
|
|
157
|
-
for (const key of ["matchSnapshot", "toMatchSnapshot"]) utils.addMethod(chai.Assertion.prototype, key, wrapAssertion(utils, key, function(properties, message) {
|
|
158
|
-
utils.flag(this, "_name", key);
|
|
159
|
-
if (utils.flag(this, "negate")) throw new Error(`${key} cannot be used with "not"`);
|
|
160
|
-
const expected = utils.flag(this, "object");
|
|
161
|
-
const test = getTest(key, this);
|
|
162
|
-
if (typeof properties === "string" && typeof message === "undefined") {
|
|
163
|
-
message = properties;
|
|
164
|
-
properties = void 0;
|
|
165
|
-
}
|
|
166
|
-
const errorMessage = utils.flag(this, "message");
|
|
167
|
-
getSnapshotClient().assert({
|
|
168
|
-
received: expected,
|
|
169
|
-
message,
|
|
170
|
-
isInline: false,
|
|
171
|
-
properties,
|
|
172
|
-
errorMessage,
|
|
173
|
-
...getTestNames(test)
|
|
174
|
-
});
|
|
175
|
-
}));
|
|
176
|
-
utils.addMethod(chai.Assertion.prototype, "toMatchFileSnapshot", function(file, message) {
|
|
177
|
-
utils.flag(this, "_name", "toMatchFileSnapshot");
|
|
178
|
-
if (utils.flag(this, "negate")) throw new Error("toMatchFileSnapshot cannot be used with \"not\"");
|
|
179
|
-
const error = /* @__PURE__ */ new Error("resolves");
|
|
180
|
-
const expected = utils.flag(this, "object");
|
|
181
|
-
const test = getTest("toMatchFileSnapshot", this);
|
|
182
|
-
const errorMessage = utils.flag(this, "message");
|
|
183
|
-
return recordAsyncExpect(test, getSnapshotClient().assertRaw({
|
|
184
|
-
received: expected,
|
|
185
|
-
message,
|
|
186
|
-
isInline: false,
|
|
187
|
-
rawSnapshot: { file },
|
|
188
|
-
errorMessage,
|
|
189
|
-
...getTestNames(test)
|
|
190
|
-
}), createAssertionMessage(utils, this, true), error, utils.flag(this, "soft"));
|
|
191
|
-
});
|
|
192
|
-
utils.addMethod(chai.Assertion.prototype, "toMatchInlineSnapshot", wrapAssertion(utils, "toMatchInlineSnapshot", function __INLINE_SNAPSHOT_OFFSET_3__(properties, inlineSnapshot, message) {
|
|
193
|
-
utils.flag(this, "_name", "toMatchInlineSnapshot");
|
|
194
|
-
if (utils.flag(this, "negate")) throw new Error("toMatchInlineSnapshot cannot be used with \"not\"");
|
|
195
|
-
const test = getTest("toMatchInlineSnapshot", this);
|
|
196
|
-
const expected = utils.flag(this, "object");
|
|
197
|
-
const error = utils.flag(this, "error");
|
|
198
|
-
if (typeof properties === "string") {
|
|
199
|
-
message = inlineSnapshot;
|
|
200
|
-
inlineSnapshot = properties;
|
|
201
|
-
properties = void 0;
|
|
202
|
-
}
|
|
203
|
-
if (inlineSnapshot) inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
|
|
204
|
-
const errorMessage = utils.flag(this, "message");
|
|
205
|
-
getSnapshotClient().assert({
|
|
206
|
-
received: expected,
|
|
207
|
-
message,
|
|
208
|
-
isInline: true,
|
|
209
|
-
properties,
|
|
210
|
-
inlineSnapshot,
|
|
211
|
-
error,
|
|
212
|
-
errorMessage,
|
|
213
|
-
...getTestNames(test)
|
|
214
|
-
});
|
|
215
|
-
}));
|
|
216
|
-
utils.addMethod(chai.Assertion.prototype, "toThrowErrorMatchingSnapshot", wrapAssertion(utils, "toThrowErrorMatchingSnapshot", function(properties, message) {
|
|
217
|
-
utils.flag(this, "_name", "toThrowErrorMatchingSnapshot");
|
|
218
|
-
if (utils.flag(this, "negate")) throw new Error("toThrowErrorMatchingSnapshot cannot be used with \"not\"");
|
|
219
|
-
const expected = utils.flag(this, "object");
|
|
220
|
-
const test = getTest("toThrowErrorMatchingSnapshot", this);
|
|
221
|
-
const promise = utils.flag(this, "promise");
|
|
222
|
-
const errorMessage = utils.flag(this, "message");
|
|
223
|
-
getSnapshotClient().assert({
|
|
224
|
-
received: getError(expected, promise),
|
|
225
|
-
message,
|
|
226
|
-
errorMessage,
|
|
227
|
-
...getTestNames(test)
|
|
228
|
-
});
|
|
229
|
-
}));
|
|
230
|
-
utils.addMethod(chai.Assertion.prototype, "toThrowErrorMatchingInlineSnapshot", wrapAssertion(utils, "toThrowErrorMatchingInlineSnapshot", function __INLINE_SNAPSHOT_OFFSET_3__(inlineSnapshot, message) {
|
|
231
|
-
if (utils.flag(this, "negate")) throw new Error("toThrowErrorMatchingInlineSnapshot cannot be used with \"not\"");
|
|
232
|
-
const test = getTest("toThrowErrorMatchingInlineSnapshot", this);
|
|
233
|
-
const expected = utils.flag(this, "object");
|
|
234
|
-
const error = utils.flag(this, "error");
|
|
235
|
-
const promise = utils.flag(this, "promise");
|
|
236
|
-
const errorMessage = utils.flag(this, "message");
|
|
237
|
-
if (inlineSnapshot) inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
|
|
238
|
-
getSnapshotClient().assert({
|
|
239
|
-
received: getError(expected, promise),
|
|
240
|
-
message,
|
|
241
|
-
inlineSnapshot,
|
|
242
|
-
isInline: true,
|
|
243
|
-
error,
|
|
244
|
-
errorMessage,
|
|
245
|
-
...getTestNames(test)
|
|
246
|
-
});
|
|
247
|
-
}));
|
|
248
|
-
utils.addMethod(chai.expect, "addSnapshotSerializer", addSerializer);
|
|
249
|
-
};
|
|
250
|
-
use(JestExtend);
|
|
251
|
-
use(JestChaiExpect);
|
|
252
|
-
use(ChaiStyleAssertions);
|
|
253
|
-
use(SnapshotPlugin);
|
|
254
|
-
use(JestAsymmetricMatchers);
|
|
255
|
-
function createExpect(test) {
|
|
256
|
-
const expect$1 = ((value, message) => {
|
|
257
|
-
const { assertionCalls } = getState(expect$1);
|
|
258
|
-
setState({ assertionCalls: assertionCalls + 1 }, expect$1);
|
|
259
|
-
const assert = expect(value, message);
|
|
260
|
-
const _test = test || getCurrentTest();
|
|
261
|
-
if (_test) return assert.withTest(_test);
|
|
262
|
-
else return assert;
|
|
263
|
-
});
|
|
264
|
-
Object.assign(expect$1, expect);
|
|
265
|
-
Object.assign(expect$1, globalThis[ASYMMETRIC_MATCHERS_OBJECT]);
|
|
266
|
-
expect$1.getState = () => getState(expect$1);
|
|
267
|
-
expect$1.setState = (state) => setState(state, expect$1);
|
|
268
|
-
const globalState = getState(globalThis[GLOBAL_EXPECT]) || {};
|
|
269
|
-
setState({
|
|
270
|
-
...globalState,
|
|
271
|
-
assertionCalls: 0,
|
|
272
|
-
isExpectingAssertions: false,
|
|
273
|
-
isExpectingAssertionsError: null,
|
|
274
|
-
expectedAssertionsNumber: null,
|
|
275
|
-
expectedAssertionsNumberErrorGen: null,
|
|
276
|
-
get testPath() {
|
|
277
|
-
return getWorkerState().filepath;
|
|
278
|
-
},
|
|
279
|
-
currentTestName: test ? test.fullTestName ?? "" : globalState.currentTestName
|
|
280
|
-
}, expect$1);
|
|
281
|
-
expect$1.assert = assert$1;
|
|
282
|
-
expect$1.extend = (matchers) => expect.extend(expect$1, matchers);
|
|
283
|
-
expect$1.addEqualityTesters = (customTesters) => addCustomEqualityTesters(customTesters);
|
|
284
|
-
expect$1.soft = (...args) => {
|
|
285
|
-
return expect$1(...args).withContext({ soft: true });
|
|
286
|
-
};
|
|
287
|
-
expect$1.poll = createExpectPoll(expect$1);
|
|
288
|
-
expect$1.unreachable = (message) => {
|
|
289
|
-
assert$1.fail(`expected${message ? ` "${message}" ` : " "}not to be reached`);
|
|
290
|
-
};
|
|
291
|
-
function assertions(expected) {
|
|
292
|
-
const errorGen = () => /* @__PURE__ */ new Error(`expected number of assertions to be ${expected}, but got ${expect$1.getState().assertionCalls}`);
|
|
293
|
-
if (Error.captureStackTrace) Error.captureStackTrace(errorGen(), assertions);
|
|
294
|
-
expect$1.setState({
|
|
295
|
-
expectedAssertionsNumber: expected,
|
|
296
|
-
expectedAssertionsNumberErrorGen: errorGen
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
function hasAssertions() {
|
|
300
|
-
const error = /* @__PURE__ */ new Error("expected any number of assertion, but got none");
|
|
301
|
-
if (Error.captureStackTrace) Error.captureStackTrace(error, hasAssertions);
|
|
302
|
-
expect$1.setState({
|
|
303
|
-
isExpectingAssertions: true,
|
|
304
|
-
isExpectingAssertionsError: error
|
|
305
|
-
});
|
|
306
|
-
}
|
|
307
|
-
utils_exports.addMethod(expect$1, "assertions", assertions);
|
|
308
|
-
utils_exports.addMethod(expect$1, "hasAssertions", hasAssertions);
|
|
309
|
-
expect$1.extend(customMatchers);
|
|
310
|
-
return expect$1;
|
|
311
|
-
}
|
|
312
|
-
var globalExpect = createExpect();
|
|
313
|
-
Object.defineProperty(globalThis, GLOBAL_EXPECT, {
|
|
314
|
-
value: globalExpect,
|
|
315
|
-
writable: true,
|
|
316
|
-
configurable: true
|
|
317
|
-
});
|
|
13
|
+
import { SnapshotClient, addSerializer, stripSnapshotIndentation } from "../../../../../@vitest_snapshot@4.1.10/node_modules/@vitest/snapshot/dist/index.js";
|
|
14
|
+
//#region ../../node_modules/.pnpm/vitest@4.1.10_@types+node@24.12.0_@vitest+browser-preview@4.1.10_@vitest+coverage-v8@4._55bf307888d746e7433721e12ae091d9/node_modules/vitest/dist/chunks/test.DNmyFkvJ.js
|
|
318
15
|
var fakeTimersSrc = {};
|
|
319
16
|
var global;
|
|
320
17
|
var hasRequiredGlobal;
|
|
@@ -2313,7 +2010,7 @@ var FakeTimers = class {
|
|
|
2313
2010
|
return this._fakingTime;
|
|
2314
2011
|
}
|
|
2315
2012
|
};
|
|
2316
|
-
function copyStackTrace(target, source) {
|
|
2013
|
+
function copyStackTrace$1(target, source) {
|
|
2317
2014
|
if (source.stack !== void 0) target.stack = source.stack.replace(source.message, target.message);
|
|
2318
2015
|
return target;
|
|
2319
2016
|
}
|
|
@@ -2334,7 +2031,7 @@ function waitFor(callback, options = {}) {
|
|
|
2334
2031
|
const handleTimeout = () => {
|
|
2335
2032
|
if (intervalId) clearInterval(intervalId);
|
|
2336
2033
|
let error = lastError;
|
|
2337
|
-
if (!error) error = copyStackTrace(/* @__PURE__ */ new Error("Timed out in waitFor!"), STACK_TRACE_ERROR);
|
|
2034
|
+
if (!error) error = copyStackTrace$1(/* @__PURE__ */ new Error("Timed out in waitFor!"), STACK_TRACE_ERROR);
|
|
2338
2035
|
reject(error);
|
|
2339
2036
|
};
|
|
2340
2037
|
const checkCallback = () => {
|
|
@@ -2375,7 +2072,7 @@ function waitUntil(callback, options = {}) {
|
|
|
2375
2072
|
let intervalId;
|
|
2376
2073
|
const onReject = (error) => {
|
|
2377
2074
|
if (intervalId) clearInterval(intervalId);
|
|
2378
|
-
if (!error) error = copyStackTrace(/* @__PURE__ */ new Error("Timed out in waitUntil!"), STACK_TRACE_ERROR);
|
|
2075
|
+
if (!error) error = copyStackTrace$1(/* @__PURE__ */ new Error("Timed out in waitUntil!"), STACK_TRACE_ERROR);
|
|
2379
2076
|
reject(error);
|
|
2380
2077
|
};
|
|
2381
2078
|
const onResolve = (result) => {
|
|
@@ -2512,7 +2209,7 @@ function createVitest() {
|
|
|
2512
2209
|
waitUntil,
|
|
2513
2210
|
defineHelper: (fn) => {
|
|
2514
2211
|
return function __VITEST_HELPER__(...args) {
|
|
2515
|
-
const result = fn(
|
|
2212
|
+
const result = fn.apply(this, args);
|
|
2516
2213
|
if (result && typeof result === "object" && typeof result.then === "function") return (async function __VITEST_HELPER__() {
|
|
2517
2214
|
return await result;
|
|
2518
2215
|
})();
|
|
@@ -2641,5 +2338,359 @@ function getImporter(name) {
|
|
|
2641
2338
|
return stack.includes(` at Object.${name}`) || stack.includes(`${name}@`) || stack.includes(` at ${name} (`);
|
|
2642
2339
|
}) + 1])?.file || "";
|
|
2643
2340
|
}
|
|
2341
|
+
var unsupported = [
|
|
2342
|
+
"matchSnapshot",
|
|
2343
|
+
"toMatchSnapshot",
|
|
2344
|
+
"toMatchInlineSnapshot",
|
|
2345
|
+
"toThrowErrorMatchingSnapshot",
|
|
2346
|
+
"toThrowErrorMatchingInlineSnapshot",
|
|
2347
|
+
"throws",
|
|
2348
|
+
"Throw",
|
|
2349
|
+
"throw",
|
|
2350
|
+
"toThrow",
|
|
2351
|
+
"toThrowError"
|
|
2352
|
+
];
|
|
2353
|
+
/**
|
|
2354
|
+
* Attaches a `cause` property to the error if missing, copies the stack trace from the source, and throws.
|
|
2355
|
+
*
|
|
2356
|
+
* @param error - The error to throw
|
|
2357
|
+
* @param source - Error to copy the stack trace from
|
|
2358
|
+
*
|
|
2359
|
+
* @throws Always throws the provided error with an amended stack trace
|
|
2360
|
+
*/
|
|
2361
|
+
function throwWithCause(error, source) {
|
|
2362
|
+
if (error.cause == null) error.cause = /* @__PURE__ */ new Error("Matcher did not succeed in time.");
|
|
2363
|
+
throw copyStackTrace(error, source);
|
|
2364
|
+
}
|
|
2365
|
+
function createExpectPoll(expect) {
|
|
2366
|
+
return function poll(fn, options = {}) {
|
|
2367
|
+
const defaults = getWorkerState().config.expect?.poll ?? {};
|
|
2368
|
+
const { interval = defaults.interval ?? 50, timeout = defaults.timeout ?? 1e3, message } = options;
|
|
2369
|
+
const assertion = expect(null, message).withContext({ poll: true });
|
|
2370
|
+
fn = fn.bind(assertion);
|
|
2371
|
+
utils_exports.flag(assertion, "_poll.fn", fn);
|
|
2372
|
+
utils_exports.flag(assertion, "_poll.timeout", timeout);
|
|
2373
|
+
utils_exports.flag(assertion, "_poll.interval", interval);
|
|
2374
|
+
const test = utils_exports.flag(assertion, "vitest-test");
|
|
2375
|
+
if (!test) throw new Error("expect.poll() must be called inside a test");
|
|
2376
|
+
const proxy = new Proxy(assertion, { get(target, key, receiver) {
|
|
2377
|
+
const assertionFunction = Reflect.get(target, key, receiver);
|
|
2378
|
+
if (typeof assertionFunction !== "function") return assertionFunction instanceof Assertion ? proxy : assertionFunction;
|
|
2379
|
+
if (key === "assert") return assertionFunction;
|
|
2380
|
+
if (typeof key === "string" && unsupported.includes(key)) throw new SyntaxError(`expect.poll() is not supported in combination with .${key}(). Use vi.waitFor() if your assertion condition is unstable.`);
|
|
2381
|
+
return function __VITEST_POLL_CHAIN__(...args) {
|
|
2382
|
+
const STACK_TRACE_ERROR = /* @__PURE__ */ new Error("STACK_TRACE_ERROR");
|
|
2383
|
+
const promise = async () => {
|
|
2384
|
+
utils_exports.flag(assertion, "_name", key);
|
|
2385
|
+
utils_exports.flag(assertion, "error", STACK_TRACE_ERROR);
|
|
2386
|
+
const onSettled = utils_exports.flag(assertion, "_poll.onSettled");
|
|
2387
|
+
if (Object.getOwnPropertyDescriptor(assertionFunction, "__vitest_poll_takeover__")?.value) try {
|
|
2388
|
+
const output = await assertionFunction.call(assertion, ...args);
|
|
2389
|
+
await onSettled?.({
|
|
2390
|
+
assertion,
|
|
2391
|
+
status: "pass"
|
|
2392
|
+
});
|
|
2393
|
+
return output;
|
|
2394
|
+
} catch (err) {
|
|
2395
|
+
await onSettled?.({
|
|
2396
|
+
assertion,
|
|
2397
|
+
status: "fail"
|
|
2398
|
+
});
|
|
2399
|
+
throwWithCause(err, STACK_TRACE_ERROR);
|
|
2400
|
+
}
|
|
2401
|
+
const { setTimeout, clearTimeout } = getSafeTimers();
|
|
2402
|
+
let executionPhase = "fn";
|
|
2403
|
+
let hasTimedOut = false;
|
|
2404
|
+
const timerId = setTimeout(() => {
|
|
2405
|
+
hasTimedOut = true;
|
|
2406
|
+
}, timeout);
|
|
2407
|
+
try {
|
|
2408
|
+
while (true) {
|
|
2409
|
+
const isLastAttempt = hasTimedOut;
|
|
2410
|
+
if (isLastAttempt) utils_exports.flag(assertion, "_isLastPollAttempt", true);
|
|
2411
|
+
try {
|
|
2412
|
+
executionPhase = "fn";
|
|
2413
|
+
const obj = await fn();
|
|
2414
|
+
utils_exports.flag(assertion, "object", obj);
|
|
2415
|
+
executionPhase = "assertion";
|
|
2416
|
+
const output = await assertionFunction.call(assertion, ...args);
|
|
2417
|
+
await onSettled?.({
|
|
2418
|
+
assertion,
|
|
2419
|
+
status: "pass"
|
|
2420
|
+
});
|
|
2421
|
+
return output;
|
|
2422
|
+
} catch (err) {
|
|
2423
|
+
if (isLastAttempt || executionPhase === "assertion" && utils_exports.flag(assertion, "_poll.assert_once")) {
|
|
2424
|
+
await onSettled?.({
|
|
2425
|
+
assertion,
|
|
2426
|
+
status: "fail"
|
|
2427
|
+
});
|
|
2428
|
+
throwWithCause(err, STACK_TRACE_ERROR);
|
|
2429
|
+
}
|
|
2430
|
+
await delay(interval, setTimeout);
|
|
2431
|
+
if (vi.isFakeTimers()) vi.advanceTimersByTime(interval);
|
|
2432
|
+
}
|
|
2433
|
+
}
|
|
2434
|
+
} finally {
|
|
2435
|
+
clearTimeout(timerId);
|
|
2436
|
+
}
|
|
2437
|
+
};
|
|
2438
|
+
let awaited = false;
|
|
2439
|
+
test.onFinished ??= [];
|
|
2440
|
+
test.onFinished.push(() => {
|
|
2441
|
+
if (!awaited) {
|
|
2442
|
+
const negated = utils_exports.flag(assertion, "negate") ? "not." : "";
|
|
2443
|
+
const assertionString = `expect.${utils_exports.flag(assertion, "_poll.element") ? "element(locator)" : "poll(assertion)"}.${negated}${String(key)}()`;
|
|
2444
|
+
throw copyStackTrace(/* @__PURE__ */ new Error(`${assertionString} was not awaited. This assertion is asynchronous and must be awaited; otherwise, it is not executed to avoid unhandled rejections:\n\nawait ${assertionString}\n`), STACK_TRACE_ERROR);
|
|
2445
|
+
}
|
|
2446
|
+
});
|
|
2447
|
+
let resultPromise;
|
|
2448
|
+
return {
|
|
2449
|
+
then(onFulfilled, onRejected) {
|
|
2450
|
+
awaited = true;
|
|
2451
|
+
return (resultPromise ||= promise()).then(onFulfilled, onRejected);
|
|
2452
|
+
},
|
|
2453
|
+
catch(onRejected) {
|
|
2454
|
+
awaited = true;
|
|
2455
|
+
return (resultPromise ||= promise()).catch(onRejected);
|
|
2456
|
+
},
|
|
2457
|
+
finally(onFinally) {
|
|
2458
|
+
awaited = true;
|
|
2459
|
+
return (resultPromise ||= promise()).finally(onFinally);
|
|
2460
|
+
},
|
|
2461
|
+
[Symbol.toStringTag]: "Promise"
|
|
2462
|
+
};
|
|
2463
|
+
};
|
|
2464
|
+
} });
|
|
2465
|
+
return proxy;
|
|
2466
|
+
};
|
|
2467
|
+
}
|
|
2468
|
+
function copyStackTrace(target, source) {
|
|
2469
|
+
if (source.stack !== void 0) target.stack = source.stack.replace(source.message, target.message);
|
|
2470
|
+
return target;
|
|
2471
|
+
}
|
|
2472
|
+
var _client;
|
|
2473
|
+
function getSnapshotClient() {
|
|
2474
|
+
if (!_client) _client = new SnapshotClient({ isEqual: (received, expected) => {
|
|
2475
|
+
return equals(received, expected, [iterableEquality, subsetEquality]);
|
|
2476
|
+
} });
|
|
2477
|
+
return _client;
|
|
2478
|
+
}
|
|
2479
|
+
function getError(expected, promise) {
|
|
2480
|
+
if (typeof expected !== "function") {
|
|
2481
|
+
if (!promise) throw new Error(`expected must be a function, received ${typeof expected}`);
|
|
2482
|
+
return expected;
|
|
2483
|
+
}
|
|
2484
|
+
try {
|
|
2485
|
+
expected();
|
|
2486
|
+
} catch (e) {
|
|
2487
|
+
return e;
|
|
2488
|
+
}
|
|
2489
|
+
throw new Error("snapshot function didn't throw");
|
|
2490
|
+
}
|
|
2491
|
+
function getTestNames(test) {
|
|
2492
|
+
return {
|
|
2493
|
+
filepath: test.file.filepath,
|
|
2494
|
+
name: getNames(test).slice(1).join(" > "),
|
|
2495
|
+
testId: test.id
|
|
2496
|
+
};
|
|
2497
|
+
}
|
|
2498
|
+
function getAssertionName(assertion) {
|
|
2499
|
+
const name = utils_exports.flag(assertion, "_name");
|
|
2500
|
+
if (!name) throw new Error("Assertion name is not set. This is a bug in Vitest. Please, open a new issue with reproduction.");
|
|
2501
|
+
return name;
|
|
2502
|
+
}
|
|
2503
|
+
function getTest(obj) {
|
|
2504
|
+
const test = utils_exports.flag(obj, "vitest-test");
|
|
2505
|
+
if (!test) throw new Error(`'${getAssertionName(obj)}' cannot be used without test context`);
|
|
2506
|
+
return test;
|
|
2507
|
+
}
|
|
2508
|
+
function validateAssertion(assertion) {
|
|
2509
|
+
if (utils_exports.flag(assertion, "negate")) throw new Error(`${getAssertionName(assertion)} cannot be used with "not"`);
|
|
2510
|
+
}
|
|
2511
|
+
var SnapshotPlugin = (chai, utils) => {
|
|
2512
|
+
for (const key of ["matchSnapshot", "toMatchSnapshot"]) utils.addMethod(chai.Assertion.prototype, key, wrapAssertion(utils, key, function(propertiesOrHint, hint) {
|
|
2513
|
+
return assertMatchResult(toMatchSnapshotImpl({
|
|
2514
|
+
assertion: this,
|
|
2515
|
+
received: utils.flag(this, "object"),
|
|
2516
|
+
...normalizeArguments(propertiesOrHint, hint)
|
|
2517
|
+
}), chai.util.flag(this, "message"));
|
|
2518
|
+
}));
|
|
2519
|
+
utils.addMethod(chai.Assertion.prototype, "toMatchFileSnapshot", function(filepath, hint) {
|
|
2520
|
+
utils.flag(this, "_name", "toMatchFileSnapshot");
|
|
2521
|
+
validateAssertion(this);
|
|
2522
|
+
const assertPromise = toMatchFileSnapshotImpl({
|
|
2523
|
+
assertion: this,
|
|
2524
|
+
received: utils.flag(this, "object"),
|
|
2525
|
+
filepath,
|
|
2526
|
+
hint
|
|
2527
|
+
}).then((result) => assertMatchResult(result, chai.util.flag(this, "message")));
|
|
2528
|
+
return recordAsyncExpect(getTest(this), assertPromise, createAssertionMessage(utils, this, true), /* @__PURE__ */ new Error("resolves"), utils.flag(this, "soft"));
|
|
2529
|
+
});
|
|
2530
|
+
utils.addMethod(chai.Assertion.prototype, "toMatchInlineSnapshot", wrapAssertion(utils, "toMatchInlineSnapshot", function __INLINE_SNAPSHOT_OFFSET_3__(propertiesOrInlineSnapshot, inlineSnapshotOrHint, hint) {
|
|
2531
|
+
return assertMatchResult(toMatchSnapshotImpl({
|
|
2532
|
+
assertion: this,
|
|
2533
|
+
received: utils.flag(this, "object"),
|
|
2534
|
+
isInline: true,
|
|
2535
|
+
...normalizeInlineArguments(propertiesOrInlineSnapshot, inlineSnapshotOrHint, hint)
|
|
2536
|
+
}), chai.util.flag(this, "message"));
|
|
2537
|
+
}));
|
|
2538
|
+
utils.addMethod(chai.Assertion.prototype, "toThrowErrorMatchingSnapshot", wrapAssertion(utils, "toThrowErrorMatchingSnapshot", function(propertiesOrHint, hint) {
|
|
2539
|
+
validateAssertion(this);
|
|
2540
|
+
const received = utils.flag(this, "object");
|
|
2541
|
+
const promise = utils.flag(this, "promise");
|
|
2542
|
+
return assertMatchResult(toMatchSnapshotImpl({
|
|
2543
|
+
assertion: this,
|
|
2544
|
+
received: getError(received, promise),
|
|
2545
|
+
...normalizeArguments(propertiesOrHint, hint)
|
|
2546
|
+
}), chai.util.flag(this, "message"));
|
|
2547
|
+
}));
|
|
2548
|
+
utils.addMethod(chai.Assertion.prototype, "toThrowErrorMatchingInlineSnapshot", wrapAssertion(utils, "toThrowErrorMatchingInlineSnapshot", function __INLINE_SNAPSHOT_OFFSET_3__(inlineSnapshotOrHint, hint) {
|
|
2549
|
+
validateAssertion(this);
|
|
2550
|
+
const received = utils.flag(this, "object");
|
|
2551
|
+
const promise = utils.flag(this, "promise");
|
|
2552
|
+
return assertMatchResult(toMatchSnapshotImpl({
|
|
2553
|
+
assertion: this,
|
|
2554
|
+
received: getError(received, promise),
|
|
2555
|
+
isInline: true,
|
|
2556
|
+
...normalizeInlineArguments(void 0, inlineSnapshotOrHint, hint)
|
|
2557
|
+
}), chai.util.flag(this, "message"));
|
|
2558
|
+
}));
|
|
2559
|
+
utils.addMethod(chai.expect, "addSnapshotSerializer", addSerializer);
|
|
2560
|
+
};
|
|
2561
|
+
function normalizeArguments(propertiesOrHint, hint) {
|
|
2562
|
+
if (typeof propertiesOrHint === "string") return { hint: propertiesOrHint };
|
|
2563
|
+
return {
|
|
2564
|
+
properties: propertiesOrHint,
|
|
2565
|
+
hint
|
|
2566
|
+
};
|
|
2567
|
+
}
|
|
2568
|
+
function normalizeInlineArguments(propertiesOrInlineSnapshot, inlineSnapshotOrHint, hint) {
|
|
2569
|
+
let inlineSnapshot;
|
|
2570
|
+
if (typeof propertiesOrInlineSnapshot === "string") {
|
|
2571
|
+
inlineSnapshot = stripSnapshotIndentation(propertiesOrInlineSnapshot);
|
|
2572
|
+
return {
|
|
2573
|
+
inlineSnapshot,
|
|
2574
|
+
hint: inlineSnapshotOrHint
|
|
2575
|
+
};
|
|
2576
|
+
}
|
|
2577
|
+
if (inlineSnapshotOrHint) inlineSnapshot = stripSnapshotIndentation(inlineSnapshotOrHint);
|
|
2578
|
+
return {
|
|
2579
|
+
properties: propertiesOrInlineSnapshot,
|
|
2580
|
+
inlineSnapshot,
|
|
2581
|
+
hint
|
|
2582
|
+
};
|
|
2583
|
+
}
|
|
2584
|
+
function toMatchSnapshotImpl(options) {
|
|
2585
|
+
const { assertion } = options;
|
|
2586
|
+
validateAssertion(assertion);
|
|
2587
|
+
const assertionName = getAssertionName(assertion);
|
|
2588
|
+
const test = getTest(assertion);
|
|
2589
|
+
return getSnapshotClient().match({
|
|
2590
|
+
received: options.received,
|
|
2591
|
+
properties: options.properties,
|
|
2592
|
+
message: options.hint,
|
|
2593
|
+
isInline: options.isInline,
|
|
2594
|
+
inlineSnapshot: options.inlineSnapshot,
|
|
2595
|
+
assertionName,
|
|
2596
|
+
error: utils_exports.flag(assertion, "error"),
|
|
2597
|
+
...getTestNames(test)
|
|
2598
|
+
});
|
|
2599
|
+
}
|
|
2600
|
+
async function toMatchFileSnapshotImpl(options) {
|
|
2601
|
+
const { assertion } = options;
|
|
2602
|
+
validateAssertion(assertion);
|
|
2603
|
+
const testNames = getTestNames(getTest(assertion));
|
|
2604
|
+
const snapshotState = getSnapshotClient().getSnapshotState(testNames.filepath);
|
|
2605
|
+
const rawSnapshotFile = await snapshotState.environment.resolveRawPath(testNames.filepath, options.filepath);
|
|
2606
|
+
const rawSnapshotContent = await snapshotState.environment.readSnapshotFile(rawSnapshotFile);
|
|
2607
|
+
return getSnapshotClient().match({
|
|
2608
|
+
received: options.received,
|
|
2609
|
+
message: options.hint,
|
|
2610
|
+
rawSnapshot: {
|
|
2611
|
+
file: rawSnapshotFile,
|
|
2612
|
+
content: rawSnapshotContent ?? void 0
|
|
2613
|
+
},
|
|
2614
|
+
...testNames
|
|
2615
|
+
});
|
|
2616
|
+
}
|
|
2617
|
+
function assertMatchResult(result, customMessage) {
|
|
2618
|
+
if (!result.pass) {
|
|
2619
|
+
const errorMessage = (customMessage ? `${customMessage}: ` : "") + result.message();
|
|
2620
|
+
throw Object.assign(new Error(errorMessage), {
|
|
2621
|
+
actual: result.actual,
|
|
2622
|
+
expected: result.expected,
|
|
2623
|
+
diffOptions: { expand: getWorkerState().config.snapshotOptions.expand }
|
|
2624
|
+
});
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
use(JestExtend);
|
|
2628
|
+
use(JestChaiExpect);
|
|
2629
|
+
use(ChaiStyleAssertions);
|
|
2630
|
+
use(SnapshotPlugin);
|
|
2631
|
+
use(JestAsymmetricMatchers);
|
|
2632
|
+
function createExpect(test) {
|
|
2633
|
+
const expect$1 = ((value, message) => {
|
|
2634
|
+
const { assertionCalls } = getState(expect$1);
|
|
2635
|
+
setState({ assertionCalls: assertionCalls + 1 }, expect$1);
|
|
2636
|
+
const assert = expect(value, message);
|
|
2637
|
+
const _test = test || getCurrentTest();
|
|
2638
|
+
if (_test) return assert.withTest(_test);
|
|
2639
|
+
else return assert;
|
|
2640
|
+
});
|
|
2641
|
+
Object.assign(expect$1, expect);
|
|
2642
|
+
Object.assign(expect$1, globalThis[ASYMMETRIC_MATCHERS_OBJECT]);
|
|
2643
|
+
expect$1.getState = () => getState(expect$1);
|
|
2644
|
+
expect$1.setState = (state) => setState(state, expect$1);
|
|
2645
|
+
const globalState = getState(globalThis[GLOBAL_EXPECT]) || {};
|
|
2646
|
+
setState({
|
|
2647
|
+
...globalState,
|
|
2648
|
+
assertionCalls: 0,
|
|
2649
|
+
isExpectingAssertions: false,
|
|
2650
|
+
isExpectingAssertionsError: null,
|
|
2651
|
+
expectedAssertionsNumber: null,
|
|
2652
|
+
expectedAssertionsNumberErrorGen: null,
|
|
2653
|
+
get testPath() {
|
|
2654
|
+
return getWorkerState().filepath;
|
|
2655
|
+
},
|
|
2656
|
+
currentTestName: test ? test.fullTestName ?? "" : globalState.currentTestName
|
|
2657
|
+
}, expect$1);
|
|
2658
|
+
expect$1.assert = assert$1;
|
|
2659
|
+
expect$1.extend = (matchers) => expect.extend(expect$1, matchers);
|
|
2660
|
+
expect$1.addEqualityTesters = (customTesters) => addCustomEqualityTesters(customTesters);
|
|
2661
|
+
expect$1.soft = (...args) => {
|
|
2662
|
+
return expect$1(...args).withContext({ soft: true });
|
|
2663
|
+
};
|
|
2664
|
+
expect$1.poll = createExpectPoll(expect$1);
|
|
2665
|
+
expect$1.unreachable = (message) => {
|
|
2666
|
+
assert$1.fail(`expected${message ? ` "${message}" ` : " "}not to be reached`);
|
|
2667
|
+
};
|
|
2668
|
+
function assertions(expected) {
|
|
2669
|
+
const errorGen = () => /* @__PURE__ */ new Error(`expected number of assertions to be ${expected}, but got ${expect$1.getState().assertionCalls}`);
|
|
2670
|
+
if (Error.captureStackTrace) Error.captureStackTrace(errorGen(), assertions);
|
|
2671
|
+
expect$1.setState({
|
|
2672
|
+
expectedAssertionsNumber: expected,
|
|
2673
|
+
expectedAssertionsNumberErrorGen: errorGen
|
|
2674
|
+
});
|
|
2675
|
+
}
|
|
2676
|
+
function hasAssertions() {
|
|
2677
|
+
const error = /* @__PURE__ */ new Error("expected any number of assertion, but got none");
|
|
2678
|
+
if (Error.captureStackTrace) Error.captureStackTrace(error, hasAssertions);
|
|
2679
|
+
expect$1.setState({
|
|
2680
|
+
isExpectingAssertions: true,
|
|
2681
|
+
isExpectingAssertionsError: error
|
|
2682
|
+
});
|
|
2683
|
+
}
|
|
2684
|
+
utils_exports.addMethod(expect$1, "assertions", assertions);
|
|
2685
|
+
utils_exports.addMethod(expect$1, "hasAssertions", hasAssertions);
|
|
2686
|
+
expect$1.extend(customMatchers);
|
|
2687
|
+
return expect$1;
|
|
2688
|
+
}
|
|
2689
|
+
var globalExpect = createExpect();
|
|
2690
|
+
Object.defineProperty(globalThis, GLOBAL_EXPECT, {
|
|
2691
|
+
value: globalExpect,
|
|
2692
|
+
writable: true,
|
|
2693
|
+
configurable: true
|
|
2694
|
+
});
|
|
2644
2695
|
//#endregion
|
|
2645
2696
|
export { vitest as b, createExpect as c, globalExpect as g, vi as v };
|