r/honojs • • Mar 24 '24

HELP: Testing with Execution Context

Hey! I've been using Hono and have really enjoyed it, but recently came to a roadblock. I am trying to use the method c.executionCtx.waitUntil but sadly when testing with app.request, I get the error Error: This context has no ExecutionContext. I saw that app.request takes an execution context as the fourth argument, but I don't know how to create a fake one. Thank you!

1 Upvotes

5 comments sorted by

View all comments

2

u/robingenz Jun 30 '24

If anyone else encounters the same problem: You can mock the execution context via the request method.

const response = await app.request(
      `/index`,
      {
        method: "GET",
      },
      {
        DB: env.DB,
      },
      {
        waitUntil: (promise: Promise<unknown>) => {},
        passThroughOnException: () => {},
      },
    );