Skip to content

feat: add rs.waitFor and rs.waitUntil utilities#982

Merged
9aoy merged 2 commits intomainfrom
waitFor
Feb 26, 2026
Merged

feat: add rs.waitFor and rs.waitUntil utilities#982
9aoy merged 2 commits intomainfrom
waitFor

Conversation

@9aoy
Copy link
Copy Markdown
Collaborator

@9aoy 9aoy commented Feb 26, 2026

Summary

add rs.waitFor and rs.waitUntil utilities.

export interface RstestUtilities {
  // ... existing methods ...

  /**
   * Retry callback until it succeeds (doesn't throw) or timeout is reached.
   * If timeout is reached, throws the last error from the callback.
   */
  waitFor<T>(
    callback: WaitForCallback<T>,
    options?: number | WaitForOptions,
  ): Promise<T>

  /**
   * Retry callback until it returns a truthy value or timeout is reached.
   * If timeout is reached, throws an error.
   */
  waitUntil<T>(
    callback: () => T | Promise<T>,
    options?: number | WaitUntilOptions,
  ): Promise<T>
}

interface WaitForOptions {
  timeout?: number   // default: 1000
  interval?: number  // default: 50
}

Related Links

close #973

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying rstest with  Cloudflare Pages  Cloudflare Pages

Latest commit: 51188db
Status: ✅  Deploy successful!
Preview URL: https://4bdc930d.rstest.pages.dev
Branch Preview URL: https://waitfor.rstest.pages.dev

View logs

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 51188dbdb6

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@9aoy 9aoy merged commit c5008b5 into main Feb 26, 2026
15 of 17 checks passed
@9aoy 9aoy deleted the waitFor branch February 26, 2026 07:45
@fi3ework fi3ework mentioned this pull request Mar 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add built-in rs.waitFor() / rs.waitUntil() polling helpers (vitest parity)

1 participant