-
Notifications
You must be signed in to change notification settings - Fork 396
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mock Next.js in page router tests #1489
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 1 Ignored Deployment
|
@@ -170,15 +170,6 @@ describe('with-page-auth-required ssr', () => { | |||
delete process.env.NEXT_PUBLIC_AUTH0_LOGIN; | |||
}); | |||
|
|||
test('is a no-op when invoked as a client-side protection from the server', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need this test anymore since the same withPageAuthRequired
import isn't used for SSR and CSR since v3
const parseJson = (req: IncomingMessage, res: ServerResponse): Promise<IncomingMessage> => | ||
new Promise((resolve, reject) => { | ||
export const parseJson = async (req: IncomingMessage, res: ServerResponse): Promise<IncomingMessage> => { | ||
const { default: bodyParser } = await import('body-parser'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just curious, what is the reason we need a dynamic import here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a dependency on this file in tests/fixtures/server.ts
which some test files that run edge tests depend on and body-parser
can't be imported on the edge runtime (it must use eval
or something)
📋 Changes
Mock out the next test app for page router tests - since standing up a next app for every test is too expensive for the CI (didn't work in GH actions and was flakey on CircleCI)
Before:
After:
🎯 Testing
Tested on GH actions https://github.com/auth0/nextjs-auth0/actions/runs/6494889625/job/17638727581