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.
- package/LICENSE +2 -2
- package/README.md +2 -57
- package/dist/cjs/classnames.development.js +18 -16
- package/dist/cjs/classnames.production.js +1 -1
- package/dist/cjs/enforce/compose.development.js +5 -54
- package/dist/cjs/enforce/compose.production.js +1 -1
- package/dist/cjs/enforce/compounds.development.js +20 -83
- package/dist/cjs/enforce/compounds.production.js +1 -1
- package/dist/cjs/enforce/schema.development.js +19 -82
- package/dist/cjs/enforce/schema.production.js +1 -1
- package/dist/cjs/parser.development.js +12 -9
- package/dist/cjs/parser.production.js +1 -1
- package/dist/cjs/promisify.development.js +4 -8
- package/dist/cjs/promisify.production.js +1 -1
- package/dist/cjs/vest.development.js +1287 -1153
- package/dist/cjs/vest.production.js +1 -1
- package/dist/es/classnames.development.js +20 -18
- package/dist/es/classnames.production.js +1 -1
- package/dist/es/enforce/compose.development.js +1 -58
- package/dist/es/enforce/compose.production.js +1 -1
- package/dist/es/enforce/compounds.development.js +2 -90
- package/dist/es/enforce/compounds.production.js +1 -1
- package/dist/es/enforce/schema.development.js +2 -88
- package/dist/es/enforce/schema.production.js +1 -1
- package/dist/es/parser.development.js +12 -9
- package/dist/es/parser.production.js +1 -1
- package/dist/es/promisify.development.js +5 -9
- package/dist/es/promisify.production.js +1 -1
- package/dist/es/vest.development.js +1286 -1148
- package/dist/es/vest.production.js +1 -1
- package/dist/umd/classnames.development.js +21 -19
- package/dist/umd/classnames.production.js +1 -1
- package/dist/umd/enforce/compose.development.js +9 -57
- package/dist/umd/enforce/compose.production.js +1 -1
- package/dist/umd/enforce/compounds.development.js +32 -94
- package/dist/umd/enforce/compounds.production.js +1 -1
- package/dist/umd/enforce/schema.development.js +32 -94
- package/dist/umd/enforce/schema.production.js +1 -1
- package/dist/umd/parser.development.js +16 -13
- package/dist/umd/parser.production.js +1 -1
- package/dist/umd/promisify.development.js +7 -11
- package/dist/umd/promisify.production.js +1 -1
- package/dist/umd/vest.development.js +1289 -1155
- package/dist/umd/vest.production.js +1 -1
- package/package.json +12 -16
- package/src/__tests__/__snapshots__/integration.async-tests.test.ts.snap +71 -0
- package/src/__tests__/__snapshots__/integration.base.test.ts.snap +71 -0
- package/src/__tests__/__snapshots__/integration.stateful-async.test.ts.snap +243 -0
- package/src/__tests__/__snapshots__/integration.stateful-tests.test.ts.snap +376 -0
- package/src/__tests__/integration.async-tests.test.ts +90 -0
- package/src/__tests__/integration.base.test.ts +45 -0
- package/src/__tests__/integration.exclusive.test.ts +88 -0
- package/src/__tests__/integration.stateful-async.test.ts +137 -0
- package/src/__tests__/integration.stateful-tests.test.ts +155 -0
- package/src/__tests__/isolate.test.ts +288 -0
- package/src/__tests__/state_refill.test.ts +41 -0
- package/src/core/SuiteWalker/SuiteWalker.ts +64 -0
- package/src/core/SuiteWalker/__tests__/hasRemainingTests.test.ts +130 -0
- package/src/core/VestBus/VestBus.ts +78 -0
- package/src/core/context/PersistedContext.ts +243 -0
- package/src/core/context/SuiteContext.ts +74 -0
- package/src/core/isolate/IsolateTest/IsolateTest.ts +213 -0
- package/src/core/isolate/IsolateTest/IsolateTestReconciler.ts +156 -0
- package/src/core/isolate/IsolateTest/IsolateTestStateMachine.ts +69 -0
- package/src/core/isolate/IsolateTest/SimpleStateMachine.ts +43 -0
- package/src/core/isolate/IsolateTest/TestWalker.ts +77 -0
- package/src/core/isolate/IsolateTypes.ts +10 -0
- package/src/core/isolate/isIsolate.ts +6 -0
- package/src/core/isolate/isolate.ts +110 -0
- package/src/core/isolate/reconciler/Reconciler/Reconciler.ts +123 -0
- package/src/core/isolate/reconciler/cancelOverriddenPendingTest.ts +15 -0
- package/src/core/isolate/reconciler/isSameProfileTest.ts +12 -0
- package/src/core/isolate/walker.ts +127 -0
- package/src/core/test/TestTypes.ts +3 -0
- package/src/core/test/__tests__/IsolateTest.test.ts +152 -0
- package/src/core/test/__tests__/__snapshots__/IsolateTest.test.ts.snap +39 -0
- package/src/core/test/__tests__/__snapshots__/memo.test.ts.snap +101 -0
- package/src/core/test/__tests__/__snapshots__/test.test.ts.snap +231 -0
- package/src/core/test/__tests__/key.test.ts +195 -0
- package/src/core/test/__tests__/memo.test.ts +218 -0
- package/src/core/test/__tests__/merging_of_previous_test_runs.test.ts +341 -0
- package/src/core/test/__tests__/runAsyncTest.test.ts +175 -0
- package/src/core/test/__tests__/test.test.ts +226 -0
- package/src/core/test/helpers/__tests__/nonMatchingSeverityProfile.test.ts +52 -0
- package/src/core/test/helpers/asVestTest.ts +9 -0
- package/src/core/test/helpers/matchingFieldName.ts +16 -0
- package/src/core/test/helpers/matchingGroupName.ts +12 -0
- package/src/core/test/helpers/nonMatchingSeverityProfile.ts +14 -0
- package/src/core/test/helpers/shouldUseErrorMessage.ts +9 -0
- package/src/core/test/test.memo.ts +81 -0
- package/src/core/test/test.ts +64 -0
- package/src/core/test/testLevelFlowControl/runTest.ts +86 -0
- package/src/core/test/testLevelFlowControl/verifyTestRun.ts +32 -0
- package/src/core/test/testObjectIsolate.ts +11 -0
- package/src/errors/ErrorStrings.ts +4 -0
- package/src/exports/__tests__/classnames.test.ts +92 -0
- package/src/exports/__tests__/parser.test.ts +441 -0
- package/src/exports/__tests__/promisify.test.ts +77 -0
- package/src/exports/classnames.ts +35 -0
- package/src/exports/enforce@compose.ts +1 -0
- package/src/exports/enforce@compounds.ts +1 -0
- package/src/exports/enforce@schema.ts +1 -0
- package/src/exports/parser.ts +63 -0
- package/src/exports/promisify.ts +18 -0
- package/src/hooks/__tests__/__snapshots__/include.test.ts.snap +794 -0
- package/src/hooks/__tests__/eager.test.ts +130 -0
- package/src/hooks/__tests__/exclusive.test.ts +578 -0
- package/src/hooks/__tests__/include.test.ts +431 -0
- package/src/hooks/__tests__/optional.test.ts +83 -0
- package/src/hooks/__tests__/warn.test.ts +42 -0
- package/src/hooks/exclusive.ts +179 -0
- package/src/hooks/include.ts +54 -0
- package/src/hooks/mode.ts +47 -0
- package/src/hooks/optional/OptionalTypes.ts +31 -0
- package/src/hooks/optional/optional.ts +69 -0
- package/src/hooks/warn.ts +19 -0
- package/src/isolates/__tests__/__snapshots__/each.test.ts.snap +3 -0
- package/src/isolates/__tests__/__snapshots__/group.test.ts.snap +114 -0
- package/src/isolates/__tests__/__snapshots__/omitWhen.test.ts.snap +443 -0
- package/src/isolates/__tests__/__snapshots__/skipWhen.test.ts.snap +99 -0
- package/src/isolates/__tests__/each.test.ts +35 -0
- package/src/isolates/__tests__/group.test.ts +362 -0
- package/src/isolates/__tests__/omitWhen.test.ts +246 -0
- package/src/isolates/__tests__/skipWhen.test.ts +163 -0
- package/src/isolates/each.ts +30 -0
- package/src/isolates/group.ts +9 -0
- package/src/isolates/omitWhen.ts +41 -0
- package/src/isolates/skipWhen.ts +42 -0
- package/src/suite/__tests__/__snapshots__/create.test.ts.snap +67 -0
- package/src/suite/__tests__/create.test.ts +109 -0
- package/src/suite/__tests__/remove.test.ts +50 -0
- package/src/suite/__tests__/resetField.test.ts +74 -0
- package/src/suite/createSuite.ts +94 -0
- package/src/suite/runCallbacks.ts +28 -0
- package/src/suiteResult/Severity.ts +15 -0
- package/src/suiteResult/SuiteResultTypes.ts +42 -0
- package/src/suiteResult/__tests__/done.test.ts +334 -0
- package/src/suiteResult/__tests__/produce.test.ts +163 -0
- package/src/suiteResult/done/deferDoneCallback.ts +28 -0
- package/src/suiteResult/done/shouldSkipDoneRegistration.ts +20 -0
- package/src/suiteResult/selectors/__tests__/__snapshots__/collectFailureMessages.test.ts.snap +89 -0
- package/src/suiteResult/selectors/__tests__/collectFailureMessages.test.ts +124 -0
- package/src/suiteResult/selectors/__tests__/getFailures.test.ts +158 -0
- package/src/suiteResult/selectors/__tests__/getFailuresByGroup.test.ts +199 -0
- package/src/suiteResult/selectors/__tests__/hasFailures.test.ts +141 -0
- package/src/suiteResult/selectors/__tests__/hasFailuresByGroup.test.ts +185 -0
- package/src/suiteResult/selectors/__tests__/hasFailuresByTestObject.test.ts +88 -0
- package/src/suiteResult/selectors/__tests__/isValid.test.ts +359 -0
- package/src/suiteResult/selectors/__tests__/isValidByGroup.test.ts +480 -0
- package/src/suiteResult/selectors/collectFailures.ts +43 -0
- package/src/suiteResult/selectors/hasFailuresByTestObjects.ts +62 -0
- package/src/suiteResult/selectors/produceSuiteSummary.ts +135 -0
- package/src/suiteResult/selectors/shouldAddValidProperty.ts +148 -0
- package/src/suiteResult/selectors/suiteSelectors.ts +199 -0
- package/src/suiteResult/suiteResult.ts +15 -0
- package/src/suiteResult/suiteRunResult.ts +43 -0
- package/src/vest.ts +36 -0
- package/testUtils/TVestMock.ts +5 -0
- package/testUtils/__tests__/partition.test.ts +4 -4
- package/testUtils/mockThrowError.ts +4 -2
- package/testUtils/suiteDummy.ts +2 -1
- package/testUtils/testDummy.ts +12 -10
- package/testUtils/testPromise.ts +3 -0
- package/tsconfig.json +84 -2
- package/types/classnames.d.ts +39 -4
- package/types/classnames.d.ts.map +1 -0
- package/types/enforce/compose.d.ts +2 -126
- package/types/enforce/compose.d.ts.map +1 -0
- package/types/enforce/compounds.d.ts +2 -136
- package/types/enforce/compounds.d.ts.map +1 -0
- package/types/enforce/schema.d.ts +2 -144
- package/types/enforce/schema.d.ts.map +1 -0
- package/types/parser.d.ts +45 -10
- package/types/parser.d.ts.map +1 -0
- package/types/promisify.d.ts +36 -34
- package/types/promisify.d.ts.map +1 -0
- package/types/vest.d.ts +169 -224
- package/types/vest.d.ts.map +1 -0
- package/CHANGELOG.md +0 -87
- package/testUtils/expandStateRef.ts +0 -8
- package/testUtils/runCreateRef.ts +0 -10
- package/testUtils/testObjects.ts +0 -6
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { faker } from '@faker-js/faker';
|
|
2
|
+
|
|
3
|
+
import { dummyTest } from '../../../../testUtils/testDummy';
|
|
4
|
+
|
|
5
|
+
import * as vest from 'vest';
|
|
6
|
+
|
|
7
|
+
describe('produce method: hasFailures', () => {
|
|
8
|
+
const fieldName = faker.random.word();
|
|
9
|
+
|
|
10
|
+
describe(`hasErrors`, () => {
|
|
11
|
+
describe('When no test objects', () => {
|
|
12
|
+
it('should return false', () => {
|
|
13
|
+
const suite = vest.create(() => {});
|
|
14
|
+
const res = suite();
|
|
15
|
+
expect(res.hasErrors(fieldName)).toBe(false);
|
|
16
|
+
expect(suite.get().hasErrors(fieldName)).toBe(false);
|
|
17
|
+
expect(res.hasErrors()).toBe(false);
|
|
18
|
+
expect(suite.get().hasErrors()).toBe(false);
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
describe('When no failing test objects', () => {
|
|
23
|
+
it('should return false', () => {
|
|
24
|
+
const suite = vest.create(() => {
|
|
25
|
+
dummyTest.passing(fieldName);
|
|
26
|
+
dummyTest.passing('field_1');
|
|
27
|
+
dummyTest.passing('field_2');
|
|
28
|
+
});
|
|
29
|
+
const res = suite();
|
|
30
|
+
expect(res.hasErrors(fieldName)).toBe(false);
|
|
31
|
+
expect(suite.get().hasErrors(fieldName)).toBe(false);
|
|
32
|
+
expect(res.hasErrors()).toBe(false);
|
|
33
|
+
expect(suite.get().hasErrors()).toBe(false);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('When failed fields are warning', () => {
|
|
38
|
+
it('should return false', () => {
|
|
39
|
+
const suite = vest.create(() => {
|
|
40
|
+
dummyTest.failingWarning();
|
|
41
|
+
dummyTest.passing(fieldName);
|
|
42
|
+
});
|
|
43
|
+
const res = suite();
|
|
44
|
+
expect(res.hasErrors(fieldName)).toBe(false);
|
|
45
|
+
expect(suite.get().hasErrors(fieldName)).toBe(false);
|
|
46
|
+
expect(res.hasErrors()).toBe(false);
|
|
47
|
+
expect(suite.get().hasErrors()).toBe(false);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe('When field has an error', () => {
|
|
52
|
+
it('Should return true when some of the tests of the field are erroring', () => {
|
|
53
|
+
const suite = vest.create(() => {
|
|
54
|
+
dummyTest.passing();
|
|
55
|
+
dummyTest.failing(fieldName);
|
|
56
|
+
});
|
|
57
|
+
const res = suite();
|
|
58
|
+
expect(res.hasErrors(fieldName)).toBe(true);
|
|
59
|
+
expect(suite.get().hasErrors(fieldName)).toBe(true);
|
|
60
|
+
expect(res.hasErrors()).toBe(true);
|
|
61
|
+
expect(suite.get().hasErrors()).toBe(true);
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
it('should return true', () => {
|
|
65
|
+
const suite = vest.create(() => {
|
|
66
|
+
dummyTest.failing(fieldName);
|
|
67
|
+
});
|
|
68
|
+
const res = suite();
|
|
69
|
+
expect(res.hasErrors(fieldName)).toBe(true);
|
|
70
|
+
expect(suite.get().hasErrors(fieldName)).toBe(true);
|
|
71
|
+
expect(res.hasErrors()).toBe(true);
|
|
72
|
+
expect(suite.get().hasErrors()).toBe(true);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe(`hasWarnings`, () => {
|
|
78
|
+
describe('When no test objects', () => {
|
|
79
|
+
it('should return false', () => {
|
|
80
|
+
const suite = vest.create(() => {});
|
|
81
|
+
const res = suite();
|
|
82
|
+
expect(res.hasWarnings(fieldName)).toBe(false);
|
|
83
|
+
expect(suite.get().hasWarnings(fieldName)).toBe(false);
|
|
84
|
+
expect(res.hasWarnings()).toBe(false);
|
|
85
|
+
expect(suite.get().hasWarnings()).toBe(false);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
describe('When no failing test objects', () => {
|
|
90
|
+
it('should return false', () => {
|
|
91
|
+
const suite = vest.create(() => {
|
|
92
|
+
dummyTest.passingWarning(fieldName);
|
|
93
|
+
dummyTest.passing('field_1');
|
|
94
|
+
});
|
|
95
|
+
const res = suite();
|
|
96
|
+
expect(res.hasWarnings(fieldName)).toBe(false);
|
|
97
|
+
expect(suite.get().hasWarnings(fieldName)).toBe(false);
|
|
98
|
+
expect(res.hasWarnings()).toBe(false);
|
|
99
|
+
expect(suite.get().hasWarnings()).toBe(false);
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
describe('When failed fields is not warning', () => {
|
|
104
|
+
it('should return false', () => {
|
|
105
|
+
const suite = vest.create(() => {
|
|
106
|
+
dummyTest.failing(fieldName);
|
|
107
|
+
});
|
|
108
|
+
const res = suite();
|
|
109
|
+
expect(res.hasWarnings(fieldName)).toBe(false);
|
|
110
|
+
expect(suite.get().hasWarnings(fieldName)).toBe(false);
|
|
111
|
+
expect(res.hasWarnings()).toBe(false);
|
|
112
|
+
expect(suite.get().hasWarnings()).toBe(false);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
describe('When field is warning', () => {
|
|
117
|
+
it('Should return true when some of the tests of the field are warning', () => {
|
|
118
|
+
const suite = vest.create(() => {
|
|
119
|
+
dummyTest.passingWarning();
|
|
120
|
+
dummyTest.failingWarning(fieldName);
|
|
121
|
+
});
|
|
122
|
+
const res = suite();
|
|
123
|
+
expect(res.hasWarnings(fieldName)).toBe(true);
|
|
124
|
+
expect(suite.get().hasWarnings(fieldName)).toBe(true);
|
|
125
|
+
expect(res.hasWarnings()).toBe(true);
|
|
126
|
+
expect(suite.get().hasWarnings()).toBe(true);
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
it('should return false', () => {
|
|
130
|
+
const suite = vest.create(() => {
|
|
131
|
+
dummyTest.failingWarning(fieldName);
|
|
132
|
+
});
|
|
133
|
+
const res = suite();
|
|
134
|
+
expect(res.hasWarnings(fieldName)).toBe(true);
|
|
135
|
+
expect(suite.get().hasWarnings(fieldName)).toBe(true);
|
|
136
|
+
expect(res.hasWarnings()).toBe(true);
|
|
137
|
+
expect(suite.get().hasWarnings()).toBe(true);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
});
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { faker } from '@faker-js/faker';
|
|
2
|
+
|
|
3
|
+
import { dummyTest } from '../../../../testUtils/testDummy';
|
|
4
|
+
|
|
5
|
+
import * as vest from 'vest';
|
|
6
|
+
|
|
7
|
+
const fieldName = faker.random.word();
|
|
8
|
+
const groupName = faker.lorem.word();
|
|
9
|
+
|
|
10
|
+
let suite: vest.Suite<(...args: any[]) => void, string>;
|
|
11
|
+
describe('hasErrorsByGroup', () => {
|
|
12
|
+
describe('When no tests', () => {
|
|
13
|
+
it('Should return false', () => {
|
|
14
|
+
suite = vest.create(() => undefined);
|
|
15
|
+
|
|
16
|
+
expect(suite().hasErrorsByGroup(groupName)).toBe(false);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe('When no failing tests', () => {
|
|
21
|
+
it('Should return false', () => {
|
|
22
|
+
suite = vest.create(() => {
|
|
23
|
+
dummyTest.passing();
|
|
24
|
+
});
|
|
25
|
+
expect(suite().hasErrorsByGroup(groupName)).toBe(false);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe('When there are failing tests without a group', () => {
|
|
30
|
+
it('Should return false', () => {
|
|
31
|
+
suite = vest.create(() => {
|
|
32
|
+
dummyTest.failing();
|
|
33
|
+
});
|
|
34
|
+
expect(suite().hasErrorsByGroup(groupName)).toBe(false);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe('When failing tests are from a different group', () => {
|
|
39
|
+
it('Should return false', () => {
|
|
40
|
+
suite = vest.create(() => {
|
|
41
|
+
vest.group('another_group', () => {
|
|
42
|
+
dummyTest.failing('field_1', 'msg');
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
expect(suite().hasErrorsByGroup(groupName)).toBe(false);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('When failing tests are from the same group but warning', () => {
|
|
51
|
+
it('Should return false', () => {
|
|
52
|
+
suite = vest.create(() => {
|
|
53
|
+
vest.group(groupName, () => {
|
|
54
|
+
dummyTest.failingWarning('field_1', 'msg');
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
expect(suite().hasErrorsByGroup(groupName)).toBe(false);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
describe('When failing tests are from the same group', () => {
|
|
62
|
+
it('Should return true', () => {
|
|
63
|
+
suite = vest.create(() => {
|
|
64
|
+
vest.group(groupName, () => {
|
|
65
|
+
dummyTest.failing('field_1', 'msg');
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
expect(suite().hasErrorsByGroup(groupName)).toBe(true);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe('When fieldName is provided', () => {
|
|
73
|
+
describe('When not matching', () => {
|
|
74
|
+
it('Should return false', () => {
|
|
75
|
+
suite = vest.create(() => {
|
|
76
|
+
vest.group(groupName, () => {
|
|
77
|
+
dummyTest.failing('field_1', 'msg');
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
expect(suite().hasErrorsByGroup(groupName, 'non_matcing_field')).toBe(
|
|
81
|
+
false
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
describe('When matching', () => {
|
|
87
|
+
it('Should return true', () => {
|
|
88
|
+
suite = vest.create(() => {
|
|
89
|
+
vest.group(groupName, () => {
|
|
90
|
+
dummyTest.failing(fieldName, 'msg');
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
expect(suite().hasErrorsByGroup(groupName, fieldName)).toBe(true);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
describe('hasWarningsByGroup', () => {
|
|
100
|
+
describe('When no tests', () => {
|
|
101
|
+
it('Should return false', () => {
|
|
102
|
+
suite = vest.create(() => undefined);
|
|
103
|
+
expect(suite().hasWarningsByGroup(groupName)).toBe(false);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
describe('When no failing tests', () => {
|
|
108
|
+
it('Should return false', () => {
|
|
109
|
+
suite = vest.create(() => {
|
|
110
|
+
vest.group(groupName, () => {
|
|
111
|
+
dummyTest.passingWarning(fieldName, 'msg');
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
expect(suite().hasWarningsByGroup(groupName)).toBe(false);
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
describe('When there are failing tests without a group', () => {
|
|
119
|
+
it('Should return false', () => {
|
|
120
|
+
suite = vest.create(() => {
|
|
121
|
+
dummyTest.failingWarning();
|
|
122
|
+
});
|
|
123
|
+
expect(suite().hasWarningsByGroup(groupName)).toBe(false);
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
describe('When failing tests are from a different group', () => {
|
|
128
|
+
it('Should return false', () => {
|
|
129
|
+
suite = vest.create(() => {
|
|
130
|
+
vest.group('another_group', () => {
|
|
131
|
+
dummyTest.failingWarning('field_1', 'msg');
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
expect(suite().hasWarningsByGroup(groupName)).toBe(false);
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
describe('When failing tests are from the same group but erroring', () => {
|
|
139
|
+
it('Should return false', () => {
|
|
140
|
+
suite = vest.create(() => {
|
|
141
|
+
vest.group(groupName, () => {
|
|
142
|
+
dummyTest.failing('field_1', 'msg');
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
expect(suite().hasWarningsByGroup(groupName)).toBe(false);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
describe('When failing tests are from the same group', () => {
|
|
150
|
+
it('Should return true', () => {
|
|
151
|
+
suite = vest.create(() => {
|
|
152
|
+
vest.group(groupName, () => {
|
|
153
|
+
dummyTest.failingWarning(fieldName, 'msg');
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
expect(suite().hasWarningsByGroup(groupName)).toBe(true);
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
describe('When fieldName is provided', () => {
|
|
161
|
+
describe('When not matching', () => {
|
|
162
|
+
it('Should return false', () => {
|
|
163
|
+
suite = vest.create(() => {
|
|
164
|
+
vest.group(groupName, () => {
|
|
165
|
+
dummyTest.failingWarning(fieldName, 'msg');
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
expect(suite().hasWarningsByGroup(groupName, 'non_matcing_field')).toBe(
|
|
169
|
+
false
|
|
170
|
+
);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
describe('When matching', () => {
|
|
175
|
+
it('Should return true', () => {
|
|
176
|
+
suite = vest.create(() => {
|
|
177
|
+
vest.group(groupName, () => {
|
|
178
|
+
dummyTest.failingWarning(fieldName, 'msg');
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
expect(suite().hasWarningsByGroup(groupName, fieldName)).toBe(true);
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { faker } from '@faker-js/faker';
|
|
2
|
+
|
|
3
|
+
import { IsolateTest } from 'IsolateTest';
|
|
4
|
+
import { IsolateTypes } from 'IsolateTypes';
|
|
5
|
+
import { Severity } from 'Severity';
|
|
6
|
+
import { hasFailuresByTestObject } from 'hasFailuresByTestObjects';
|
|
7
|
+
|
|
8
|
+
const fieldName: string = faker.random.word();
|
|
9
|
+
|
|
10
|
+
describe('hasFailuresByTestObject', () => {
|
|
11
|
+
let testObject: IsolateTest;
|
|
12
|
+
|
|
13
|
+
beforeEach(() => {
|
|
14
|
+
const fieldName: string = faker.random.word();
|
|
15
|
+
testObject = new IsolateTest(IsolateTypes.TEST, {
|
|
16
|
+
fieldName,
|
|
17
|
+
testFn: jest.fn(),
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe('When test did not fail', () => {
|
|
22
|
+
it('Should return false', () => {
|
|
23
|
+
expect(hasFailuresByTestObject(testObject, Severity.ERRORS)).toBe(false);
|
|
24
|
+
expect(hasFailuresByTestObject(testObject, Severity.WARNINGS)).toBe(
|
|
25
|
+
false
|
|
26
|
+
);
|
|
27
|
+
expect(
|
|
28
|
+
hasFailuresByTestObject(testObject, Severity.ERRORS, fieldName)
|
|
29
|
+
).toBe(false);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe('When the test did fail', () => {
|
|
34
|
+
beforeEach(() => {
|
|
35
|
+
testObject.fail();
|
|
36
|
+
});
|
|
37
|
+
describe('When field name is not provided', () => {
|
|
38
|
+
describe('When non matching severity profile', () => {
|
|
39
|
+
it('should return false', () => {
|
|
40
|
+
expect(hasFailuresByTestObject(testObject, Severity.WARNINGS)).toBe(
|
|
41
|
+
false
|
|
42
|
+
);
|
|
43
|
+
testObject.warn();
|
|
44
|
+
expect(hasFailuresByTestObject(testObject, Severity.ERRORS)).toBe(
|
|
45
|
+
false
|
|
46
|
+
);
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('When matching severity profile', () => {
|
|
51
|
+
it('Should return true', () => {
|
|
52
|
+
expect(hasFailuresByTestObject(testObject, Severity.ERRORS)).toBe(
|
|
53
|
+
true
|
|
54
|
+
);
|
|
55
|
+
testObject.warn();
|
|
56
|
+
expect(hasFailuresByTestObject(testObject, Severity.WARNINGS)).toBe(
|
|
57
|
+
true
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
describe('When field name is provided', () => {
|
|
63
|
+
describe('When field name matches', () => {
|
|
64
|
+
it('should return false', () => {
|
|
65
|
+
expect(
|
|
66
|
+
hasFailuresByTestObject(testObject, Severity.ERRORS, 'non_matching')
|
|
67
|
+
).toBe(false);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe('When field name matches', () => {
|
|
72
|
+
it('Should continue with normal flow', () => {
|
|
73
|
+
expect(hasFailuresByTestObject(testObject, Severity.WARNINGS)).toBe(
|
|
74
|
+
false
|
|
75
|
+
);
|
|
76
|
+
testObject.warn();
|
|
77
|
+
expect(hasFailuresByTestObject(testObject, Severity.ERRORS)).toBe(
|
|
78
|
+
false
|
|
79
|
+
);
|
|
80
|
+
testObject.fail();
|
|
81
|
+
expect(hasFailuresByTestObject(testObject, Severity.WARNINGS)).toBe(
|
|
82
|
+
true
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|