diff --git a/packages/next/server/app-render.tsx b/packages/next/server/app-render.tsx index 193b23526fe8..5a1bd0f5c45d 100644 --- a/packages/next/server/app-render.tsx +++ b/packages/next/server/app-render.tsx @@ -54,7 +54,7 @@ function preloadComponent(Component: any, props: any) { const prev = console.error // Hide invalid hook call warning when calling component console.error = function (msg) { - if (msg.startsWith('Invalid hook call..')) { + if (msg.startsWith('Warning: Invalid hook call.')) { // ignore } else { // @ts-expect-error argument is defined diff --git a/test/e2e/app-dir/index.test.ts b/test/e2e/app-dir/index.test.ts index f5424ec18bd0..912486fcd26d 100644 --- a/test/e2e/app-dir/index.test.ts +++ b/test/e2e/app-dir/index.test.ts @@ -136,8 +136,15 @@ describe('app dir', () => { if (!(global as any).isNextDeploy) { it('should serve /index as separate page', async () => { + const stderr = [] + next.on('stderr', (err) => { + stderr.push(err) + }) const html = await renderViaHTTP(next.url, '/dashboard/index') expect(html).toContain('hello from app/dashboard/index') + expect(stderr.some((err) => err.includes('Invalid hook call'))).toBe( + false + ) }) it('should handle next/dynamic correctly', async () => {