Skip to content

Commit cc32469

Browse files
committed
Add dev test too
1 parent 2af2d22 commit cc32469

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

packages/next/next-server/server/render.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,10 @@ export async function renderToHTML(
460460
!isSSG &&
461461
!getServerSideProps
462462

463-
if (process.env.NEXT_CONCURRENT_FEATURES && typeof Document !== 'function') {
463+
if (
464+
(process.env.NEXT_CONCURRENT_FEATURES && typeof Document !== 'function') ||
465+
Document.prototype
466+
) {
464467
throw new Error(CUSTOM_DOCUMENT_RSC_ERROR + ` ${pathname}`)
465468
}
466469

test/integration/concurrent-document-component-error/test/index.test.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
/* eslint-env jest */
22

33
import { join } from 'path'
4-
import { nextBuild } from 'next-test-utils'
4+
import {
5+
renderViaHTTP,
6+
findPort,
7+
launchApp,
8+
killApp,
9+
nextBuild,
10+
} from 'next-test-utils'
511
import { CUSTOM_DOCUMENT_RSC_ERROR } from 'next/dist/lib/constants'
612

713
jest.setTimeout(1000 * 60)
@@ -12,4 +18,25 @@ describe('Concurrent Document Component Errors', () => {
1218
const { stderr } = await nextBuild(appDir, [], { stderr: true })
1319
expect(stderr).toContain(CUSTOM_DOCUMENT_RSC_ERROR)
1420
})
21+
22+
describe('development mode', () => {
23+
let output
24+
25+
beforeAll(async () => {
26+
const handleOutput = (msg) => {
27+
output += msg
28+
}
29+
const appPort = await findPort()
30+
const app = await launchApp(appDir, appPort, {
31+
onStdout: handleOutput,
32+
onStderr: handleOutput,
33+
})
34+
await renderViaHTTP(appPort, '/')
35+
await killApp(app)
36+
})
37+
38+
it('errors when document is a class component', () => {
39+
expect(output).toContain(CUSTOM_DOCUMENT_RSC_ERROR)
40+
})
41+
})
1542
})

0 commit comments

Comments
 (0)