How to test query operators with Jest?

Hi everyone
I’m writing some unit tests with Jest for my repository methods.

For example, I have something like this:
await db.query.userTable.findFirst({
  where: (user, { eq }) => eq(user.id, id),
});


In my test, I’d like to assert what arguments I pass into findFirst (or findMany), especially the where condition.

The problem is that the operators (eq, and, or, etc.) are functions, so I can’t easily compare the where callback or check the arguments directly.

What’s the recommended way to test this?
Should I mock the operators, or is there a better practice to verify the where conditions in tests?

Thanks! 🙏
Was this page helpful?