diff --git a/packages/vest/src/__tests__/__snapshots__/integration.base.test.ts.snap b/packages/vest/src/__tests__/__snapshots__/integration.base.test.ts.snap index e79da749f..b81bfd404 100644 --- a/packages/vest/src/__tests__/__snapshots__/integration.base.test.ts.snap +++ b/packages/vest/src/__tests__/__snapshots__/integration.base.test.ts.snap @@ -28,6 +28,7 @@ exports[`Base behavior Should produce correct validation result 1`] = ` "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, diff --git a/packages/vest/src/__tests__/__snapshots__/integration.stateful-async.test.ts.snap b/packages/vest/src/__tests__/__snapshots__/integration.stateful-async.test.ts.snap index e9f8f026a..a6b6939c3 100644 --- a/packages/vest/src/__tests__/__snapshots__/integration.stateful-async.test.ts.snap +++ b/packages/vest/src/__tests__/__snapshots__/integration.stateful-async.test.ts.snap @@ -44,6 +44,7 @@ exports[`Stateful async tests Merges skipped validations from previous suite 1`] "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 1, @@ -143,6 +144,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -263,6 +265,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, diff --git a/packages/vest/src/__tests__/__snapshots__/integration.stateful-tests.test.ts.snap b/packages/vest/src/__tests__/__snapshots__/integration.stateful-tests.test.ts.snap index bab0472dc..40c3ce8c0 100644 --- a/packages/vest/src/__tests__/__snapshots__/integration.stateful-tests.test.ts.snap +++ b/packages/vest/src/__tests__/__snapshots__/integration.stateful-tests.test.ts.snap @@ -23,6 +23,7 @@ exports[`Stateful behavior Should merge skipped fields with previous values 1`] "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -116,6 +117,7 @@ exports[`Stateful behavior Should merge skipped fields with previous values 2`] "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -217,6 +219,7 @@ exports[`Stateful behavior Should merge skipped fields with previous values 3`] "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -306,6 +309,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -334,6 +338,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -396,6 +401,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -460,6 +466,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, diff --git a/packages/vest/src/core/__tests__/__snapshots__/runtime.test.ts.snap b/packages/vest/src/core/__tests__/__snapshots__/runtime.test.ts.snap index ea7a1c22d..bc02a3b67 100644 --- a/packages/vest/src/core/__tests__/__snapshots__/runtime.test.ts.snap +++ b/packages/vest/src/core/__tests__/__snapshots__/runtime.test.ts.snap @@ -274,6 +274,7 @@ exports[`useLoadSuite Calling useLoadSuite should resume from loaded state 1`] = "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -421,6 +422,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, diff --git a/packages/vest/src/core/test/__tests__/__snapshots__/memo.test.ts.snap b/packages/vest/src/core/test/__tests__/__snapshots__/memo.test.ts.snap index ad35f5773..cfc10b27f 100644 --- a/packages/vest/src/core/test/__tests__/__snapshots__/memo.test.ts.snap +++ b/packages/vest/src/core/test/__tests__/__snapshots__/memo.test.ts.snap @@ -23,6 +23,7 @@ exports[`test.memo cache hit Should produce correct initial result 1`] = ` "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -94,6 +95,7 @@ exports[`test.memo cache hit sync Should restore previous result on re-run 1`] = "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, diff --git a/packages/vest/src/core/test/__tests__/__snapshots__/test.test.ts.snap b/packages/vest/src/core/test/__tests__/__snapshots__/test.test.ts.snap index d8104359e..e9647eccb 100644 --- a/packages/vest/src/core/test/__tests__/__snapshots__/test.test.ts.snap +++ b/packages/vest/src/core/test/__tests__/__snapshots__/test.test.ts.snap @@ -43,6 +43,7 @@ exports[`Test Vest's \`test\` function test params creates a test without a key "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -114,6 +115,7 @@ exports[`Test Vest's \`test\` function test params creates a test without a mess "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -183,6 +185,7 @@ exports[`Test Vest's \`test\` function test params creates a test without a mess "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, diff --git a/packages/vest/src/hooks/__tests__/__snapshots__/include.test.ts.snap b/packages/vest/src/hooks/__tests__/__snapshots__/include.test.ts.snap index 41aa46292..c5639464b 100644 --- a/packages/vest/src/hooks/__tests__/__snapshots__/include.test.ts.snap +++ b/packages/vest/src/hooks/__tests__/__snapshots__/include.test.ts.snap @@ -23,6 +23,7 @@ exports[`include Field is excluded via \`skip\` Should disregard \`include.when\ "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -77,6 +78,7 @@ exports[`include Field is excluded via \`skip\` Should disregard \`include\` and "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -152,6 +154,7 @@ exports[`include Test is excluded via \`skip.group\` Should disregard \`include. "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -227,6 +230,7 @@ exports[`include Test is excluded via \`skip.group\` Should disregard \`include\ "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -281,6 +285,7 @@ exports[`include Test is excluded via \`skipWhen\` Should disregard \`include.wh "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -326,6 +331,7 @@ exports[`include Test is excluded via \`skipWhen\` Should disregard \`include\` "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -376,6 +382,7 @@ exports[`include There is an \`onlyd\` field \`include\` is run as-is without mo "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -430,6 +437,7 @@ exports[`include There is an \`onlyd\` field include().when() \`when\` param is "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -498,6 +506,7 @@ exports[`include There is an \`onlyd\` field include().when() \`when\` param is "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -566,6 +575,7 @@ exports[`include There is an \`onlyd\` field include().when() \`when\` param is "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -611,6 +621,7 @@ exports[`include There is an \`onlyd\` field include().when() \`when\` param is "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -679,6 +690,7 @@ exports[`include There is an \`onlyd\` field include().when() \`when\` param is "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -742,6 +754,7 @@ exports[`include There is an \`onlyd\` field include().when() \`when\` param is "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -805,6 +818,7 @@ exports[`include There is an \`onlyd\` field include().when() \`when\` param is "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -873,6 +887,7 @@ exports[`include There is an \`onlyd\` field include().when() \`when\` param is "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -941,6 +956,7 @@ exports[`include When no \`skip\` or \`only\` include has no effect 1`] = ` "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -1000,6 +1016,7 @@ exports[`include When no \`skip\` or \`only\` include().when has no effect 1`] = "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, diff --git a/packages/vest/src/hooks/focused/__tests__/__snapshots__/focused.test.ts.snap b/packages/vest/src/hooks/focused/__tests__/__snapshots__/focused.test.ts.snap index 9d873dd9c..efff66cfd 100644 --- a/packages/vest/src/hooks/focused/__tests__/__snapshots__/focused.test.ts.snap +++ b/packages/vest/src/hooks/focused/__tests__/__snapshots__/focused.test.ts.snap @@ -34,6 +34,7 @@ exports[`Top Level Focus Top Level Skip When passing false Should run all fields "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -114,6 +115,7 @@ exports[`Top Level Focus Top Level Skip When passing undefined Should run all fi "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, diff --git a/packages/vest/src/isolates/__tests__/__snapshots__/group.test.ts.snap b/packages/vest/src/isolates/__tests__/__snapshots__/group.test.ts.snap index 848513c55..8760d434c 100644 --- a/packages/vest/src/isolates/__tests__/__snapshots__/group.test.ts.snap +++ b/packages/vest/src/isolates/__tests__/__snapshots__/group.test.ts.snap @@ -96,6 +96,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -227,6 +228,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -320,6 +322,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -415,6 +418,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -529,6 +533,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -612,6 +617,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -744,6 +750,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -846,6 +853,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -918,6 +926,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -990,6 +999,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -1046,6 +1056,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -1108,6 +1119,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -1175,6 +1187,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, diff --git a/packages/vest/src/isolates/__tests__/__snapshots__/omitWhen.test.ts.snap b/packages/vest/src/isolates/__tests__/__snapshots__/omitWhen.test.ts.snap index 9e7f20991..c1d44413b 100644 --- a/packages/vest/src/isolates/__tests__/__snapshots__/omitWhen.test.ts.snap +++ b/packages/vest/src/isolates/__tests__/__snapshots__/omitWhen.test.ts.snap @@ -268,6 +268,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -339,6 +340,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -410,6 +412,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -481,6 +484,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, diff --git a/packages/vest/src/isolates/__tests__/__snapshots__/skipWhen.test.ts.snap b/packages/vest/src/isolates/__tests__/__snapshots__/skipWhen.test.ts.snap index 2d18bcc72..3ace789cb 100644 --- a/packages/vest/src/isolates/__tests__/__snapshots__/skipWhen.test.ts.snap +++ b/packages/vest/src/isolates/__tests__/__snapshots__/skipWhen.test.ts.snap @@ -16,6 +16,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -50,6 +51,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -101,6 +103,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, diff --git a/packages/vest/src/suite/__tests__/__snapshots__/create.test.ts.snap b/packages/vest/src/suite/__tests__/__snapshots__/create.test.ts.snap index f4aa8069e..7e6e2b350 100644 --- a/packages/vest/src/suite/__tests__/__snapshots__/create.test.ts.snap +++ b/packages/vest/src/suite/__tests__/__snapshots__/create.test.ts.snap @@ -16,6 +16,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -44,6 +45,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -72,6 +74,7 @@ SuiteSummary { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, diff --git a/packages/vest/src/suite/__tests__/__snapshots__/staticSuite.test.ts.snap b/packages/vest/src/suite/__tests__/__snapshots__/staticSuite.test.ts.snap index 8078766b4..a367dee4e 100644 --- a/packages/vest/src/suite/__tests__/__snapshots__/staticSuite.test.ts.snap +++ b/packages/vest/src/suite/__tests__/__snapshots__/staticSuite.test.ts.snap @@ -144,6 +144,7 @@ exports[`staticSuite dump should output a dump of the suite 1`] = ` "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, diff --git a/packages/vest/src/suiteResult/__tests__/useProduceSuiteSummary.test.ts b/packages/vest/src/suiteResult/__tests__/useProduceSuiteSummary.test.ts index 8ea791f8e..f7dd2aba8 100644 --- a/packages/vest/src/suiteResult/__tests__/useProduceSuiteSummary.test.ts +++ b/packages/vest/src/suiteResult/__tests__/useProduceSuiteSummary.test.ts @@ -132,6 +132,7 @@ describe('suite.get()', () => { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, @@ -167,6 +168,7 @@ describe('suite()', () => { "hasWarnings": [Function], "hasWarningsByGroup": [Function], "isPending": [Function], + "isTested": [Function], "isValid": [Function], "isValidByGroup": [Function], "pendingCount": 0, diff --git a/packages/vest/src/suiteResult/selectors/__tests__/isTested.test.ts b/packages/vest/src/suiteResult/selectors/__tests__/isTested.test.ts new file mode 100644 index 000000000..32543cf06 --- /dev/null +++ b/packages/vest/src/suiteResult/selectors/__tests__/isTested.test.ts @@ -0,0 +1,69 @@ +import wait from 'wait'; + +import * as vest from 'vest'; + +describe('isTested', () => { + describe('When no field name is passed', () => { + describe('When suite has no tests', () => { + it('Should return false', () => { + const suite = vest.create(() => {}); + suite(); + // @ts-ignore - invalid input + expect(suite.isTested()).toBe(false); + }); + }); + + describe('When suite has tests', () => { + it('Should return false', () => { + const suite = vest.create(() => { + vest.test('f1', () => {}); + }); + suite(); + // @ts-ignore - invalid input + expect(suite.isTested()).toBe(false); + }); + }); + }); + + describe('When suite has no tests', () => { + it('Should return false', () => { + const suite = vest.create(() => {}); + suite(); + expect(suite.isTested('f1')).toBe(false); + }); + }); + + describe('When suite has tests', () => { + describe('When field has no tests', () => { + it('Should return false', () => { + const suite = vest.create(() => { + vest.test('f1', () => {}); + }); + suite(); + expect(suite.isTested('f2')).toBe(false); + }); + }); + + describe('When field has tests', () => { + it('Should return true', () => { + const suite = vest.create(() => { + vest.test('f1', () => {}); + }); + suite(); + expect(suite.isTested('f1')).toBe(true); + }); + }); + }); + + describe('When async test is pending', () => { + it('Should return false', async () => { + const suite = vest.create(() => { + vest.test('f1', async () => { + await wait(100); + }); + }); + suite(); + expect(suite.isTested('f1')).toBe(true); + }); + }); +}); diff --git a/packages/vest/src/suiteResult/selectors/suiteSelectors.ts b/packages/vest/src/suiteResult/selectors/suiteSelectors.ts index 8e6a082a5..0d064ddf4 100644 --- a/packages/vest/src/suiteResult/selectors/suiteSelectors.ts +++ b/packages/vest/src/suiteResult/selectors/suiteSelectors.ts @@ -45,6 +45,8 @@ export function bindSuiteSelectors( isPending: (...args: Parameters['isPending']>) => { return get().isPending(...args); }, + isTested: (...args: Parameters['isTested']>) => + get().isTested(...args), isValid: (...args: Parameters['isValid']>) => get().isValid(...args), isValidByGroup: ( @@ -69,6 +71,7 @@ export function suiteSelectors( hasWarnings, hasWarningsByGroup, isPending, + isTested, isValid, isValidByGroup, }; @@ -108,6 +111,10 @@ export function suiteSelectors( return hasFailures(summary, SeverityCount.ERROR_COUNT, fieldName); } + function isTested(fieldName: F): boolean { + return isPositive(summary.tests[fieldName]?.testCount); + } + function hasWarningsByGroup( groupName: G, fieldName?: F @@ -203,6 +210,7 @@ export interface SuiteSelectors { hasWarnings(fieldName?: F): boolean; hasErrorsByGroup(groupName: G, fieldName?: F): boolean; hasWarningsByGroup(groupName: G, fieldName?: F): boolean; + isTested(fieldName: F): boolean; isPending(fieldName?: F): boolean; isValid(fieldName?: F): boolean; isValidByGroup(groupName: G, fieldName?: F): boolean;