Repository navigation
fix: accept StoryContext's userEvent.setup() instance in I.init - #15
Conversation
StoryContext.userEvent is a setup() instance (keyboard(): Promise<void>); UserEvent was picked from the direct API (keyboard(): Promise<System>), so a real context failed to typecheck. Type only the called methods, with Promise<unknown> returns.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (3)
Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe ChangesContext typing
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Merge Risk: ⚪ Minimal · up to The context typing change has no identified merge-blocking issue. Normal checks remain appropriate before merging. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
There was a problem hiding this comment.
🟡 Changes recommended
The exported UserEvent return type introduces an unacknowledged source-breaking API change.
1 open finding
What changed in this PR
Updates actor context typing to accept Storybook setup-based and direct user-event APIs.
Changes:
- Defines the minimal user-event methods required by the actor.
- Adds compile-time compatibility tests.
- Adds a patch changeset.
| File | Description |
|---|---|
src/context.ts |
Broadens accepted user-event implementations. |
test/context.test.ts |
Adds Storybook context compatibility checks. |
.changeset/accept-setup-user-event.md |
Documents the release change. |
🧠 Review effort: Balanced
Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.
UserEvent methods now return Promise<unknown>; keyboard() lost its System result type.

StoryContext.userEventisReturnType<typeof userEvent.setup>(keyboard(): Promise<void>).UserEventwas picked from the direct API (keyboard(): Promise<System>), so passing a real context toI.initfailed typecheck once@testing-library/user-eventtypes resolved; consumers had to cast.UserEventtypes onlyclear/click/keyboard/tab/type, taking the setup-instance parameters and returningPromise<unknown>. Both the instance and the direct API are assignable. Still renderer-agnostic, type-only import from thestorybookpeer.test/context.test.tsasserts withexpectTypeOf(...).toExtend<StoryContext>()that Storybook'sStoryContextandStoryContextForLoaders(with a custom renderer and args, sinceStepFunctionis invariant in them) and a direct-userEventcontext are accepted. Without the fix, typecheck reports 3 errors.UserEventmethods returnPromise<unknown>, sokeyboard()no longer resolves toSystem). README doesn't mention the type, so it's unchanged.pnpm run checkpasses.[Claude Code (Opus 5.5) — t3cody]
Summary by CodeRabbit
userEvent.setup()or the directuserEventAPI.