vest 5.0.0-dev-781e21 → 5.0.2-dev-d315d9

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.
Files changed (182) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +2 -57
  3. package/dist/cjs/classnames.development.js +18 -16
  4. package/dist/cjs/classnames.production.js +1 -1
  5. package/dist/cjs/enforce/compose.development.js +5 -54
  6. package/dist/cjs/enforce/compose.production.js +1 -1
  7. package/dist/cjs/enforce/compounds.development.js +20 -83
  8. package/dist/cjs/enforce/compounds.production.js +1 -1
  9. package/dist/cjs/enforce/schema.development.js +19 -82
  10. package/dist/cjs/enforce/schema.production.js +1 -1
  11. package/dist/cjs/parser.development.js +12 -9
  12. package/dist/cjs/parser.production.js +1 -1
  13. package/dist/cjs/promisify.development.js +4 -8
  14. package/dist/cjs/promisify.production.js +1 -1
  15. package/dist/cjs/vest.development.js +1287 -1153
  16. package/dist/cjs/vest.production.js +1 -1
  17. package/dist/es/classnames.development.js +20 -18
  18. package/dist/es/classnames.production.js +1 -1
  19. package/dist/es/enforce/compose.development.js +1 -58
  20. package/dist/es/enforce/compose.production.js +1 -1
  21. package/dist/es/enforce/compounds.development.js +2 -90
  22. package/dist/es/enforce/compounds.production.js +1 -1
  23. package/dist/es/enforce/schema.development.js +2 -88
  24. package/dist/es/enforce/schema.production.js +1 -1
  25. package/dist/es/parser.development.js +12 -9
  26. package/dist/es/parser.production.js +1 -1
  27. package/dist/es/promisify.development.js +5 -9
  28. package/dist/es/promisify.production.js +1 -1
  29. package/dist/es/vest.development.js +1286 -1148
  30. package/dist/es/vest.production.js +1 -1
  31. package/dist/umd/classnames.development.js +21 -19
  32. package/dist/umd/classnames.production.js +1 -1
  33. package/dist/umd/enforce/compose.development.js +9 -57
  34. package/dist/umd/enforce/compose.production.js +1 -1
  35. package/dist/umd/enforce/compounds.development.js +32 -94
  36. package/dist/umd/enforce/compounds.production.js +1 -1
  37. package/dist/umd/enforce/schema.development.js +32 -94
  38. package/dist/umd/enforce/schema.production.js +1 -1
  39. package/dist/umd/parser.development.js +16 -13
  40. package/dist/umd/parser.production.js +1 -1
  41. package/dist/umd/promisify.development.js +7 -11
  42. package/dist/umd/promisify.production.js +1 -1
  43. package/dist/umd/vest.development.js +1289 -1155
  44. package/dist/umd/vest.production.js +1 -1
  45. package/package.json +12 -16
  46. package/src/__tests__/__snapshots__/integration.async-tests.test.ts.snap +71 -0
  47. package/src/__tests__/__snapshots__/integration.base.test.ts.snap +71 -0
  48. package/src/__tests__/__snapshots__/integration.stateful-async.test.ts.snap +243 -0
  49. package/src/__tests__/__snapshots__/integration.stateful-tests.test.ts.snap +376 -0
  50. package/src/__tests__/integration.async-tests.test.ts +90 -0
  51. package/src/__tests__/integration.base.test.ts +45 -0
  52. package/src/__tests__/integration.exclusive.test.ts +88 -0
  53. package/src/__tests__/integration.stateful-async.test.ts +137 -0
  54. package/src/__tests__/integration.stateful-tests.test.ts +155 -0
  55. package/src/__tests__/isolate.test.ts +288 -0
  56. package/src/__tests__/state_refill.test.ts +41 -0
  57. package/src/core/SuiteWalker/SuiteWalker.ts +64 -0
  58. package/src/core/SuiteWalker/__tests__/hasRemainingTests.test.ts +130 -0
  59. package/src/core/VestBus/VestBus.ts +78 -0
  60. package/src/core/context/PersistedContext.ts +243 -0
  61. package/src/core/context/SuiteContext.ts +74 -0
  62. package/src/core/isolate/IsolateTest/IsolateTest.ts +213 -0
  63. package/src/core/isolate/IsolateTest/IsolateTestReconciler.ts +156 -0
  64. package/src/core/isolate/IsolateTest/IsolateTestStateMachine.ts +69 -0
  65. package/src/core/isolate/IsolateTest/SimpleStateMachine.ts +43 -0
  66. package/src/core/isolate/IsolateTest/TestWalker.ts +77 -0
  67. package/src/core/isolate/IsolateTypes.ts +10 -0
  68. package/src/core/isolate/isIsolate.ts +6 -0
  69. package/src/core/isolate/isolate.ts +110 -0
  70. package/src/core/isolate/reconciler/Reconciler/Reconciler.ts +123 -0
  71. package/src/core/isolate/reconciler/cancelOverriddenPendingTest.ts +15 -0
  72. package/src/core/isolate/reconciler/isSameProfileTest.ts +12 -0
  73. package/src/core/isolate/walker.ts +127 -0
  74. package/src/core/test/TestTypes.ts +3 -0
  75. package/src/core/test/__tests__/IsolateTest.test.ts +152 -0
  76. package/src/core/test/__tests__/__snapshots__/IsolateTest.test.ts.snap +39 -0
  77. package/src/core/test/__tests__/__snapshots__/memo.test.ts.snap +101 -0
  78. package/src/core/test/__tests__/__snapshots__/test.test.ts.snap +231 -0
  79. package/src/core/test/__tests__/key.test.ts +195 -0
  80. package/src/core/test/__tests__/memo.test.ts +218 -0
  81. package/src/core/test/__tests__/merging_of_previous_test_runs.test.ts +341 -0
  82. package/src/core/test/__tests__/runAsyncTest.test.ts +175 -0
  83. package/src/core/test/__tests__/test.test.ts +226 -0
  84. package/src/core/test/helpers/__tests__/nonMatchingSeverityProfile.test.ts +52 -0
  85. package/src/core/test/helpers/asVestTest.ts +9 -0
  86. package/src/core/test/helpers/matchingFieldName.ts +16 -0
  87. package/src/core/test/helpers/matchingGroupName.ts +12 -0
  88. package/src/core/test/helpers/nonMatchingSeverityProfile.ts +14 -0
  89. package/src/core/test/helpers/shouldUseErrorMessage.ts +9 -0
  90. package/src/core/test/test.memo.ts +81 -0
  91. package/src/core/test/test.ts +64 -0
  92. package/src/core/test/testLevelFlowControl/runTest.ts +86 -0
  93. package/src/core/test/testLevelFlowControl/verifyTestRun.ts +32 -0
  94. package/src/core/test/testObjectIsolate.ts +11 -0
  95. package/src/errors/ErrorStrings.ts +4 -0
  96. package/src/exports/__tests__/classnames.test.ts +92 -0
  97. package/src/exports/__tests__/parser.test.ts +441 -0
  98. package/src/exports/__tests__/promisify.test.ts +77 -0
  99. package/src/exports/classnames.ts +35 -0
  100. package/src/exports/enforce@compose.ts +1 -0
  101. package/src/exports/enforce@compounds.ts +1 -0
  102. package/src/exports/enforce@schema.ts +1 -0
  103. package/src/exports/parser.ts +63 -0
  104. package/src/exports/promisify.ts +18 -0
  105. package/src/hooks/__tests__/__snapshots__/include.test.ts.snap +794 -0
  106. package/src/hooks/__tests__/eager.test.ts +130 -0
  107. package/src/hooks/__tests__/exclusive.test.ts +578 -0
  108. package/src/hooks/__tests__/include.test.ts +431 -0
  109. package/src/hooks/__tests__/optional.test.ts +83 -0
  110. package/src/hooks/__tests__/warn.test.ts +42 -0
  111. package/src/hooks/exclusive.ts +179 -0
  112. package/src/hooks/include.ts +54 -0
  113. package/src/hooks/mode.ts +47 -0
  114. package/src/hooks/optional/OptionalTypes.ts +31 -0
  115. package/src/hooks/optional/optional.ts +69 -0
  116. package/src/hooks/warn.ts +19 -0
  117. package/src/isolates/__tests__/__snapshots__/each.test.ts.snap +3 -0
  118. package/src/isolates/__tests__/__snapshots__/group.test.ts.snap +114 -0
  119. package/src/isolates/__tests__/__snapshots__/omitWhen.test.ts.snap +443 -0
  120. package/src/isolates/__tests__/__snapshots__/skipWhen.test.ts.snap +99 -0
  121. package/src/isolates/__tests__/each.test.ts +35 -0
  122. package/src/isolates/__tests__/group.test.ts +362 -0
  123. package/src/isolates/__tests__/omitWhen.test.ts +246 -0
  124. package/src/isolates/__tests__/skipWhen.test.ts +163 -0
  125. package/src/isolates/each.ts +30 -0
  126. package/src/isolates/group.ts +9 -0
  127. package/src/isolates/omitWhen.ts +41 -0
  128. package/src/isolates/skipWhen.ts +42 -0
  129. package/src/suite/__tests__/__snapshots__/create.test.ts.snap +67 -0
  130. package/src/suite/__tests__/create.test.ts +109 -0
  131. package/src/suite/__tests__/remove.test.ts +50 -0
  132. package/src/suite/__tests__/resetField.test.ts +74 -0
  133. package/src/suite/createSuite.ts +94 -0
  134. package/src/suite/runCallbacks.ts +28 -0
  135. package/src/suiteResult/Severity.ts +15 -0
  136. package/src/suiteResult/SuiteResultTypes.ts +42 -0
  137. package/src/suiteResult/__tests__/done.test.ts +334 -0
  138. package/src/suiteResult/__tests__/produce.test.ts +163 -0
  139. package/src/suiteResult/done/deferDoneCallback.ts +28 -0
  140. package/src/suiteResult/done/shouldSkipDoneRegistration.ts +20 -0
  141. package/src/suiteResult/selectors/__tests__/__snapshots__/collectFailureMessages.test.ts.snap +89 -0
  142. package/src/suiteResult/selectors/__tests__/collectFailureMessages.test.ts +124 -0
  143. package/src/suiteResult/selectors/__tests__/getFailures.test.ts +158 -0
  144. package/src/suiteResult/selectors/__tests__/getFailuresByGroup.test.ts +199 -0
  145. package/src/suiteResult/selectors/__tests__/hasFailures.test.ts +141 -0
  146. package/src/suiteResult/selectors/__tests__/hasFailuresByGroup.test.ts +185 -0
  147. package/src/suiteResult/selectors/__tests__/hasFailuresByTestObject.test.ts +88 -0
  148. package/src/suiteResult/selectors/__tests__/isValid.test.ts +359 -0
  149. package/src/suiteResult/selectors/__tests__/isValidByGroup.test.ts +480 -0
  150. package/src/suiteResult/selectors/collectFailures.ts +43 -0
  151. package/src/suiteResult/selectors/hasFailuresByTestObjects.ts +62 -0
  152. package/src/suiteResult/selectors/produceSuiteSummary.ts +135 -0
  153. package/src/suiteResult/selectors/shouldAddValidProperty.ts +148 -0
  154. package/src/suiteResult/selectors/suiteSelectors.ts +199 -0
  155. package/src/suiteResult/suiteResult.ts +15 -0
  156. package/src/suiteResult/suiteRunResult.ts +43 -0
  157. package/src/vest.ts +36 -0
  158. package/testUtils/TVestMock.ts +5 -0
  159. package/testUtils/__tests__/partition.test.ts +4 -4
  160. package/testUtils/mockThrowError.ts +4 -2
  161. package/testUtils/suiteDummy.ts +2 -1
  162. package/testUtils/testDummy.ts +12 -10
  163. package/testUtils/testPromise.ts +3 -0
  164. package/tsconfig.json +84 -2
  165. package/types/classnames.d.ts +39 -4
  166. package/types/classnames.d.ts.map +1 -0
  167. package/types/enforce/compose.d.ts +2 -126
  168. package/types/enforce/compose.d.ts.map +1 -0
  169. package/types/enforce/compounds.d.ts +2 -136
  170. package/types/enforce/compounds.d.ts.map +1 -0
  171. package/types/enforce/schema.d.ts +2 -144
  172. package/types/enforce/schema.d.ts.map +1 -0
  173. package/types/parser.d.ts +45 -10
  174. package/types/parser.d.ts.map +1 -0
  175. package/types/promisify.d.ts +36 -34
  176. package/types/promisify.d.ts.map +1 -0
  177. package/types/vest.d.ts +169 -224
  178. package/types/vest.d.ts.map +1 -0
  179. package/CHANGELOG.md +0 -87
  180. package/testUtils/expandStateRef.ts +0 -8
  181. package/testUtils/runCreateRef.ts +0 -10
  182. package/testUtils/testObjects.ts +0 -6
