Using Next.js middleware and withAuth breaks Playwright E2E tests with Prisma adapter in Github actions only #9854
Unanswered
juan-carlos-correa
asked this question in
Help
Replies: 1 comment
-
Seems like I have the same issue. Do you find any solution to this? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm working in a personal open-source project using next-auth as part of the tech stack.
The issue that I have is that if I add a middleware using the
withAuth
from next-auth, my tests are failing in Github actions only (in local everything is fine).Here is when I had the test errors:
The middleware with withAuth:
I downloaded the Playwright html report and after debugging and some checks, I found out that in the test, it's behaving like the DB is empty (which is weird since there are another tests where the user is required to be authenticated).
The next SS is how the UI looks like when I'm getting the users from the DB, but in this case, behaves like there are not users (but I have an user logged in in the app).
As proof, I reverted the middleware and it's working as expected.
This is how it looks like when is working:
The curious part is that Prisma is not returning data from the DB when the tests are failing, as if the DB does not have data in the users table.
And if I just use the Next.js middlware with a simple console log (without the
withAuth
wrapper from next-auth), the tests are passing:withAuth
that is passing.What does this means?
If I use the
withAuth
, my tests fail, and if I don't, my tests pass. That's why I believe is a possible issue withwithAuth
middleware.My first guess was that I was doing something wrong in my tests or I was missing something in the GA configurations, but is weird that only when I add a middleware I have the error and without the middleware I'm not having it, isn't?
I would appreciate any help or suggest 🙏
Beta Was this translation helpful? Give feedback.
All reactions