Creating trpc context (express server) for testing without req and res objects.
I have seen a few examples of tests with next auth or t3 stack that is using next-auth under the hood.
My problem is that I don't understand what should my inner context object contain, because I'm using express server 😦
For example, this is my context and t object. Req and res are mandatory:
Then, my require auth middleware function is:
Of course, I cannot create called with this setup, because, I will need to have req and res object.
It's not possible to use next-auth as well.
If you have any example express trpc testing code, it would be awesome if you showed me how this can be achieved.
If not, the question is:
How do I need to rewrite the context creation and what should the inner context accept and return? Should I get the headers and other data before the inner context?
0 Replies