fix: await Promise-shaped waitForEvent mocks before validation - #1669
fix: await Promise-shaped waitForEvent mocks before validation#1669leen-neel wants to merge 2 commits into
Conversation
InngestTestEngine stores mocked step results as Promises; use the resolved values in validateEvents so documented steps mocks no longer throw EventValidationError (inngest#1652).
🦋 Changeset detectedLatest commit: 7983303 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
LGTM
The fix is correct and minimal. The existing Promise.all([result.data, result.error, result.input]) already awaited the values but the callback ignored the resolved outputs; now it destructures [resolvedData, resolvedError] and uses them consistently. The riskiest hunk—the typeof resolvedData !== "undefined" check at line 2570—correctly preserves the original semantics (distinguishing undefined from null for the timeout case). Tests cover both the resolved-event and null-timeout paths.
What this PR does
Fixes a bug where InngestTestEngine mocked step results (stored as Promises) were passed unresolved into validateEvents for step.waitForEvent, causing event.name to be undefined. The fix destructures the resolved values from the existing Promise.all call and uses them throughout the callback.
Tag @mendral-app with feedback or questions. View session
InngestTestEngine stores mocked step results as Promises; use the resolved values in validateEvents so documented steps mocks no longer throw EventValidationError (#1652).
Summary
InngestTestEnginestores mocked step results as Promises. The execution engine awaited those Promises but still passed the unresolved Promise intovalidateEventsforstep.waitForEvent, soevent.namewasundefinedand validation threwEventValidationError: Event not found in triggers: undefined.This change uses the resolved values from
Promise.allfor waitForEvent validation and memoized step handling, so the documentedstepsmock pattern works again.Checklist
Added a docs PR that references this PRN/A Bug fix; no docs change needed — existing testing docs already describe this APIRelated
InngestTestEngine: documentedsteps-option mock forstep.waitForEventthrowsEventValidationError: Event not found in triggers: undefined(v4) #1652