Skip to content

fix: await Promise-shaped waitForEvent mocks before validation - #1669

Open
leen-neel wants to merge 2 commits into
inngest:mainfrom
leen-neel:fix/1652-wait-for-event-mock-promise
Open

fix: await Promise-shaped waitForEvent mocks before validation#1669
leen-neel wants to merge 2 commits into
inngest:mainfrom
leen-neel:fix/1652-wait-for-event-mock-promise

Conversation

@leen-neel

Copy link
Copy Markdown

InngestTestEngine stores mocked step results as Promises; use the resolved values in validateEvents so documented steps mocks no longer throw EventValidationError (#1652).

Summary

InngestTestEngine stores mocked step results as Promises. The execution engine awaited those Promises but still passed the unresolved Promise into validateEvents for step.waitForEvent, so event.name was undefined and validation threw EventValidationError: Event not found in triggers: undefined.

This change uses the resolved values from Promise.all for waitForEvent validation and memoized step handling, so the documented steps mock pattern works again.

Checklist

  • Added a docs PR that references this PR N/A Bug fix; no docs change needed — existing testing docs already describe this API
  • Added unit/integration tests
  • Added changesets if applicable

Related

InngestTestEngine stores mocked step results as Promises; use the
resolved values in validateEvents so documented steps mocks no longer
throw EventValidationError (inngest#1652).
@changeset-bot

changeset-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7983303

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
inngest Patch

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

@mendral-app mendral-app Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

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.

[BUG] InngestTestEngine: documented steps-option mock for step.waitForEvent throws EventValidationError: Event not found in triggers: undefined (v4)

1 participant