Skip to content

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

Description

@redlumxn

Describe the bug

Mocking step.waitForEvent with the steps option exactly as prescribed in the v4 testing docs throws EventValidationError: Event not found in triggers: undefined on every execution. As far as we can tell, waitForEvent cannot currently be mocked the documented way on the latest versions of both packages. The failure is identical whether the waitForEvent option is a string event name or an EventType instance.

To Reproduce

Steps to reproduce the behavior:

  1. Create a function that calls step.waitForEvent
  2. Test it with InngestTestEngine, mocking the wait step via the steps option with a handler that returns an event (the shape from the testing docs)
  3. execute() the function with its trigger event
  4. error is an EventValidationError instead of the function completing with the mocked event

Expected behavior

The mocked handler's return value resolves the waitForEvent step (or null simulates a timeout), and the function proceeds — as documented.

Code snippets / Logs / Screenshots

Minimal repro (verified on the versions below):

import { InngestTestEngine } from "@inngest/test";
import { Inngest, eventType, staticSchema } from "inngest";

const inngest = new Inngest({ id: "repro", isDev: true });

const started = eventType("demo/started", {
  schema: staticSchema<{ id: string }>(),
});

const fn = inngest.createFunction(
  { id: "wait-repro", triggers: [started] },
  async ({ step }) => {
    const approval = await step.waitForEvent("wait-for-approval", {
      event: "demo/approved",
      timeout: "1d",
    });
    return { approved: approval !== null };
  },
);

const t = new InngestTestEngine({
  function: fn,
  steps: [
    {
      id: "wait-for-approval",
      handler() {
        return { name: "demo/approved", data: { ok: true } };
      },
    },
  ],
});

const { error } = await t.execute({
  events: [started.create({ id: "1" })],
});

error is:

EventValidationError: Event not found in triggers: undefined
    at getValidatorForEvent (inngest/components/triggers/utils.js:92)
    at validateEvents (inngest/components/triggers/utils.js:75)
    at inngest/components/execution/engine.js:1435

System info (please complete the following information):

  • OS: macOS
  • npm package Version: inngest 4.13.0, @inngest/test 1.0.0 (both latest)
  • Framework: none — repro is framework-independent (run under vitest; we use Fastify in the app)
  • Platform: local test run (Node 24, TypeScript 5.9)

Additional context

Our interim workaround is a transformCtx that replaces step.waitForEvent with a stub, bypassing the engine's step machinery for that tool.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions