backpack1098B
Convex Community9mo ago
5 replies
backpack1098

how to mock convex actions?

I'm trying to write tests for a function that uses AWS KMS decryption (fetchSomething). This function relies on internal.kms.decrypt action.

I've tried several approaches but all attempts resulted in type errors or failed decryption.

What's the correct way to mock an internal action in Convex tests?

Example of what I'm trying to test:
export const fetchSomething = action({
  args: {...},
  handler: async (ctx, args) => {

    // ... gets encrypted token ...
    const decryptedToken = await ctx.runAction(
      internal.kms.decrypt,
      { token: user.token }
    )
    // ... uses decrypted token ...

  }
})
Was this page helpful?