diff --git a/packages/vest/src/suiteResult/done/__tests__/done.test.ts b/packages/vest/src/suiteResult/done/__tests__/done.test.ts index 09e766d8c..5eee29638 100644 --- a/packages/vest/src/suiteResult/done/__tests__/done.test.ts +++ b/packages/vest/src/suiteResult/done/__tests__/done.test.ts @@ -333,14 +333,30 @@ describe('done', () => { }); describe('When no tests are run', () => { - it('Should avoid calling the callback', () => { + it('Should run the callback', () => { const cb = jest.fn(); const suite = vest.create(() => {}); suite().done(cb); - expect(cb).not.toHaveBeenCalled(); + expect(cb).toHaveBeenCalled(); + }); + + describe('When tests are omitted', () => { + it('Should run the callback', () => { + const cb = jest.fn(); + + const suite = vest.create(() => { + vest.optional({ f1: true }); + + vest.test('f1', () => {}); + }); + + suite().done(cb); + expect(suite.get().tests.f1.testCount).toBe(0); + expect(cb).toHaveBeenCalled(); + }); }); }); diff --git a/packages/vest/src/suiteResult/done/shouldSkipDoneRegistration.ts b/packages/vest/src/suiteResult/done/shouldSkipDoneRegistration.ts index 16e7c1ae8..d6a9931ae 100644 --- a/packages/vest/src/suiteResult/done/shouldSkipDoneRegistration.ts +++ b/packages/vest/src/suiteResult/done/shouldSkipDoneRegistration.ts @@ -23,7 +23,6 @@ export function shouldSkipDoneRegistration< // If we do not have any test runs for the current field return !!( !isFunction(callback) || - numberEquals(output.testCount, 0) || (fieldName && numberEquals(output.tests[fieldName]?.testCount ?? 0, 0)) ); }