@lokascript/framework 2.2.1 → 2.3.1
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/testing/index.js +128 -104
- package/dist/testing/index.js.map +1 -1
- package/package.json +1 -1
package/dist/testing/index.js
CHANGED
|
@@ -2429,15 +2429,23 @@ function findPlugin(plugins2, val) {
|
|
|
2429
2429
|
return null;
|
|
2430
2430
|
}
|
|
2431
2431
|
function printer(val, config2, indentation, depth, refs, hasCalledToJSON) {
|
|
2432
|
+
let result;
|
|
2432
2433
|
const plugin3 = findPlugin(config2.plugins, val);
|
|
2433
2434
|
if (plugin3 !== null) {
|
|
2434
|
-
|
|
2435
|
+
result = printPlugin(plugin3, val, config2, indentation, depth, refs);
|
|
2436
|
+
} else {
|
|
2437
|
+
const basicResult = printBasicValue(val, config2.printFunctionName, config2.escapeRegex, config2.escapeString);
|
|
2438
|
+
if (basicResult !== null) {
|
|
2439
|
+
result = basicResult;
|
|
2440
|
+
} else {
|
|
2441
|
+
result = printComplexValue(val, config2, indentation, depth, refs, hasCalledToJSON);
|
|
2442
|
+
}
|
|
2435
2443
|
}
|
|
2436
|
-
|
|
2437
|
-
if (
|
|
2438
|
-
|
|
2444
|
+
config2.outputLength += result.length;
|
|
2445
|
+
if (config2.outputLength > config2.maxOutputLength) {
|
|
2446
|
+
config2.maxDepth = 0;
|
|
2439
2447
|
}
|
|
2440
|
-
return
|
|
2448
|
+
return result;
|
|
2441
2449
|
}
|
|
2442
2450
|
var DEFAULT_THEME = {
|
|
2443
2451
|
comment: "gray",
|
|
@@ -2455,6 +2463,7 @@ var DEFAULT_OPTIONS = {
|
|
|
2455
2463
|
highlight: false,
|
|
2456
2464
|
indent: 2,
|
|
2457
2465
|
maxDepth: Number.POSITIVE_INFINITY,
|
|
2466
|
+
maxOutputLength: 1e6,
|
|
2458
2467
|
maxWidth: Number.POSITIVE_INFINITY,
|
|
2459
2468
|
min: false,
|
|
2460
2469
|
plugins: [],
|
|
@@ -2519,7 +2528,9 @@ function getConfig(options) {
|
|
|
2519
2528
|
printFunctionName: getPrintFunctionName(options),
|
|
2520
2529
|
printShadowRoot: options?.printShadowRoot ?? true,
|
|
2521
2530
|
spacingInner: options?.min ? " " : "\n",
|
|
2522
|
-
spacingOuter: options?.min ? "" : "\n"
|
|
2531
|
+
spacingOuter: options?.min ? "" : "\n",
|
|
2532
|
+
maxOutputLength: options?.maxOutputLength ?? DEFAULT_OPTIONS.maxOutputLength,
|
|
2533
|
+
outputLength: 0
|
|
2523
2534
|
};
|
|
2524
2535
|
}
|
|
2525
2536
|
function createIndent(indent) {
|
|
@@ -5798,93 +5809,7 @@ function getOriginalPosition(map2, needle) {
|
|
|
5798
5809
|
return result;
|
|
5799
5810
|
}
|
|
5800
5811
|
|
|
5801
|
-
// ../../node_modules/@vitest/runner/dist/chunk-
|
|
5802
|
-
var kChainableContext = Symbol("kChainableContext");
|
|
5803
|
-
function getChainableContext(chainable) {
|
|
5804
|
-
return chainable?.[kChainableContext];
|
|
5805
|
-
}
|
|
5806
|
-
function createChainable(keys2, fn2, context) {
|
|
5807
|
-
function create(context2) {
|
|
5808
|
-
const chain2 = function(...args) {
|
|
5809
|
-
return fn2.apply(context2, args);
|
|
5810
|
-
};
|
|
5811
|
-
Object.assign(chain2, fn2);
|
|
5812
|
-
Object.defineProperty(chain2, kChainableContext, {
|
|
5813
|
-
value: {
|
|
5814
|
-
withContext: () => chain2.bind(context2),
|
|
5815
|
-
getFixtures: () => context2.fixtures,
|
|
5816
|
-
setContext: (key, value) => {
|
|
5817
|
-
context2[key] = value;
|
|
5818
|
-
},
|
|
5819
|
-
mergeContext: (ctx) => {
|
|
5820
|
-
Object.assign(context2, ctx);
|
|
5821
|
-
}
|
|
5822
|
-
},
|
|
5823
|
-
enumerable: false
|
|
5824
|
-
});
|
|
5825
|
-
for (const key of keys2) {
|
|
5826
|
-
Object.defineProperty(chain2, key, { get() {
|
|
5827
|
-
return create({
|
|
5828
|
-
...context2,
|
|
5829
|
-
[key]: true
|
|
5830
|
-
});
|
|
5831
|
-
} });
|
|
5832
|
-
}
|
|
5833
|
-
return chain2;
|
|
5834
|
-
}
|
|
5835
|
-
const chain = create(context ?? {});
|
|
5836
|
-
Object.defineProperty(chain, "fn", {
|
|
5837
|
-
value: fn2,
|
|
5838
|
-
enumerable: false
|
|
5839
|
-
});
|
|
5840
|
-
return chain;
|
|
5841
|
-
}
|
|
5842
|
-
function findTestFileStackTrace(testFilePath, error) {
|
|
5843
|
-
const lines = error.split("\n").slice(1);
|
|
5844
|
-
for (const line of lines) {
|
|
5845
|
-
const stack = parseSingleStack(line);
|
|
5846
|
-
if (stack && stack.file === testFilePath) {
|
|
5847
|
-
return stack;
|
|
5848
|
-
}
|
|
5849
|
-
}
|
|
5850
|
-
}
|
|
5851
|
-
function validateTags(config2, tags) {
|
|
5852
|
-
if (!config2.strictTags) {
|
|
5853
|
-
return;
|
|
5854
|
-
}
|
|
5855
|
-
const availableTags = new Set(config2.tags.map((tag) => tag.name));
|
|
5856
|
-
for (const tag of tags) {
|
|
5857
|
-
if (!availableTags.has(tag)) {
|
|
5858
|
-
throw createNoTagsError(config2.tags, tag);
|
|
5859
|
-
}
|
|
5860
|
-
}
|
|
5861
|
-
}
|
|
5862
|
-
function createNoTagsError(availableTags, tag, prefix = "tag") {
|
|
5863
|
-
if (!availableTags.length) {
|
|
5864
|
-
throw new Error(`The Vitest config does't define any "tags", cannot apply "${tag}" ${prefix} for this test. See: https://vitest.dev/guide/test-tags`);
|
|
5865
|
-
}
|
|
5866
|
-
throw new Error(`The ${prefix} "${tag}" is not defined in the configuration. Available tags are:
|
|
5867
|
-
${availableTags.map((t) => `- ${t.name}${t.description ? `: ${t.description}` : ""}`).join("\n")}`);
|
|
5868
|
-
}
|
|
5869
|
-
function getNames(task) {
|
|
5870
|
-
const names = [task.name];
|
|
5871
|
-
let current = task;
|
|
5872
|
-
while (current?.suite) {
|
|
5873
|
-
current = current.suite;
|
|
5874
|
-
if (current?.name) {
|
|
5875
|
-
names.unshift(current.name);
|
|
5876
|
-
}
|
|
5877
|
-
}
|
|
5878
|
-
if (current !== task.file) {
|
|
5879
|
-
names.unshift(task.file.name);
|
|
5880
|
-
}
|
|
5881
|
-
return names;
|
|
5882
|
-
}
|
|
5883
|
-
function createTaskName(names, separator = " > ") {
|
|
5884
|
-
return names.filter((name) => name !== void 0).join(separator);
|
|
5885
|
-
}
|
|
5886
|
-
|
|
5887
|
-
// ../../node_modules/@vitest/runner/dist/index.js
|
|
5812
|
+
// ../../node_modules/@vitest/runner/dist/chunk-artifact.js
|
|
5888
5813
|
var PendingError = class extends Error {
|
|
5889
5814
|
constructor(message, task, note) {
|
|
5890
5815
|
super(message);
|
|
@@ -5931,6 +5856,7 @@ function setHooks(key, hooks) {
|
|
|
5931
5856
|
function getHooks(key) {
|
|
5932
5857
|
return hooksMap.get(key);
|
|
5933
5858
|
}
|
|
5859
|
+
var FIXTURE_STACK_TRACE_KEY = Symbol.for("VITEST_FIXTURE_STACK_TRACE");
|
|
5934
5860
|
var _TestFixtures = class _TestFixtures {
|
|
5935
5861
|
constructor(registrations) {
|
|
5936
5862
|
__publicField(this, "_suiteContexts");
|
|
@@ -5949,6 +5875,9 @@ var _TestFixtures = class _TestFixtures {
|
|
|
5949
5875
|
static getFileContexts(file) {
|
|
5950
5876
|
return _TestFixtures._definitions.map((f) => f.getFileContext(file));
|
|
5951
5877
|
}
|
|
5878
|
+
static isFixtureOptions(obj) {
|
|
5879
|
+
return isObject(obj) && Object.keys(obj).some((key) => _TestFixtures._fixtureOptionKeys.includes(key));
|
|
5880
|
+
}
|
|
5952
5881
|
extend(runner2, userFixtures) {
|
|
5953
5882
|
const { suite: suite2 } = getCurrentSuite();
|
|
5954
5883
|
const isTopLevel = !suite2 || suite2.file === suite2;
|
|
@@ -5999,7 +5928,7 @@ var _TestFixtures = class _TestFixtures {
|
|
|
5999
5928
|
let options;
|
|
6000
5929
|
let value;
|
|
6001
5930
|
let _options;
|
|
6002
|
-
if (Array.isArray(fn2) && fn2.length >= 2 &&
|
|
5931
|
+
if (Array.isArray(fn2) && fn2.length >= 2 && _TestFixtures.isFixtureOptions(fn2[1])) {
|
|
6003
5932
|
_options = fn2[1];
|
|
6004
5933
|
options = {
|
|
6005
5934
|
auto: _options.auto ?? false,
|
|
@@ -6047,6 +5976,9 @@ var _TestFixtures = class _TestFixtures {
|
|
|
6047
5976
|
deps,
|
|
6048
5977
|
parent
|
|
6049
5978
|
};
|
|
5979
|
+
if (isFixtureFunction(value)) {
|
|
5980
|
+
Object.assign(value, { [FIXTURE_STACK_TRACE_KEY]: new Error("STACK_TRACE_ERROR") });
|
|
5981
|
+
}
|
|
6050
5982
|
registrations.set(name, item);
|
|
6051
5983
|
if (item.scope === "worker" && (runner2.pool === "vmThreads" || runner2.pool === "vmForks")) {
|
|
6052
5984
|
item.scope = "file";
|
|
@@ -6186,7 +6118,7 @@ function resolveTestFixtureValue(fixture, context, cleanupFnArray) {
|
|
|
6186
6118
|
if (!isFixtureFunction(fixture.value)) {
|
|
6187
6119
|
return fixture.value;
|
|
6188
6120
|
}
|
|
6189
|
-
return resolveFixtureFunction(fixture.value, context, cleanupFnArray);
|
|
6121
|
+
return resolveFixtureFunction(fixture.value, fixture.name, context, cleanupFnArray);
|
|
6190
6122
|
}
|
|
6191
6123
|
var scopedFixturePromiseCache = /* @__PURE__ */ new WeakMap();
|
|
6192
6124
|
async function resolveScopeFixtureValue(fixtures, suite2, fixture) {
|
|
@@ -6207,7 +6139,7 @@ async function resolveScopeFixtureValue(fixtures, suite2, fixture) {
|
|
|
6207
6139
|
cleanupFnArrayMap.set(fixtureContext, []);
|
|
6208
6140
|
}
|
|
6209
6141
|
const cleanupFnFileArray = cleanupFnArrayMap.get(fixtureContext);
|
|
6210
|
-
const promise = resolveFixtureFunction(fixture.value, fixture.scope === "file" ? {
|
|
6142
|
+
const promise = resolveFixtureFunction(fixture.value, fixture.name, fixture.scope === "file" ? {
|
|
6211
6143
|
...workerContext,
|
|
6212
6144
|
...fileContext
|
|
6213
6145
|
} : fixtureContext, cleanupFnFileArray).then((value) => {
|
|
@@ -6218,8 +6150,9 @@ async function resolveScopeFixtureValue(fixtures, suite2, fixture) {
|
|
|
6218
6150
|
scopedFixturePromiseCache.set(fixture, promise);
|
|
6219
6151
|
return promise;
|
|
6220
6152
|
}
|
|
6221
|
-
async function resolveFixtureFunction(fixtureFn, context, cleanupFnArray) {
|
|
6153
|
+
async function resolveFixtureFunction(fixtureFn, fixtureName, context, cleanupFnArray) {
|
|
6222
6154
|
const useFnArgPromise = createDefer();
|
|
6155
|
+
const stackTraceError = FIXTURE_STACK_TRACE_KEY in fixtureFn && fixtureFn[FIXTURE_STACK_TRACE_KEY] instanceof Error ? fixtureFn[FIXTURE_STACK_TRACE_KEY] : void 0;
|
|
6223
6156
|
let isUseFnArgResolved = false;
|
|
6224
6157
|
const fixtureReturn = fixtureFn(context, async (useFnArg) => {
|
|
6225
6158
|
isUseFnArgResolved = true;
|
|
@@ -6230,6 +6163,14 @@ async function resolveFixtureFunction(fixtureFn, context, cleanupFnArray) {
|
|
|
6230
6163
|
await fixtureReturn;
|
|
6231
6164
|
});
|
|
6232
6165
|
await useReturnPromise;
|
|
6166
|
+
}).then(() => {
|
|
6167
|
+
if (!isUseFnArgResolved) {
|
|
6168
|
+
const error = new Error(`Fixture "${fixtureName}" returned without calling "use". Make sure to call "use" in every code path of the fixture function.`);
|
|
6169
|
+
if (stackTraceError?.stack) {
|
|
6170
|
+
error.stack = error.message + stackTraceError.stack.replace(stackTraceError.message, "");
|
|
6171
|
+
}
|
|
6172
|
+
useFnArgPromise.reject(error);
|
|
6173
|
+
}
|
|
6233
6174
|
}).catch((e) => {
|
|
6234
6175
|
if (!isUseFnArgResolved) {
|
|
6235
6176
|
useFnArgPromise.reject(e);
|
|
@@ -6358,6 +6299,46 @@ var _test;
|
|
|
6358
6299
|
function getCurrentTest() {
|
|
6359
6300
|
return _test;
|
|
6360
6301
|
}
|
|
6302
|
+
var kChainableContext = Symbol("kChainableContext");
|
|
6303
|
+
function getChainableContext(chainable) {
|
|
6304
|
+
return chainable?.[kChainableContext];
|
|
6305
|
+
}
|
|
6306
|
+
function createChainable(keys2, fn2, context) {
|
|
6307
|
+
function create(context2) {
|
|
6308
|
+
const chain2 = function(...args) {
|
|
6309
|
+
return fn2.apply(context2, args);
|
|
6310
|
+
};
|
|
6311
|
+
Object.assign(chain2, fn2);
|
|
6312
|
+
Object.defineProperty(chain2, kChainableContext, {
|
|
6313
|
+
value: {
|
|
6314
|
+
withContext: () => chain2.bind(context2),
|
|
6315
|
+
getFixtures: () => context2.fixtures,
|
|
6316
|
+
setContext: (key, value) => {
|
|
6317
|
+
context2[key] = value;
|
|
6318
|
+
},
|
|
6319
|
+
mergeContext: (ctx) => {
|
|
6320
|
+
Object.assign(context2, ctx);
|
|
6321
|
+
}
|
|
6322
|
+
},
|
|
6323
|
+
enumerable: false
|
|
6324
|
+
});
|
|
6325
|
+
for (const key of keys2) {
|
|
6326
|
+
Object.defineProperty(chain2, key, { get() {
|
|
6327
|
+
return create({
|
|
6328
|
+
...context2,
|
|
6329
|
+
[key]: true
|
|
6330
|
+
});
|
|
6331
|
+
} });
|
|
6332
|
+
}
|
|
6333
|
+
return chain2;
|
|
6334
|
+
}
|
|
6335
|
+
const chain = create(context ?? {});
|
|
6336
|
+
Object.defineProperty(chain, "fn", {
|
|
6337
|
+
value: fn2,
|
|
6338
|
+
enumerable: false
|
|
6339
|
+
});
|
|
6340
|
+
return chain;
|
|
6341
|
+
}
|
|
6361
6342
|
function getDefaultHookTimeout() {
|
|
6362
6343
|
return getRunner().config.hookTimeout;
|
|
6363
6344
|
}
|
|
@@ -6466,6 +6447,50 @@ function createTestHook(name, handler) {
|
|
|
6466
6447
|
return handler(current, fn2, timeout);
|
|
6467
6448
|
};
|
|
6468
6449
|
}
|
|
6450
|
+
function findTestFileStackTrace(testFilePath, error) {
|
|
6451
|
+
const lines = error.split("\n").slice(1);
|
|
6452
|
+
for (const line of lines) {
|
|
6453
|
+
const stack = parseSingleStack(line);
|
|
6454
|
+
if (stack && stack.file === testFilePath) {
|
|
6455
|
+
return stack;
|
|
6456
|
+
}
|
|
6457
|
+
}
|
|
6458
|
+
}
|
|
6459
|
+
function validateTags(config2, tags) {
|
|
6460
|
+
if (!config2.strictTags) {
|
|
6461
|
+
return;
|
|
6462
|
+
}
|
|
6463
|
+
const availableTags = new Set(config2.tags.map((tag) => tag.name));
|
|
6464
|
+
for (const tag of tags) {
|
|
6465
|
+
if (!availableTags.has(tag)) {
|
|
6466
|
+
throw createNoTagsError(config2.tags, tag);
|
|
6467
|
+
}
|
|
6468
|
+
}
|
|
6469
|
+
}
|
|
6470
|
+
function createNoTagsError(availableTags, tag, prefix = "tag") {
|
|
6471
|
+
if (!availableTags.length) {
|
|
6472
|
+
throw new Error(`The Vitest config does't define any "tags", cannot apply "${tag}" ${prefix} for this test. See: https://vitest.dev/guide/test-tags`);
|
|
6473
|
+
}
|
|
6474
|
+
throw new Error(`The ${prefix} "${tag}" is not defined in the configuration. Available tags are:
|
|
6475
|
+
${availableTags.map((t) => `- ${t.name}${t.description ? `: ${t.description}` : ""}`).join("\n")}`);
|
|
6476
|
+
}
|
|
6477
|
+
function getNames(task) {
|
|
6478
|
+
const names = [task.name];
|
|
6479
|
+
let current = task;
|
|
6480
|
+
while (current?.suite) {
|
|
6481
|
+
current = current.suite;
|
|
6482
|
+
if (current?.name) {
|
|
6483
|
+
names.unshift(current.name);
|
|
6484
|
+
}
|
|
6485
|
+
}
|
|
6486
|
+
if (current !== task.file) {
|
|
6487
|
+
names.unshift(task.file.name);
|
|
6488
|
+
}
|
|
6489
|
+
return names;
|
|
6490
|
+
}
|
|
6491
|
+
function createTaskName(names, separator = " > ") {
|
|
6492
|
+
return names.filter((name) => name !== void 0).join(separator);
|
|
6493
|
+
}
|
|
6469
6494
|
var suite = createSuite();
|
|
6470
6495
|
var test2 = createTest(function(name, optionsOrFn, optionsOrTest) {
|
|
6471
6496
|
if (getCurrentTest()) {
|
|
@@ -6896,7 +6921,7 @@ function createTaskCollector(fn2) {
|
|
|
6896
6921
|
fixtureOptions = optionsOrFn;
|
|
6897
6922
|
fixtureValue = maybeFn;
|
|
6898
6923
|
} else {
|
|
6899
|
-
if (optionsOrFn !== null && typeof optionsOrFn === "object" && !Array.isArray(optionsOrFn) && (
|
|
6924
|
+
if (optionsOrFn !== null && typeof optionsOrFn === "object" && !Array.isArray(optionsOrFn) && TestFixtures.isFixtureOptions(optionsOrFn)) {
|
|
6900
6925
|
fixtureOptions = optionsOrFn;
|
|
6901
6926
|
fixtureValue = {};
|
|
6902
6927
|
} else {
|
|
@@ -11927,18 +11952,16 @@ var ChaiStyleAssertions = (chai, utils) => {
|
|
|
11927
11952
|
});
|
|
11928
11953
|
}
|
|
11929
11954
|
function defMethod(name, delegateTo) {
|
|
11930
|
-
utils.
|
|
11955
|
+
utils.addMethod(chai.Assertion.prototype, name, function(...args) {
|
|
11931
11956
|
const jestMethod = chai.Assertion.prototype[delegateTo];
|
|
11932
11957
|
if (!jestMethod) {
|
|
11933
11958
|
throw new Error(`Cannot delegate to ${String(delegateTo)}: method not found. Ensure JestChaiExpect plugin is loaded first.`);
|
|
11934
11959
|
}
|
|
11935
11960
|
return jestMethod.call(this, ...args);
|
|
11936
|
-
}, () => {
|
|
11937
11961
|
});
|
|
11938
11962
|
}
|
|
11939
11963
|
defProperty("called", "toHaveBeenCalled");
|
|
11940
11964
|
defProperty("calledOnce", "toHaveBeenCalledOnce");
|
|
11941
|
-
defProperty("returned", "toHaveReturned");
|
|
11942
11965
|
defPropertyWithArgs("calledTwice", "toHaveBeenCalledTimes", 2);
|
|
11943
11966
|
defPropertyWithArgs("calledThrice", "toHaveBeenCalledTimes", 3);
|
|
11944
11967
|
defMethod("callCount", "toHaveBeenCalledTimes");
|
|
@@ -11946,6 +11969,7 @@ var ChaiStyleAssertions = (chai, utils) => {
|
|
|
11946
11969
|
defMethod("calledOnceWith", "toHaveBeenCalledExactlyOnceWith");
|
|
11947
11970
|
defMethod("lastCalledWith", "toHaveBeenLastCalledWith");
|
|
11948
11971
|
defMethod("nthCalledWith", "toHaveBeenNthCalledWith");
|
|
11972
|
+
defMethod("returned", "toHaveReturned");
|
|
11949
11973
|
defMethod("returnedWith", "toHaveReturnedWith");
|
|
11950
11974
|
defMethod("returnedTimes", "toHaveReturnedTimes");
|
|
11951
11975
|
defMethod("lastReturnedWith", "toHaveLastReturnedWith");
|
|
@@ -13493,7 +13517,7 @@ var JestChaiExpect = (chai, utils) => {
|
|
|
13493
13517
|
}
|
|
13494
13518
|
throw err;
|
|
13495
13519
|
});
|
|
13496
|
-
return recordAsyncExpect(test5, promise, createAssertionMessage(utils, this, !!args.length), error);
|
|
13520
|
+
return recordAsyncExpect(test5, promise, createAssertionMessage(utils, this, !!args.length), error, utils.flag(this, "soft"));
|
|
13497
13521
|
};
|
|
13498
13522
|
} });
|
|
13499
13523
|
return proxy;
|
|
@@ -13534,7 +13558,7 @@ var JestChaiExpect = (chai, utils) => {
|
|
|
13534
13558
|
}
|
|
13535
13559
|
throw err;
|
|
13536
13560
|
});
|
|
13537
|
-
return recordAsyncExpect(test5, promise, createAssertionMessage(utils, this, !!args.length), error);
|
|
13561
|
+
return recordAsyncExpect(test5, promise, createAssertionMessage(utils, this, !!args.length), error, utils.flag(this, "soft"));
|
|
13538
13562
|
};
|
|
13539
13563
|
} });
|
|
13540
13564
|
return proxy;
|
|
@@ -14577,7 +14601,7 @@ function resetDate() {
|
|
|
14577
14601
|
}
|
|
14578
14602
|
var { get: get2 } = Reflect;
|
|
14579
14603
|
|
|
14580
|
-
// ../../node_modules/vitest/dist/chunks/test.
|
|
14604
|
+
// ../../node_modules/vitest/dist/chunks/test.CBQUpOM3.js
|
|
14581
14605
|
var unsupported = [
|
|
14582
14606
|
"matchSnapshot",
|
|
14583
14607
|
"toMatchSnapshot",
|