Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test helper to await Durable Object's alarms #322

Closed
robertcepa opened this issue Jul 25, 2022 · 1 comment · Fixed by #324
Closed

Test helper to await Durable Object's alarms #322

robertcepa opened this issue Jul 25, 2022 · 1 comment · Fixed by #324
Labels
enhancement New feature or request
Milestone

Comments

@robertcepa
Copy link
Member

We would like to test the side effects in our alarms, but the best way to do it now seems to be sleeping in tests for MAX_ALARM_TIMEOUT (which can slow tests down significantly), or mocking an internal function used in alarm via jest.

Would it be a good idea to expose a similar API to res.waitUntil() (e.g., await res.waitForAlarms()), which optionally accepts an argument to change the alarm interval, so they can be tested instantly?

@CraigglesO
Copy link
Contributor

Hey! I wanted to work on this for myself too.

I've been thinking more along the lines of:

global.flushDurableObjectAlarms(ids?: DurableObjectId[])

Where no ids specified means to call all existing alarms.

I'll try to find time this week to add this.

@mrbbot mrbbot added the enhancement New feature or request label Aug 11, 2022
@mrbbot mrbbot added this to the 2.7.0 milestone Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants