-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Description
🚀 Feature Proposal
Add some kind to feature to jest to wait until a mock function has been called n times.
Motivation
We have an API that recursively sends periodic notifications to another service, we need to check that this works, we currently have a setTimeout wrapped in a promise to make the test wait for a period thats deffinetly longer than needed.
Example
test('some test', async () => {
const someMock = jest.fn()
await someMock.waitUntilCalledNTimes(n) // on the nth call, continue.
expect(someOtherMock).hasBeenCalled()
})Pitch
Why does this feature belong in the Jest core platform?
It would be an addition to the core jest mocking ability, allowing for dynamic tests ensuring that a function has to of been called n times before moving on to check for its asssertions
Im happy to give this ago myself, if its something thats wanted
ms314006
Metadata
Metadata
Assignees
Labels
No labels