@vitest/runner 4.0.0-beta.4 → 4.0.0-beta.6
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/LICENSE +1 -1
- package/dist/chunk-hooks.js +28 -20
- package/package.json +2 -2
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2021-Present Vitest
|
|
3
|
+
Copyright (c) 2021-Present VoidZero Inc. and Vitest contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/dist/chunk-hooks.js
CHANGED
|
@@ -869,7 +869,7 @@ function createSuiteHooks() {
|
|
|
869
869
|
}
|
|
870
870
|
function parseArguments(optionsOrFn, optionsOrTest) {
|
|
871
871
|
let options = {};
|
|
872
|
-
let fn
|
|
872
|
+
let fn;
|
|
873
873
|
// it('', () => {}, { retry: 2 })
|
|
874
874
|
if (typeof optionsOrTest === "object") {
|
|
875
875
|
// it('', { retry: 2 }, { retry: 3 })
|
|
@@ -921,6 +921,9 @@ function createSuiteCollector(name, factory = () => {}, mode, each, suiteOptions
|
|
|
921
921
|
annotations: []
|
|
922
922
|
};
|
|
923
923
|
const handler = options.handler;
|
|
924
|
+
if (task.mode === "run" && !handler) {
|
|
925
|
+
task.mode = "todo";
|
|
926
|
+
}
|
|
924
927
|
if (options.concurrent || !options.sequential && runner.config.sequence.concurrent) {
|
|
925
928
|
task.concurrent = true;
|
|
926
929
|
}
|
|
@@ -1054,7 +1057,7 @@ function createSuiteCollector(name, factory = () => {}, mode, each, suiteOptions
|
|
|
1054
1057
|
return collector;
|
|
1055
1058
|
}
|
|
1056
1059
|
function withAwaitAsyncAssertions(fn, task) {
|
|
1057
|
-
return async (...args) => {
|
|
1060
|
+
return (async (...args) => {
|
|
1058
1061
|
const fnResult = await fn(...args);
|
|
1059
1062
|
// some async expect will be added to this array, in case user forget to await them
|
|
1060
1063
|
if (task.promises) {
|
|
@@ -1065,14 +1068,17 @@ function withAwaitAsyncAssertions(fn, task) {
|
|
|
1065
1068
|
}
|
|
1066
1069
|
}
|
|
1067
1070
|
return fnResult;
|
|
1068
|
-
};
|
|
1071
|
+
});
|
|
1069
1072
|
}
|
|
1070
1073
|
function createSuite() {
|
|
1071
1074
|
function suiteFn(name, factoryOrOptions, optionsOrFactory) {
|
|
1072
1075
|
var _currentSuite$options;
|
|
1073
|
-
|
|
1076
|
+
let mode = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
|
|
1074
1077
|
const currentSuite = collectorContext.currentSuite || defaultSuite;
|
|
1075
1078
|
let { options, handler: factory } = parseArguments(factoryOrOptions, optionsOrFactory);
|
|
1079
|
+
if (mode === "run" && !factory) {
|
|
1080
|
+
mode = "todo";
|
|
1081
|
+
}
|
|
1076
1082
|
const isConcurrentSpecified = options.concurrent || this.concurrent || options.sequential === false;
|
|
1077
1083
|
const isSequentialSpecified = options.sequential || this.sequential || options.concurrent === false;
|
|
1078
1084
|
// inherit options from current suite
|
|
@@ -1103,15 +1109,15 @@ function createSuite() {
|
|
|
1103
1109
|
const items = Array.isArray(i) ? i : [i];
|
|
1104
1110
|
if (fnFirst) {
|
|
1105
1111
|
if (arrayOnlyCases) {
|
|
1106
|
-
suite(formatTitle(_name, items, idx), () => handler(...items), options);
|
|
1112
|
+
suite(formatTitle(_name, items, idx), handler ? () => handler(...items) : undefined, options);
|
|
1107
1113
|
} else {
|
|
1108
|
-
suite(formatTitle(_name, items, idx), () => handler(i), options);
|
|
1114
|
+
suite(formatTitle(_name, items, idx), handler ? () => handler(i) : undefined, options);
|
|
1109
1115
|
}
|
|
1110
1116
|
} else {
|
|
1111
1117
|
if (arrayOnlyCases) {
|
|
1112
|
-
suite(formatTitle(_name, items, idx), options, () => handler(...items));
|
|
1118
|
+
suite(formatTitle(_name, items, idx), options, handler ? () => handler(...items) : undefined);
|
|
1113
1119
|
} else {
|
|
1114
|
-
suite(formatTitle(_name, items, idx), options, () => handler(i));
|
|
1120
|
+
suite(formatTitle(_name, items, idx), options, handler ? () => handler(i) : undefined);
|
|
1115
1121
|
}
|
|
1116
1122
|
}
|
|
1117
1123
|
});
|
|
@@ -1126,7 +1132,7 @@ function createSuite() {
|
|
|
1126
1132
|
const name_ = formatName(name);
|
|
1127
1133
|
const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
|
|
1128
1134
|
cases.forEach((item, idx) => {
|
|
1129
|
-
suite(formatTitle(name_, toArray(item), idx), options, () => handler(item));
|
|
1135
|
+
suite(formatTitle(name_, toArray(item), idx), options, handler ? () => handler(item) : undefined);
|
|
1130
1136
|
});
|
|
1131
1137
|
};
|
|
1132
1138
|
};
|
|
@@ -1158,15 +1164,15 @@ function createTaskCollector(fn, context) {
|
|
|
1158
1164
|
const items = Array.isArray(i) ? i : [i];
|
|
1159
1165
|
if (fnFirst) {
|
|
1160
1166
|
if (arrayOnlyCases) {
|
|
1161
|
-
test(formatTitle(_name, items, idx), () => handler(...items), options);
|
|
1167
|
+
test(formatTitle(_name, items, idx), handler ? () => handler(...items) : undefined, options);
|
|
1162
1168
|
} else {
|
|
1163
|
-
test(formatTitle(_name, items, idx), () => handler(i), options);
|
|
1169
|
+
test(formatTitle(_name, items, idx), handler ? () => handler(i) : undefined, options);
|
|
1164
1170
|
}
|
|
1165
1171
|
} else {
|
|
1166
1172
|
if (arrayOnlyCases) {
|
|
1167
|
-
test(formatTitle(_name, items, idx), options, () => handler(...items));
|
|
1173
|
+
test(formatTitle(_name, items, idx), options, handler ? () => handler(...items) : undefined);
|
|
1168
1174
|
} else {
|
|
1169
|
-
test(formatTitle(_name, items, idx), options, () => handler(i));
|
|
1175
|
+
test(formatTitle(_name, items, idx), options, handler ? () => handler(i) : undefined);
|
|
1170
1176
|
}
|
|
1171
1177
|
}
|
|
1172
1178
|
});
|
|
@@ -1183,9 +1189,11 @@ function createTaskCollector(fn, context) {
|
|
|
1183
1189
|
const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
|
|
1184
1190
|
cases.forEach((item, idx) => {
|
|
1185
1191
|
// monkey-patch handler to allow parsing fixture
|
|
1186
|
-
const handlerWrapper = (ctx) => handler(item, ctx);
|
|
1187
|
-
handlerWrapper
|
|
1188
|
-
|
|
1192
|
+
const handlerWrapper = handler ? (ctx) => handler(item, ctx) : undefined;
|
|
1193
|
+
if (handlerWrapper) {
|
|
1194
|
+
handlerWrapper.__VITEST_FIXTURE_INDEX__ = 1;
|
|
1195
|
+
handlerWrapper.toString = () => handler.toString();
|
|
1196
|
+
}
|
|
1189
1197
|
test(formatTitle(_name, toArray(item), idx), options, handlerWrapper);
|
|
1190
1198
|
});
|
|
1191
1199
|
};
|
|
@@ -1855,7 +1863,7 @@ function withTimeout(fn, timeout, isHook = false, stackTraceError, onTimeout) {
|
|
|
1855
1863
|
}
|
|
1856
1864
|
const { setTimeout, clearTimeout } = getSafeTimers();
|
|
1857
1865
|
// this function name is used to filter error in test/cli/test/fails.test.ts
|
|
1858
|
-
return function runWithTimeout(...args) {
|
|
1866
|
+
return (function runWithTimeout(...args) {
|
|
1859
1867
|
const startTime = now();
|
|
1860
1868
|
const runner = getRunner();
|
|
1861
1869
|
runner._currentTaskStartTime = startTime;
|
|
@@ -1908,7 +1916,7 @@ catch (error) {
|
|
|
1908
1916
|
reject(error);
|
|
1909
1917
|
}
|
|
1910
1918
|
});
|
|
1911
|
-
};
|
|
1919
|
+
});
|
|
1912
1920
|
}
|
|
1913
1921
|
const abortControllers = new WeakMap();
|
|
1914
1922
|
function abortIfTimeout([context], error) {
|
|
@@ -1970,7 +1978,7 @@ function createTestContext(test, runner) {
|
|
|
1970
1978
|
test.annotations.push(resolvedAnnotation);
|
|
1971
1979
|
return resolvedAnnotation;
|
|
1972
1980
|
}
|
|
1973
|
-
context.annotate = (message, type, attachment) => {
|
|
1981
|
+
context.annotate = ((message, type, attachment) => {
|
|
1974
1982
|
if (test.result && test.result.state !== "run") {
|
|
1975
1983
|
throw new Error(`Cannot annotate tests outside of the test run. The test "${test.name}" finished running with the "${test.result.state}" state already.`);
|
|
1976
1984
|
}
|
|
@@ -1988,7 +1996,7 @@ function createTestContext(test, runner) {
|
|
|
1988
1996
|
} else {
|
|
1989
1997
|
return recordAsyncAnnotation(test, annotate(message, location, type, attachment));
|
|
1990
1998
|
}
|
|
1991
|
-
};
|
|
1999
|
+
});
|
|
1992
2000
|
context.onTestFailed = (handler, timeout) => {
|
|
1993
2001
|
test.onFailed || (test.onFailed = []);
|
|
1994
2002
|
test.onFailed.push(withTimeout(handler, timeout ?? runner.config.hookTimeout, true, new Error("STACK_TRACE_ERROR"), (_, error) => abortController.abort(error)));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/runner",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.0-beta.
|
|
4
|
+
"version": "4.0.0-beta.6",
|
|
5
5
|
"description": "Vitest test runner",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"pathe": "^2.0.3",
|
|
42
42
|
"strip-literal": "^3.0.0",
|
|
43
|
-
"@vitest/utils": "4.0.0-beta.
|
|
43
|
+
"@vitest/utils": "4.0.0-beta.6"
|
|
44
44
|
},
|
|
45
45
|
"scripts": {
|
|
46
46
|
"build": "rimraf dist && rollup -c",
|