Skip to content

feat(waitFor): make generic to return callback value - #214

Merged
kevinccbsg merged 5 commits into
mainfrom
feat/waitfor-generic-return
Apr 15, 2026
Merged

feat(waitFor): make generic to return callback value#214
kevinccbsg merged 5 commits into
mainfrom
feat/waitfor-generic-return

Conversation

@kevinccbsg

Copy link
Copy Markdown
Member

Summary

  • Make twd.waitFor() generic (<T>) so it returns the callback's return value instead of void
  • Fully backwards compatible — existing void callbacks still work identically
  • Update API docs and AI guides with new signature, examples, and "only use when retry logic is necessary" warning

Usage

// Before: all assertions must go inside the callback
await twd.waitFor(() => {
  const event = findEvent("purchase");
  expect(event).to.exist;
  expect(event.customer_type).to.equal("b2c");
});

// After: extract the value and assert outside
const event = await twd.waitFor(() => {
  const ev = findEvent("purchase");
  expect(ev).to.exist;
  return ev;
});
expect(event.customer_type).to.equal("b2c");

Test plan

  • 3 new unit tests (sync return, async return, return after retries)
  • All 379 existing tests pass
  • TypeScript compiles clean in example app (tsc --noEmit)
  • Build succeeds
  • VitePress docs build succeeds

🤖 Generated with Claude Code

kevinccbsg and others added 5 commits April 15, 2026 17:03
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@kevinccbsg
kevinccbsg merged commit 836695c into main Apr 15, 2026
8 checks passed
@kevinccbsg
kevinccbsg deleted the feat/waitfor-generic-return branch April 15, 2026 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant