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