@@ -0,0 +1,123 @@
1
+ import { CB, invariant, isNullish } from 'vest-utils';
2
+
3
+ import {
4
+ useHistoryKey,
5
+ useSetIsolateKey,
6
+ useHistoryNode,
7
+ useIsolate,
8
+ useCurrentCursor,
9
+ PersistedContext,
10
+ useRuntimeRoot,
11
+ } from 'PersistedContext';
12
+ import type { Isolate } from 'isolate';
13
+
14
+ export class Reconciler {
15
+ static reconciler(
16
+ currentNode: Isolate,
17
+ historicNode: Isolate | null
18
+ ): Isolate {
19
+ if (isNullish(historicNode)) {
20
+ return currentNode;
21
+ }
22
+ return currentNode;
23
+ }
24
+
25
+ static reconcile<Callback extends CB = CB>(
26
+ node: Isolate,
27
+ callback: Callback
28
+ ): [Isolate, ReturnType<Callback>] {
29
+ const parent = useIsolate();
30
+
31
+ const historyNode = useHistoryNode();
32
+ let localHistoryNode = historyNode;
33
+
34
+ if (parent) {
35
+ // If we have a parent, we need to get the history node from the parent's children
36
+ // We take the history node from the cursor of the active node's children
37
+ localHistoryNode = historyNode?.at(useCurrentCursor()) ?? null;
38
+ }
39
+
40
+ const nextNode = this.reconciler(node, localHistoryNode);
41
+
42
+ invariant(nextNode);
43
+
44
+ if (Object.is(nextNode, node)) {
45
+ return [node, runAsNew(localHistoryNode, node, callback)];
46
+ }
47
+
48
+ return [nextNode, nextNode.output];
49
+ }
50
+
51
+ static removeAllNextNodesInIsolate() {
52
+ const testIsolate = useIsolate();
53
+ const historyNode = useHistoryNode();
54
+
55
+ if (!historyNode || !testIsolate) {
56
+ return;
57
+ }
58
+
59
+ historyNode.slice(useCurrentCursor());
60
+ }
61
+
62
+ static handleCollision(newNode: Isolate, prevNode: Isolate): Isolate {
63
+ // we should base our calculation on the key property
64
+ if (newNode.usesKey()) {
65
+ return this.handleIsolateNodeWithKey(newNode);
66
+ }
67
+
68
+ if (this.nodeReorderDetected(newNode, prevNode)) {
69
+ this.onNodeReorder(newNode, prevNode);
70
+ }
71
+
72
+ return prevNode ? prevNode : newNode;
73
+ }
74
+
75
+ static nodeReorderDetected(newNode: Isolate, prevNode: Isolate): boolean {
76
+ // This is a dummy return just to satisfy the linter. Overrides will supply the real implementation.
77
+ return !(newNode ?? prevNode);
78
+ }
79
+
80
+ static onNodeReorder(newNode: Isolate, prevNode: Isolate): Isolate {
81
+ this.removeAllNextNodesInIsolate();
82
+ // This is a dummy return just to satisfy the linter. Overrides will supply the real implementation.
83
+ return newNode ?? prevNode;
84
+ }
85
+
86
+ static handleIsolateNodeWithKey(node: Isolate): Isolate {
87
+ invariant(node.usesKey());
88
+
89
+ const prevNodeByKey = useHistoryKey(node.key);
90
+
91
+ let nextNode = node;
92
+
93
+ if (!isNullish(prevNodeByKey)) {
94
+ nextNode = prevNodeByKey;
95
+ }
96
+
97
+ useSetIsolateKey(node.key, node);
98
+
99
+ return nextNode;
100
+ }
101
+ }
102
+
103
+ function runAsNew<Callback extends CB = CB>(
104
+ localHistoryNode: Isolate | null,
105
+ current: Isolate,
106
+ callback: CB
107
+ ): ReturnType<Callback> {
108
+ const runtimeRoot = useRuntimeRoot();
109
+
110
+ // We're creating a new child isolate context where the local history node
111
+ // is the current history node, thus advancing the history cursor.
112
+ const output = PersistedContext.run(
113
+ {
114
+ historyNode: localHistoryNode,
115
+ runtimeNode: current,
116
+ ...(!runtimeRoot && { runtimeRoot: current }),
117
+ },
118
+ () => callback(current)
119
+ );
120
+
121
+ current.output = output;
122
+ return output;
123
+ }
@@ -0,0 +1,15 @@
1
+ import { IsolateTest } from 'IsolateTest';
2
+ import { isSameProfileTest } from 'isSameProfileTest';
3
+
4
+ export default function cancelOverriddenPendingTest(
5
+ prevRunTestObject: IsolateTest,
6
+ currentRunTestObject: IsolateTest
7
+ ): void {
8
+ if (
9
+ currentRunTestObject !== prevRunTestObject &&
10
+ isSameProfileTest(prevRunTestObject, currentRunTestObject) &&
11
+ prevRunTestObject.isPending()
12
+ ) {
13
+ prevRunTestObject.cancel();
14
+ }
15
+ }
@@ -0,0 +1,12 @@
1
+ import { IsolateTest } from 'IsolateTest';
2
+
3
+ export function isSameProfileTest(
4
+ testObject1: IsolateTest,
5
+ testObject2: IsolateTest
6
+ ): boolean {
7
+ return (
8
+ testObject1.fieldName === testObject2.fieldName &&
9
+ testObject1.groupName === testObject2.groupName &&
10
+ testObject1.key === testObject2.key
11
+ );
12
+ }
@@ -0,0 +1,127 @@
1
+ import { isNullish, optionalFunctionValue } from 'vest-utils';
2
+
3
+ import type { Isolate } from 'isolate';
4
+
5
+ export type VisitOnlyPredicate = (isolate: Isolate) => boolean;
6
+
7
+ // eslint-disable-next-line complexity, max-statements
8
+ export function walk(
9
+ startNode: Isolate,
10
+ callback: (isolate: Isolate, breakout: () => void) => void,
11
+ visitOnly?: VisitOnlyPredicate
12
+ ): void {
13
+ if (isNullish(startNode.children)) {
14
+ return;
15
+ }
16
+
17
+ let broke = false;
18
+
19
+ for (const isolate of startNode.children) {
20
+ if (broke) {
21
+ return;
22
+ }
23
+
24
+ if (isNullish(visitOnly) || optionalFunctionValue(visitOnly, isolate)) {
25
+ callback(isolate, breakout);
26
+ }
27
+
28
+ if (broke) {
29
+ return;
30
+ }
31
+
32
+ walk(
33
+ isolate,
34
+ (child, innerBreakout) => {
35
+ callback(child, () => {
36
+ innerBreakout();
37
+ breakout();
38
+ });
39
+ },
40
+ visitOnly
41
+ );
42
+ }
43
+
44
+ function breakout() {
45
+ broke = true;
46
+ }
47
+ }
48
+
49
+ export function some(
50
+ startNode: Isolate,
51
+ predicate: (node: Isolate) => boolean,
52
+ visitOnly?: VisitOnlyPredicate
53
+ ): boolean {
54
+ let hasMatch = false;
55
+ walk(
56
+ startNode,
57
+ (node, breakout) => {
58
+ if (predicate(node)) {
59
+ breakout();
60
+ hasMatch = true;
61
+ }
62
+ },
63
+ visitOnly
64
+ );
65
+
66
+ return hasMatch;
67
+ }
68
+
69
+ export function has(startNode: Isolate, match: VisitOnlyPredicate): boolean {
70
+ return some(startNode, () => true, match);
71
+ }
72
+
73
+ export function find(
74
+ startNode: Isolate,
75
+ predicate: (node: Isolate) => boolean,
76
+ visitOnly?: VisitOnlyPredicate
77
+ ): Isolate | null {
78
+ let found = null;
79
+ walk(
80
+ startNode,
81
+ (node, breakout) => {
82
+ if (predicate(node)) {
83
+ breakout();
84
+ found = node;
85
+ }
86
+ },
87
+ visitOnly
88
+ );
89
+
90
+ return found;
91
+ }
92
+
93
+ export function every(
94
+ startNode: Isolate,
95
+ predicate: (node: Isolate) => boolean,
96
+ visitOnly?: VisitOnlyPredicate
97
+ ): boolean {
98
+ let hasMatch = true;
99
+ walk(
100
+ startNode,
101
+ (node, breakout) => {
102
+ if (!predicate(node)) {
103
+ breakout();
104
+ hasMatch = false;
105
+ }
106
+ },
107
+ visitOnly
108
+ );
109
+
110
+ return hasMatch;
111
+ }
112
+
113
+ export function pluck(
114
+ startNode: Isolate,
115
+ predicate: (node: Isolate) => boolean,
116
+ visitOnly?: VisitOnlyPredicate
117
+ ): void {
118
+ walk(
119
+ startNode,
120
+ node => {
121
+ if (predicate(node) && node.parent) {
122
+ node.parent.removeChild(node);
123
+ }
124
+ },
125
+ visitOnly
126
+ );
127
+ }
@@ -0,0 +1,3 @@
1
+ export type TestFn = () => TestResult;
2
+ export type AsyncTest = Promise<string | void | false>;
3
+ export type TestResult = AsyncTest | boolean | void;
@@ -0,0 +1,152 @@
1
+ import wait from 'wait';
2
+
3
+ import { TestPromise } from '../../../../testUtils/testPromise';
4
+
5
+ import { IsolateTest } from 'IsolateTest';
6
+ import { IsolateTypes } from 'IsolateTypes';
7
+ import * as vest from 'vest';
8
+
9
+ const fieldName = 'unicycle';
10
+ const message = 'I am Root.';
11
+
12
+ describe('IsolateTest', () => {
13
+ let testObject: IsolateTest;
14
+
15
+ beforeEach(() => {
16
+ testObject = new IsolateTest(IsolateTypes.TEST, {
17
+ fieldName,
18
+ testFn: jest.fn(),
19
+ message,
20
+ });
21
+ });
22
+
23
+ test('TestObject constructor', () => {
24
+ expect(testObject).toMatchSnapshot();
25
+ });
26
+
27
+ it('Should have a unique id', () => {
28
+ Array.from(
29
+ { length: 100 },
30
+ () =>
31
+ new IsolateTest(IsolateTypes.TEST, {
32
+ fieldName,
33
+ testFn: jest.fn(),
34
+ message,
35
+ })
36
+ ).reduce((existing, { id }) => {
37
+ expect(existing.has(id)).toBe(false);
38
+ existing.add(id);
39
+ return existing;
40
+ }, new Set<string>());
41
+ });
42
+
43
+ describe('testObject.warn', () => {
44
+ it('Should mark the test as warning', () => {
45
+ expect(testObject.warns()).toBe(false);
46
+ testObject.warn();
47
+ expect(testObject.warns()).toBe(true);
48
+ expect(testObject).toMatchSnapshot();
49
+ });
50
+ });
51
+
52
+ describe('testObject.fail', () => {
53
+ beforeEach(() => {
54
+ jest.resetModules();
55
+
56
+ const { IsolateTest } = require('IsolateTest'); // eslint-disable-line @typescript-eslint/no-var-requires
57
+ testObject = new IsolateTest(fieldName, jest.fn(), { message });
58
+ });
59
+
60
+ afterEach(() => {
61
+ jest.resetAllMocks();
62
+ });
63
+
64
+ it('Should set status to failed', () => {
65
+ expect(testObject.isFailing()).toBe(false);
66
+ testObject.fail();
67
+ expect(testObject.isFailing()).toBe(true);
68
+ });
69
+ });
70
+
71
+ describe('testObject.valueOf', () => {
72
+ test('When test did not fail', () => {
73
+ expect(testObject.valueOf()).toBe(true);
74
+ });
75
+
76
+ test('When test failed', () => {
77
+ testObject.fail();
78
+ expect(testObject.valueOf()).toBe(false);
79
+ });
80
+ });
81
+
82
+ describe('testObject.cancel', () => {
83
+ it('Should set the testObject to cancel', () => {
84
+ let testObject: IsolateTest;
85
+ return TestPromise(done => {
86
+ const suite = vest.create(() => {
87
+ testObject = vest.test('f1', async () => {
88
+ await wait(100);
89
+ });
90
+ vest.test('f2', async () => {
91
+ await wait(100);
92
+ });
93
+ testObject.cancel();
94
+ });
95
+ suite();
96
+
97
+ expect(testObject.isCanceled()).toBe(true);
98
+ done();
99
+ });
100
+ });
101
+
102
+ describe('final statuses', () => {
103
+ let control = jest.fn();
104
+ beforeEach(() => {
105
+ control = jest.fn();
106
+ });
107
+ it('keep status unchanged when `failed`', () => {
108
+ vest.create(() => {
109
+ // async so it is not a final status
110
+ const testObject = vest.test('f1', async () => {
111
+ await wait(100);
112
+ });
113
+ testObject.fail();
114
+ expect(testObject.isFailing()).toBe(true);
115
+ testObject.skip();
116
+ expect(testObject.isSkipped()).toBe(false);
117
+ expect(testObject.isFailing()).toBe(true);
118
+ testObject.cancel();
119
+ expect(testObject.isCanceled()).toBe(false);
120
+ expect(testObject.isFailing()).toBe(true);
121
+ testObject.setPending();
122
+ expect(testObject.isPending()).toBe(false);
123
+ expect(testObject.isFailing()).toBe(true);
124
+ control();
125
+ })();
126
+ expect(control).toHaveBeenCalledTimes(1);
127
+ });
128
+
129
+ it('keep status unchanged when `canceled`', () => {
130
+ vest.create(() => {
131
+ // async so it is not a final status
132
+ const testObject = vest.test('f1', async () => {
133
+ await wait(100);
134
+ });
135
+ testObject.cancel();
136
+ expect(testObject.isCanceled()).toBe(true);
137
+ testObject.fail();
138
+ expect(testObject.isCanceled()).toBe(true);
139
+ expect(testObject.isFailing()).toBe(false);
140
+ testObject.skip();
141
+ expect(testObject.isSkipped()).toBe(false);
142
+ expect(testObject.isCanceled()).toBe(true);
143
+ testObject.setPending();
144
+ expect(testObject.isPending()).toBe(false);
145
+ expect(testObject.isCanceled()).toBe(true);
146
+ control();
147
+ })();
148
+ expect(control).toHaveBeenCalledTimes(1);
149
+ });
150
+ });
151
+ });
152
+ });
@@ -0,0 +1,39 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`IsolateTest TestObject constructor 1`] = `
4
+ IsolateTest {
5
+ "children": null,
6
+ "fieldName": "unicycle",
7
+ "id": "0",
8
+ "key": null,
9
+ "keys": {},
10
+ "message": "I am Root.",
11
+ "parent": null,
12
+ "severity": "error",
13
+ "stateMachine": {
14
+ "getState": [Function],
15
+ "transition": [Function],
16
+ },
17
+ "testFn": [MockFunction],
18
+ "type": "TEST",
19
+ }
20
+ `;
21
+
22
+ exports[`IsolateTest testObject.warn Should mark the test as warning 1`] = `
23
+ IsolateTest {
24
+ "children": null,
25
+ "fieldName": "unicycle",
26
+ "id": "102",
27
+ "key": null,
28
+ "keys": {},
29
+ "message": "I am Root.",
30
+ "parent": null,
31
+ "severity": "warning",
32
+ "stateMachine": {
33
+ "getState": [Function],
34
+ "transition": [Function],
35
+ },
36
+ "testFn": [MockFunction],
37
+ "type": "TEST",
38
+ }
39
+ `;
@@ -0,0 +1,101 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`test.memo cache hit Should produce correct initial result 1`] = `
4
+ {
5
+ "done": [Function],
6
+ "errorCount": 1,
7
+ "getErrors": [Function],
8
+ "getErrorsByGroup": [Function],
9
+ "getWarnings": [Function],
10
+ "getWarningsByGroup": [Function],
11
+ "groups": {},
12
+ "hasErrors": [Function],
13
+ "hasErrorsByGroup": [Function],
14
+ "hasWarnings": [Function],
15
+ "hasWarningsByGroup": [Function],
16
+ "isValid": [Function],
17
+ "isValidByGroup": [Function],
18
+ "suiteName": undefined,
19
+ "testCount": 4,
20
+ "tests": {
21
+ "field1": {
22
+ "errorCount": 1,
23
+ "errors": [
24
+ "msg1",
25
+ ],
26
+ "testCount": 2,
27
+ "valid": false,
28
+ "warnCount": 0,
29
+ "warnings": [],
30
+ },
31
+ "field2": {
32
+ "errorCount": 0,
33
+ "errors": [],
34
+ "testCount": 1,
35
+ "valid": true,
36
+ "warnCount": 0,
37
+ "warnings": [],
38
+ },
39
+ "field3": {
40
+ "errorCount": 0,
41
+ "errors": [],
42
+ "testCount": 1,
43
+ "valid": true,
44
+ "warnCount": 1,
45
+ "warnings": [],
46
+ },
47
+ },
48
+ "valid": false,
49
+ "warnCount": 1,
50
+ }
51
+ `;
52
+
53
+ exports[`test.memo cache hit sync Should restore previous result on re-run 1`] = `
54
+ {
55
+ "done": [Function],
56
+ "errorCount": 1,
57
+ "getErrors": [Function],
58
+ "getErrorsByGroup": [Function],
59
+ "getWarnings": [Function],
60
+ "getWarningsByGroup": [Function],
61
+ "groups": {},
62
+ "hasErrors": [Function],
63
+ "hasErrorsByGroup": [Function],
64
+ "hasWarnings": [Function],
65
+ "hasWarningsByGroup": [Function],
66
+ "isValid": [Function],
67
+ "isValidByGroup": [Function],
68
+ "suiteName": undefined,
69
+ "testCount": 4,
70
+ "tests": {
71
+ "field1": {
72
+ "errorCount": 1,
73
+ "errors": [
74
+ "msg1",
75
+ ],
76
+ "testCount": 2,
77
+ "valid": false,
78
+ "warnCount": 0,
79
+ "warnings": [],
80
+ },
81
+ "field2": {
82
+ "errorCount": 0,
83
+ "errors": [],
84
+ "testCount": 1,
85
+ "valid": true,
86
+ "warnCount": 0,
87
+ "warnings": [],
88
+ },
89
+ "field3": {
90
+ "errorCount": 0,
91
+ "errors": [],
92
+ "testCount": 1,
93
+ "valid": true,
94
+ "warnCount": 1,
95
+ "warnings": [],
96
+ },
97
+ },
98
+ "valid": false,
99
+ "warnCount": 1,
100
+ }
101
+ `;