vest 5.0.0-dev-ec989a → 5.0.0-dev-ae6b14
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/cjs/vest.development.js +199 -197
- package/dist/cjs/vest.production.js +1 -1
- package/dist/es/vest.development.js +165 -163
- package/dist/es/vest.production.js +1 -1
- package/dist/umd/vest.development.js +202 -200
- package/dist/umd/vest.production.js +1 -1
- package/package.json +6 -6
- package/testUtils/asVestTest.ts +1 -1
- package/types/classnames.d.ts +1 -1
- package/types/classnames.d.ts.map +1 -1
- package/types/parser.d.ts +1 -1
- package/types/parser.d.ts.map +1 -1
- package/types/promisify.d.ts +1 -1
- package/types/promisify.d.ts.map +1 -1
- package/types/vest.d.ts +6 -6
- package/types/vest.d.ts.map +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('n4s'), require('vest-
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'n4s', 'vest-
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.vest = {}, global.n4s, global["vest-
|
|
5
|
-
})(this, (function (exports, n4s,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('n4s'), require('vest-utils'), require('vestjs-runtime'), require('context')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'n4s', 'vest-utils', 'vestjs-runtime', 'context'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.vest = {}, global.n4s, global["vest-utils"], global["vestjs-runtime"], global.context));
|
|
5
|
+
})(this, (function (exports, n4s, vestUtils, vestjsRuntime, context) { 'use strict';
|
|
6
6
|
|
|
7
7
|
var OptionalFieldTypes;
|
|
8
8
|
(function (OptionalFieldTypes) {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
|
|
13
13
|
// @vx-allow use-use
|
|
14
14
|
function optional(optionals) {
|
|
15
|
-
const suiteRoot =
|
|
15
|
+
const suiteRoot = vestjsRuntime.VestRuntime.useAvailableRoot();
|
|
16
16
|
// There are two types of optional field declarations:
|
|
17
17
|
// 1 AUTO: Vest will automatically determine whether the field should be omitted
|
|
18
18
|
// Based on the current run. Vest will ommit "auto" added fields without any
|
|
@@ -47,9 +47,16 @@
|
|
|
47
47
|
if (!fieldName) {
|
|
48
48
|
return false;
|
|
49
49
|
}
|
|
50
|
-
return ((_c = (_b = (_a =
|
|
50
|
+
return ((_c = (_b = (_a = vestjsRuntime.VestRuntime.useAvailableRoot()) === null || _a === void 0 ? void 0 : _a.getOptionalField(fieldName)) === null || _b === void 0 ? void 0 : _b.applied) !== null && _c !== void 0 ? _c : false);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
exports.Modes = void 0;
|
|
54
|
+
(function (Modes) {
|
|
55
|
+
Modes["EAGER"] = "EAGER";
|
|
56
|
+
Modes["ALL"] = "ALL";
|
|
57
|
+
Modes["ONE"] = "ONE";
|
|
58
|
+
})(exports.Modes || (exports.Modes = {}));
|
|
59
|
+
|
|
53
60
|
var Events;
|
|
54
61
|
(function (Events) {
|
|
55
62
|
Events["TEST_RUN_STARTED"] = "test_run_started";
|
|
@@ -63,7 +70,7 @@
|
|
|
63
70
|
Events["DONE_TEST_OMISSION_PASS"] = "DONE_TEST_OMISSION_PASS";
|
|
64
71
|
})(Events || (Events = {}));
|
|
65
72
|
|
|
66
|
-
class IsolateSuite extends
|
|
73
|
+
class IsolateSuite extends vestjsRuntime.Isolate {
|
|
67
74
|
constructor() {
|
|
68
75
|
super(...arguments);
|
|
69
76
|
this.optional = {};
|
|
@@ -93,10 +100,10 @@
|
|
|
93
100
|
suiteName,
|
|
94
101
|
suiteResultCache,
|
|
95
102
|
};
|
|
96
|
-
return
|
|
103
|
+
return vestjsRuntime.VestRuntime.createRef(stateRef);
|
|
97
104
|
}
|
|
98
105
|
function useX() {
|
|
99
|
-
return
|
|
106
|
+
return vestjsRuntime.VestRuntime.useXAppData();
|
|
100
107
|
}
|
|
101
108
|
function useDoneCallbacks() {
|
|
102
109
|
return useX().doneCallbacks();
|
|
@@ -126,29 +133,50 @@
|
|
|
126
133
|
}
|
|
127
134
|
function useResetSuite() {
|
|
128
135
|
useResetCallbacks();
|
|
129
|
-
|
|
136
|
+
vestjsRuntime.VestRuntime.reset();
|
|
130
137
|
}
|
|
131
138
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
139
|
+
const SuiteContext = context.createCascade((ctxRef, parentContext) => {
|
|
140
|
+
if (parentContext) {
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
return vestUtils.assign({
|
|
144
|
+
exclusion: {
|
|
145
|
+
tests: {},
|
|
146
|
+
groups: {},
|
|
147
|
+
},
|
|
148
|
+
inclusion: {},
|
|
149
|
+
mode: vestUtils.tinyState.createTinyState(exports.Modes.EAGER),
|
|
150
|
+
testMemoCache,
|
|
151
|
+
}, ctxRef);
|
|
152
|
+
});
|
|
153
|
+
function useCurrentTest(msg) {
|
|
154
|
+
return SuiteContext.useX(msg).currentTest;
|
|
155
|
+
}
|
|
156
|
+
function useGroupName() {
|
|
157
|
+
return SuiteContext.useX().groupName;
|
|
158
|
+
}
|
|
159
|
+
function useExclusion(hookError) {
|
|
160
|
+
return SuiteContext.useX(hookError).exclusion;
|
|
161
|
+
}
|
|
162
|
+
function useInclusion() {
|
|
163
|
+
return SuiteContext.useX().inclusion;
|
|
164
|
+
}
|
|
165
|
+
function useMode() {
|
|
166
|
+
return SuiteContext.useX().mode();
|
|
167
|
+
}
|
|
168
|
+
function useSkipped() {
|
|
169
|
+
var _a;
|
|
170
|
+
return (_a = SuiteContext.useX().skipped) !== null && _a !== void 0 ? _a : false;
|
|
171
|
+
}
|
|
172
|
+
function useOmitted() {
|
|
173
|
+
var _a;
|
|
174
|
+
return (_a = SuiteContext.useX().omitted) !== null && _a !== void 0 ? _a : false;
|
|
175
|
+
}
|
|
176
|
+
const testMemoCache = vestUtils.cache(10);
|
|
177
|
+
function useTestMemoCache() {
|
|
178
|
+
return SuiteContext.useX().testMemoCache;
|
|
146
179
|
}
|
|
147
|
-
var TestSeverity;
|
|
148
|
-
(function (TestSeverity) {
|
|
149
|
-
TestSeverity["Error"] = "error";
|
|
150
|
-
TestSeverity["Warning"] = "warning";
|
|
151
|
-
})(TestSeverity || (TestSeverity = {}));
|
|
152
180
|
|
|
153
181
|
var ErrorStrings;
|
|
154
182
|
(function (ErrorStrings) {
|
|
@@ -187,6 +215,27 @@
|
|
|
187
215
|
}
|
|
188
216
|
}
|
|
189
217
|
|
|
218
|
+
var Severity;
|
|
219
|
+
(function (Severity) {
|
|
220
|
+
Severity["WARNINGS"] = "warnings";
|
|
221
|
+
Severity["ERRORS"] = "errors";
|
|
222
|
+
})(Severity || (Severity = {}));
|
|
223
|
+
var SeverityCount;
|
|
224
|
+
(function (SeverityCount) {
|
|
225
|
+
SeverityCount["ERROR_COUNT"] = "errorCount";
|
|
226
|
+
SeverityCount["WARN_COUNT"] = "warnCount";
|
|
227
|
+
})(SeverityCount || (SeverityCount = {}));
|
|
228
|
+
function countKeyBySeverity(severity) {
|
|
229
|
+
return severity === Severity.ERRORS
|
|
230
|
+
? SeverityCount.ERROR_COUNT
|
|
231
|
+
: SeverityCount.WARN_COUNT;
|
|
232
|
+
}
|
|
233
|
+
var TestSeverity;
|
|
234
|
+
(function (TestSeverity) {
|
|
235
|
+
TestSeverity["Error"] = "error";
|
|
236
|
+
TestSeverity["Warning"] = "warning";
|
|
237
|
+
})(TestSeverity || (TestSeverity = {}));
|
|
238
|
+
|
|
190
239
|
var _a, _b;
|
|
191
240
|
class SummaryBase {
|
|
192
241
|
constructor() {
|
|
@@ -226,6 +275,49 @@
|
|
|
226
275
|
return testObject.groupName === groupName;
|
|
227
276
|
}
|
|
228
277
|
|
|
278
|
+
/**
|
|
279
|
+
* Checks that a given test object matches the currently specified severity level
|
|
280
|
+
*/
|
|
281
|
+
function nonMatchingSeverityProfile(severity, testObject) {
|
|
282
|
+
return vestUtils.either(severity === Severity.WARNINGS, testObject.warns());
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* The difference between this file and hasFailures is that hasFailures uses the static
|
|
287
|
+
* summary object, while this one uses the actual validation state
|
|
288
|
+
*/
|
|
289
|
+
function hasErrorsByTestObjects(fieldName) {
|
|
290
|
+
return hasFailuresByTestObjects(Severity.ERRORS, fieldName);
|
|
291
|
+
}
|
|
292
|
+
function hasFailuresByTestObjects(severityKey, fieldName) {
|
|
293
|
+
return TestWalker.someTests(testObject => {
|
|
294
|
+
return hasFailuresByTestObject(testObject, severityKey, fieldName);
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
function hasGroupFailuresByTestObjects(severityKey, groupName, fieldName) {
|
|
298
|
+
return TestWalker.someTests(testObject => {
|
|
299
|
+
if (nonMatchingGroupName(testObject, groupName)) {
|
|
300
|
+
return false;
|
|
301
|
+
}
|
|
302
|
+
return hasFailuresByTestObject(testObject, severityKey, fieldName);
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Determines whether a certain test profile has failures.
|
|
307
|
+
*/
|
|
308
|
+
function hasFailuresByTestObject(testObject, severityKey, fieldName) {
|
|
309
|
+
if (!testObject.hasFailures()) {
|
|
310
|
+
return false;
|
|
311
|
+
}
|
|
312
|
+
if (nonMatchingFieldName(testObject, fieldName)) {
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
if (nonMatchingSeverityProfile(severityKey, testObject)) {
|
|
316
|
+
return false;
|
|
317
|
+
}
|
|
318
|
+
return true;
|
|
319
|
+
}
|
|
320
|
+
|
|
229
321
|
function useShouldAddValidProperty(fieldName) {
|
|
230
322
|
// Is the field optional, and the optional condition is applied
|
|
231
323
|
if (useIsOptionalFiedApplied(fieldName)) {
|
|
@@ -317,7 +409,7 @@
|
|
|
317
409
|
// Does the test belong to an optional field,
|
|
318
410
|
// and the test itself is still in an indeterminate state?
|
|
319
411
|
var _a;
|
|
320
|
-
return (((_a =
|
|
412
|
+
return (((_a = vestjsRuntime.VestRuntime.useAvailableRoot()) === null || _a === void 0 ? void 0 : _a.getOptionalField(testObject.fieldName).type) === OptionalFieldTypes.AUTO && testObject.awaitsResolution());
|
|
321
413
|
}
|
|
322
414
|
|
|
323
415
|
function useProduceSuiteSummary() {
|
|
@@ -593,7 +685,7 @@
|
|
|
593
685
|
*/
|
|
594
686
|
// @vx-allow use-use
|
|
595
687
|
function skipWhen(condition, callback) {
|
|
596
|
-
|
|
688
|
+
vestjsRuntime.Isolate.create(() => {
|
|
597
689
|
SuiteContext.run({
|
|
598
690
|
skipped:
|
|
599
691
|
// Checking for nested conditional. If we're in a nested skipWhen,
|
|
@@ -740,6 +832,51 @@
|
|
|
740
832
|
return false;
|
|
741
833
|
}
|
|
742
834
|
|
|
835
|
+
/**
|
|
836
|
+
* Sets the current execution mode for the current suite.
|
|
837
|
+
*
|
|
838
|
+
* Supported modes:
|
|
839
|
+
* - `EAGER` - (default) Runs all tests, but stops on first failure for each given field.
|
|
840
|
+
* - `ALL` - Runs all tests, regardless of failures.
|
|
841
|
+
* - `ONE` - Stops suite execution on first failure of any field.
|
|
842
|
+
*
|
|
843
|
+
* @example
|
|
844
|
+
* ```js
|
|
845
|
+
* import {Modes, create} from 'vest';
|
|
846
|
+
*
|
|
847
|
+
* const suite = create('suite_name', () => {
|
|
848
|
+
* vest.mode(Modes.ALL);
|
|
849
|
+
*
|
|
850
|
+
* // ...
|
|
851
|
+
* });
|
|
852
|
+
* ```
|
|
853
|
+
* @param 'ALL' | 'EAGER' | 'ONE' mode - The mode to set.
|
|
854
|
+
*/
|
|
855
|
+
// @vx-allow use-use
|
|
856
|
+
function mode(mode) {
|
|
857
|
+
const [, setMode] = useMode();
|
|
858
|
+
setMode(mode);
|
|
859
|
+
}
|
|
860
|
+
function useIsMode(mode) {
|
|
861
|
+
const [currentMode] = useMode();
|
|
862
|
+
return currentMode === mode;
|
|
863
|
+
}
|
|
864
|
+
function useIsEager() {
|
|
865
|
+
return useIsMode(exports.Modes.EAGER);
|
|
866
|
+
}
|
|
867
|
+
function useIsOne() {
|
|
868
|
+
return useIsMode(exports.Modes.ONE);
|
|
869
|
+
}
|
|
870
|
+
function useShouldSkipBasedOnMode(testObject) {
|
|
871
|
+
if (useIsOne()) {
|
|
872
|
+
return hasErrorsByTestObjects();
|
|
873
|
+
}
|
|
874
|
+
if (useIsEager()) {
|
|
875
|
+
return hasErrorsByTestObjects(testObject.fieldName);
|
|
876
|
+
}
|
|
877
|
+
return false;
|
|
878
|
+
}
|
|
879
|
+
|
|
743
880
|
/**
|
|
744
881
|
* Conditionally omits tests from the suite.
|
|
745
882
|
*
|
|
@@ -751,7 +888,7 @@
|
|
|
751
888
|
*/
|
|
752
889
|
// @vx-allow use-use
|
|
753
890
|
function omitWhen(conditional, callback) {
|
|
754
|
-
|
|
891
|
+
vestjsRuntime.Isolate.create(() => {
|
|
755
892
|
SuiteContext.run({
|
|
756
893
|
omitted: useWithinActiveOmitWhen() ||
|
|
757
894
|
vestUtils.optionalFunctionValue(conditional, vestUtils.optionalFunctionValue(useCreateSuiteResult)),
|
|
@@ -818,7 +955,7 @@
|
|
|
818
955
|
}
|
|
819
956
|
function handleCollision(newNode, prevNode) {
|
|
820
957
|
if (newNode.usesKey()) {
|
|
821
|
-
return IsolateTest.cast(
|
|
958
|
+
return IsolateTest.cast(vestjsRuntime.Reconciler.handleIsolateNodeWithKey(newNode));
|
|
822
959
|
}
|
|
823
960
|
if (nodeReorderDetected(newNode, prevNode)) {
|
|
824
961
|
return onNodeReorder(newNode, prevNode);
|
|
@@ -841,7 +978,7 @@
|
|
|
841
978
|
}
|
|
842
979
|
function onNodeReorder(newNode, prevNode) {
|
|
843
980
|
throwTestOrderError(newNode, prevNode);
|
|
844
|
-
|
|
981
|
+
vestjsRuntime.Reconciler.removeAllNextNodesInIsolate();
|
|
845
982
|
return newNode;
|
|
846
983
|
}
|
|
847
984
|
function usePickNode(historyNode, currentNode) {
|
|
@@ -850,7 +987,7 @@
|
|
|
850
987
|
}
|
|
851
988
|
function handleNoHistoryNode(testNode) {
|
|
852
989
|
if (testNode.usesKey()) {
|
|
853
|
-
return IsolateTest.cast(
|
|
990
|
+
return IsolateTest.cast(vestjsRuntime.Reconciler.handleIsolateNodeWithKey(testNode));
|
|
854
991
|
}
|
|
855
992
|
return testNode;
|
|
856
993
|
}
|
|
@@ -928,7 +1065,7 @@
|
|
|
928
1065
|
return vestUtils.isUndefined(message) && vestUtils.isStringValue(error);
|
|
929
1066
|
}
|
|
930
1067
|
|
|
931
|
-
class IsolateTest extends
|
|
1068
|
+
class IsolateTest extends vestjsRuntime.Isolate {
|
|
932
1069
|
constructor({ fieldName, testFn, message, groupName, key = null, }) {
|
|
933
1070
|
super();
|
|
934
1071
|
this.children = null;
|
|
@@ -1071,17 +1208,17 @@
|
|
|
1071
1208
|
|
|
1072
1209
|
class TestWalker {
|
|
1073
1210
|
static defaultRoot() {
|
|
1074
|
-
return
|
|
1211
|
+
return vestjsRuntime.VestRuntime.useAvailableRoot();
|
|
1075
1212
|
}
|
|
1076
1213
|
static hasNoTests(root = TestWalker.defaultRoot()) {
|
|
1077
1214
|
if (!root)
|
|
1078
1215
|
return true;
|
|
1079
|
-
return !
|
|
1216
|
+
return !vestjsRuntime.Walker.has(root, IsolateTest.is);
|
|
1080
1217
|
}
|
|
1081
1218
|
static someIncompleteTests(predicate, root = TestWalker.defaultRoot()) {
|
|
1082
1219
|
if (!root)
|
|
1083
1220
|
return false;
|
|
1084
|
-
return
|
|
1221
|
+
return vestjsRuntime.Walker.some(root, isolate => {
|
|
1085
1222
|
IsolateTest.isX(isolate);
|
|
1086
1223
|
return isolate.isPending() && predicate(isolate);
|
|
1087
1224
|
}, IsolateTest.is);
|
|
@@ -1089,7 +1226,7 @@
|
|
|
1089
1226
|
static someTests(predicate, root = TestWalker.defaultRoot()) {
|
|
1090
1227
|
if (!root)
|
|
1091
1228
|
return false;
|
|
1092
|
-
return
|
|
1229
|
+
return vestjsRuntime.Walker.some(root, isolate => {
|
|
1093
1230
|
IsolateTest.isX(isolate);
|
|
1094
1231
|
return predicate(isolate);
|
|
1095
1232
|
}, IsolateTest.is);
|
|
@@ -1097,7 +1234,7 @@
|
|
|
1097
1234
|
static everyTest(predicate, root = TestWalker.defaultRoot()) {
|
|
1098
1235
|
if (!root)
|
|
1099
1236
|
return false;
|
|
1100
|
-
return
|
|
1237
|
+
return vestjsRuntime.Walker.every(root, isolate => {
|
|
1101
1238
|
IsolateTest.isX(isolate);
|
|
1102
1239
|
return predicate(isolate);
|
|
1103
1240
|
}, IsolateTest.is);
|
|
@@ -1105,7 +1242,7 @@
|
|
|
1105
1242
|
static walkTests(callback, root = TestWalker.defaultRoot()) {
|
|
1106
1243
|
if (!root)
|
|
1107
1244
|
return;
|
|
1108
|
-
|
|
1245
|
+
vestjsRuntime.Walker.walk(root, (isolate, breakout) => {
|
|
1109
1246
|
callback(IsolateTest.cast(isolate), breakout);
|
|
1110
1247
|
}, IsolateTest.is);
|
|
1111
1248
|
}
|
|
@@ -1120,7 +1257,7 @@
|
|
|
1120
1257
|
static pluckTests(predicate, root = TestWalker.defaultRoot()) {
|
|
1121
1258
|
if (!root)
|
|
1122
1259
|
return;
|
|
1123
|
-
|
|
1260
|
+
vestjsRuntime.Walker.pluck(root, isolate => {
|
|
1124
1261
|
IsolateTest.isX(isolate);
|
|
1125
1262
|
return predicate(isolate);
|
|
1126
1263
|
}, IsolateTest.is);
|
|
@@ -1139,150 +1276,14 @@
|
|
|
1139
1276
|
}
|
|
1140
1277
|
}
|
|
1141
1278
|
|
|
1142
|
-
/**
|
|
1143
|
-
* Checks that a given test object matches the currently specified severity level
|
|
1144
|
-
*/
|
|
1145
|
-
function nonMatchingSeverityProfile(severity, testObject) {
|
|
1146
|
-
return vestUtils.either(severity === Severity.WARNINGS, testObject.warns());
|
|
1147
|
-
}
|
|
1148
|
-
|
|
1149
|
-
/**
|
|
1150
|
-
* The difference between this file and hasFailures is that hasFailures uses the static
|
|
1151
|
-
* summary object, while this one uses the actual validation state
|
|
1152
|
-
*/
|
|
1153
|
-
function hasErrorsByTestObjects(fieldName) {
|
|
1154
|
-
return hasFailuresByTestObjects(Severity.ERRORS, fieldName);
|
|
1155
|
-
}
|
|
1156
|
-
function hasFailuresByTestObjects(severityKey, fieldName) {
|
|
1157
|
-
return TestWalker.someTests(testObject => {
|
|
1158
|
-
return hasFailuresByTestObject(testObject, severityKey, fieldName);
|
|
1159
|
-
});
|
|
1160
|
-
}
|
|
1161
|
-
function hasGroupFailuresByTestObjects(severityKey, groupName, fieldName) {
|
|
1162
|
-
return TestWalker.someTests(testObject => {
|
|
1163
|
-
if (nonMatchingGroupName(testObject, groupName)) {
|
|
1164
|
-
return false;
|
|
1165
|
-
}
|
|
1166
|
-
return hasFailuresByTestObject(testObject, severityKey, fieldName);
|
|
1167
|
-
});
|
|
1168
|
-
}
|
|
1169
|
-
/**
|
|
1170
|
-
* Determines whether a certain test profile has failures.
|
|
1171
|
-
*/
|
|
1172
|
-
function hasFailuresByTestObject(testObject, severityKey, fieldName) {
|
|
1173
|
-
if (!testObject.hasFailures()) {
|
|
1174
|
-
return false;
|
|
1175
|
-
}
|
|
1176
|
-
if (nonMatchingFieldName(testObject, fieldName)) {
|
|
1177
|
-
return false;
|
|
1178
|
-
}
|
|
1179
|
-
if (nonMatchingSeverityProfile(severityKey, testObject)) {
|
|
1180
|
-
return false;
|
|
1181
|
-
}
|
|
1182
|
-
return true;
|
|
1183
|
-
}
|
|
1184
|
-
|
|
1185
|
-
exports.Modes = void 0;
|
|
1186
|
-
(function (Modes) {
|
|
1187
|
-
Modes["EAGER"] = "EAGER";
|
|
1188
|
-
Modes["ALL"] = "ALL";
|
|
1189
|
-
Modes["ONE"] = "ONE";
|
|
1190
|
-
})(exports.Modes || (exports.Modes = {}));
|
|
1191
|
-
/**
|
|
1192
|
-
* Sets the current execution mode for the current suite.
|
|
1193
|
-
*
|
|
1194
|
-
* Supported modes:
|
|
1195
|
-
* - `EAGER` - (default) Runs all tests, but stops on first failure for each given field.
|
|
1196
|
-
* - `ALL` - Runs all tests, regardless of failures.
|
|
1197
|
-
* - `ONE` - Stops suite execution on first failure of any field.
|
|
1198
|
-
*
|
|
1199
|
-
* @example
|
|
1200
|
-
* ```js
|
|
1201
|
-
* import {Modes, create} from 'vest';
|
|
1202
|
-
*
|
|
1203
|
-
* const suite = create('suite_name', () => {
|
|
1204
|
-
* vest.mode(Modes.ALL);
|
|
1205
|
-
*
|
|
1206
|
-
* // ...
|
|
1207
|
-
* });
|
|
1208
|
-
* ```
|
|
1209
|
-
* @param 'ALL' | 'EAGER' | 'ONE' mode - The mode to set.
|
|
1210
|
-
*/
|
|
1211
|
-
// @vx-allow use-use
|
|
1212
|
-
function mode(mode) {
|
|
1213
|
-
const [, setMode] = useMode();
|
|
1214
|
-
setMode(mode);
|
|
1215
|
-
}
|
|
1216
|
-
function useIsMode(mode) {
|
|
1217
|
-
const [currentMode] = useMode();
|
|
1218
|
-
return currentMode === mode;
|
|
1219
|
-
}
|
|
1220
|
-
function useIsEager() {
|
|
1221
|
-
return useIsMode(exports.Modes.EAGER);
|
|
1222
|
-
}
|
|
1223
|
-
function useIsOne() {
|
|
1224
|
-
return useIsMode(exports.Modes.ONE);
|
|
1225
|
-
}
|
|
1226
|
-
function useShouldSkipBasedOnMode(testObject) {
|
|
1227
|
-
if (useIsOne()) {
|
|
1228
|
-
return hasErrorsByTestObjects();
|
|
1229
|
-
}
|
|
1230
|
-
if (useIsEager()) {
|
|
1231
|
-
return hasErrorsByTestObjects(testObject.fieldName);
|
|
1232
|
-
}
|
|
1233
|
-
return false;
|
|
1234
|
-
}
|
|
1235
|
-
|
|
1236
|
-
const SuiteContext = context.createCascade((ctxRef, parentContext) => {
|
|
1237
|
-
if (parentContext) {
|
|
1238
|
-
return null;
|
|
1239
|
-
}
|
|
1240
|
-
return vestUtils.assign({
|
|
1241
|
-
exclusion: {
|
|
1242
|
-
tests: {},
|
|
1243
|
-
groups: {},
|
|
1244
|
-
},
|
|
1245
|
-
inclusion: {},
|
|
1246
|
-
mode: vestUtils.tinyState.createTinyState(exports.Modes.EAGER),
|
|
1247
|
-
testMemoCache,
|
|
1248
|
-
}, ctxRef);
|
|
1249
|
-
});
|
|
1250
|
-
function useCurrentTest(msg) {
|
|
1251
|
-
return SuiteContext.useX(msg).currentTest;
|
|
1252
|
-
}
|
|
1253
|
-
function useGroupName() {
|
|
1254
|
-
return SuiteContext.useX().groupName;
|
|
1255
|
-
}
|
|
1256
|
-
function useExclusion(hookError) {
|
|
1257
|
-
return SuiteContext.useX(hookError).exclusion;
|
|
1258
|
-
}
|
|
1259
|
-
function useInclusion() {
|
|
1260
|
-
return SuiteContext.useX().inclusion;
|
|
1261
|
-
}
|
|
1262
|
-
function useMode() {
|
|
1263
|
-
return SuiteContext.useX().mode();
|
|
1264
|
-
}
|
|
1265
|
-
function useSkipped() {
|
|
1266
|
-
var _a;
|
|
1267
|
-
return (_a = SuiteContext.useX().skipped) !== null && _a !== void 0 ? _a : false;
|
|
1268
|
-
}
|
|
1269
|
-
function useOmitted() {
|
|
1270
|
-
var _a;
|
|
1271
|
-
return (_a = SuiteContext.useX().omitted) !== null && _a !== void 0 ? _a : false;
|
|
1272
|
-
}
|
|
1273
|
-
const testMemoCache = vestUtils.cache(10);
|
|
1274
|
-
function useTestMemoCache() {
|
|
1275
|
-
return SuiteContext.useX().testMemoCache;
|
|
1276
|
-
}
|
|
1277
|
-
|
|
1278
1279
|
/**
|
|
1279
1280
|
* This module gets triggered once the suite is done running its sync tests.
|
|
1280
1281
|
*
|
|
1281
1282
|
* It goes over all the tests in the state, and checks if they need to be omitted.
|
|
1282
1283
|
*/
|
|
1283
1284
|
function useOmitOptionalFields() {
|
|
1284
|
-
const root =
|
|
1285
|
-
const emit =
|
|
1285
|
+
const root = vestjsRuntime.VestRuntime.useAvailableRoot();
|
|
1286
|
+
const emit = vestjsRuntime.VestRuntime.useEmit();
|
|
1286
1287
|
const optionalFields = root === null || root === void 0 ? void 0 : root.getOptionalFields();
|
|
1287
1288
|
// If there are no optional fields, we don't need to do anything
|
|
1288
1289
|
if (vestUtils.isEmpty(optionalFields)) {
|
|
@@ -1348,7 +1349,7 @@
|
|
|
1348
1349
|
|
|
1349
1350
|
// eslint-disable-next-line max-statements
|
|
1350
1351
|
function useInitVestBus() {
|
|
1351
|
-
const VestBus =
|
|
1352
|
+
const VestBus = vestjsRuntime.VestRuntime.useBus();
|
|
1352
1353
|
// Report a the completion of a test. There may be other tests with the same
|
|
1353
1354
|
// name that are still running, or not yet started.
|
|
1354
1355
|
on(Events.TEST_COMPLETED, (testObject) => {
|
|
@@ -1404,6 +1405,12 @@
|
|
|
1404
1405
|
}
|
|
1405
1406
|
}
|
|
1406
1407
|
|
|
1408
|
+
function group(groupName, callback) {
|
|
1409
|
+
return vestjsRuntime.Isolate.create(() => {
|
|
1410
|
+
SuiteContext.run({ groupName }, callback);
|
|
1411
|
+
});
|
|
1412
|
+
}
|
|
1413
|
+
|
|
1407
1414
|
/**
|
|
1408
1415
|
* Conditionally includes a field for testing, based on specified criteria.
|
|
1409
1416
|
*
|
|
@@ -1470,7 +1477,7 @@
|
|
|
1470
1477
|
* runs test, if async - adds to pending array
|
|
1471
1478
|
*/
|
|
1472
1479
|
function useRunTest(testObject) {
|
|
1473
|
-
const VestBus =
|
|
1480
|
+
const VestBus = vestjsRuntime.VestRuntime.useBus();
|
|
1474
1481
|
// Run test callback.
|
|
1475
1482
|
// If a promise is returned, set as async and
|
|
1476
1483
|
// Move to pending list.
|
|
@@ -1501,11 +1508,11 @@
|
|
|
1501
1508
|
if (!vestUtils.isPromise(asyncTest))
|
|
1502
1509
|
return;
|
|
1503
1510
|
testObject.setPending();
|
|
1504
|
-
const VestBus =
|
|
1505
|
-
const done =
|
|
1511
|
+
const VestBus = vestjsRuntime.VestRuntime.useBus();
|
|
1512
|
+
const done = vestjsRuntime.VestRuntime.persist(() => {
|
|
1506
1513
|
onTestCompleted(VestBus, testObject);
|
|
1507
1514
|
});
|
|
1508
|
-
const fail =
|
|
1515
|
+
const fail = vestjsRuntime.VestRuntime.persist((rejectionMessage) => {
|
|
1509
1516
|
if (testObject.isCanceled()) {
|
|
1510
1517
|
return;
|
|
1511
1518
|
}
|
|
@@ -1532,7 +1539,7 @@
|
|
|
1532
1539
|
const dependencies = [
|
|
1533
1540
|
useSuiteId(),
|
|
1534
1541
|
fieldName,
|
|
1535
|
-
|
|
1542
|
+
vestjsRuntime.VestRuntime.useCurrentCursor(),
|
|
1536
1543
|
].concat(deps);
|
|
1537
1544
|
return useGetTestFromCache(dependencies, cacheAction);
|
|
1538
1545
|
function cacheAction() {
|
|
@@ -1563,7 +1570,7 @@
|
|
|
1563
1570
|
const [message, testFn, key] = (vestUtils.isFunction(args[1]) ? args : [undefined, ...args]);
|
|
1564
1571
|
validateTestParams(fieldName, testFn);
|
|
1565
1572
|
const groupName = useGroupName();
|
|
1566
|
-
const emit =
|
|
1573
|
+
const emit = vestjsRuntime.VestRuntime.useEmit();
|
|
1567
1574
|
const testObjectInput = { fieldName, groupName, key, message, testFn };
|
|
1568
1575
|
// This invalidates the suite cache.
|
|
1569
1576
|
emit(Events.TEST_RUN_STARTED);
|
|
@@ -1586,6 +1593,7 @@
|
|
|
1586
1593
|
}));
|
|
1587
1594
|
}
|
|
1588
1595
|
|
|
1596
|
+
// import { optional, skipWhen, omitWhen, IsolateTest, group } from 'vest';
|
|
1589
1597
|
function getTypedMethods() {
|
|
1590
1598
|
return {
|
|
1591
1599
|
group,
|
|
@@ -1623,7 +1631,7 @@
|
|
|
1623
1631
|
|
|
1624
1632
|
function useSuiteRunResult() {
|
|
1625
1633
|
return Object.freeze(vestUtils.assign({
|
|
1626
|
-
done:
|
|
1634
|
+
done: vestjsRuntime.VestRuntime.persist(done),
|
|
1627
1635
|
}, useCreateSuiteResult()));
|
|
1628
1636
|
}
|
|
1629
1637
|
/**
|
|
@@ -1660,7 +1668,7 @@
|
|
|
1660
1668
|
function suite(...args) {
|
|
1661
1669
|
return SuiteContext.run({}, () => {
|
|
1662
1670
|
// eslint-disable-next-line vest-internal/use-use
|
|
1663
|
-
const emit =
|
|
1671
|
+
const emit = vestjsRuntime.VestRuntime.useEmit();
|
|
1664
1672
|
emit(Events.SUITE_RUN_STARTED);
|
|
1665
1673
|
return IsolateSuite.create(useRunSuiteCallback(suiteCallback, ...args));
|
|
1666
1674
|
}).output;
|
|
@@ -1668,16 +1676,16 @@
|
|
|
1668
1676
|
// Assign methods to the suite
|
|
1669
1677
|
// We do this within the VestRuntime so that the suite methods
|
|
1670
1678
|
// will be bound to the suite's stateRef and be able to access it.
|
|
1671
|
-
return
|
|
1679
|
+
return vestjsRuntime.VestRuntime.Run(stateRef, () => {
|
|
1672
1680
|
useInitVestBus();
|
|
1673
1681
|
return vestUtils.assign(
|
|
1674
1682
|
// We're also binding the suite to the stateRef, so that the suite
|
|
1675
1683
|
// can access the stateRef when it's called.
|
|
1676
|
-
|
|
1684
|
+
vestjsRuntime.VestRuntime.persist(suite), Object.assign(Object.assign({ get: vestjsRuntime.VestRuntime.persist(useCreateSuiteResult), remove: vestjsRuntime.VestRuntime.usePrepareEmitter(Events.REMOVE_FIELD), reset: vestjsRuntime.VestRuntime.usePrepareEmitter(Events.RESET_SUITE), resetField: vestjsRuntime.VestRuntime.usePrepareEmitter(Events.RESET_FIELD) }, bindSuiteSelectors(vestjsRuntime.VestRuntime.persist(useCreateSuiteResult))), getTypedMethods()));
|
|
1677
1685
|
});
|
|
1678
1686
|
}
|
|
1679
1687
|
function useRunSuiteCallback(suiteCallback, ...args) {
|
|
1680
|
-
const emit =
|
|
1688
|
+
const emit = vestjsRuntime.VestRuntime.useEmit();
|
|
1681
1689
|
return () => {
|
|
1682
1690
|
suiteCallback(...args);
|
|
1683
1691
|
emit(Events.SUITE_CALLBACK_RUN_FINISHED);
|
|
@@ -1685,7 +1693,7 @@
|
|
|
1685
1693
|
};
|
|
1686
1694
|
}
|
|
1687
1695
|
|
|
1688
|
-
class IsolateEach extends
|
|
1696
|
+
class IsolateEach extends vestjsRuntime.Isolate {
|
|
1689
1697
|
constructor() {
|
|
1690
1698
|
super(...arguments);
|
|
1691
1699
|
this.allowReorder = true;
|
|
@@ -1714,12 +1722,6 @@
|
|
|
1714
1722
|
});
|
|
1715
1723
|
}
|
|
1716
1724
|
|
|
1717
|
-
function group(groupName, callback) {
|
|
1718
|
-
return vestRuntime.Isolate.create(() => {
|
|
1719
|
-
SuiteContext.run({ groupName }, callback);
|
|
1720
|
-
});
|
|
1721
|
-
}
|
|
1722
|
-
|
|
1723
1725
|
/**
|
|
1724
1726
|
* Creates a static suite for server-side validation.
|
|
1725
1727
|
*
|