Is there any way to mock cookies using testing helpers?
we already have testing helper and cookies helpers in Hono, but I can't find a way to inject cookies.
I'm using Lucia with Hono together, they recommend to transfer session by cookies. Is this possible in test environment?
if no, I have a worst plan is to create a custom app and takeover routes. and replace cookie middleware with bearer token middleware.
how do you think?
5 Replies
im doing this, it's worked, i don't know what's happend.
What is
Cookie
? and how are you adding cookies in your frontend?Cookie is a string returned by the backend via response headers (Set-Cookie). In the production environment, the browser will automatically send cookies. Only in the test environment, I will manually add Cookie to the headers. For me this solve the problem.
Usually the behavior is that we get connect to a test env where their is mock user, which we use to get the cookie.
GitHub
hono-session/test/setup.ts at master · KaelWD/hono-session
Contribute to KaelWD/hono-session development by creating an account on GitHub.