File size: 2,109 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import { nextTestSetup } from 'e2e-utils'
import {
  assertHasRedbox,
  getRedboxDescription,
  getRedboxSource,
} from 'next-test-utils'

describe('app-dir - server-component-next-dynamic-ssr-false', () => {
  const { next } = nextTestSetup({
    files: __dirname,
  })

  it('should error when use dynamic ssr:false in server component', async () => {
    const browser = await next.browser('/')
    await assertHasRedbox(browser)
    const redbox = {
      description: await getRedboxDescription(browser),
      source: await getRedboxSource(browser),
    }

    if (process.env.IS_TURBOPACK_TEST) {
      expect(redbox.description).toMatchInlineSnapshot(
        `"Ecmascript file had an error"`
      )
      expect(redbox.source).toMatchInlineSnapshot(`
       "./app/page.js (3:23)
       Ecmascript file had an error
         1 | import dynamic from 'next/dynamic'
         2 |
       > 3 | const DynamicClient = dynamic(() => import('./client'), { ssr: false })
           |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         4 |
         5 | export default function Page() {
         6 |   return <DynamicClient />

       \`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a Client Component."
      `)
    } else {
      expect(redbox.description).toMatchInlineSnapshot(
        `"  x \`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a Client Component."`
      )
      expect(redbox.source).toMatchInlineSnapshot(`
         "./app/page.js
         Error:   x \`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a Client Component.
            ,-[3:1]
          1 | import dynamic from 'next/dynamic'
          2 | 
          3 | const DynamicClient = dynamic(() => import('./client'), { ssr: false })
            :                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          4 | 
          5 | export default function Page() {
          6 |   return <DynamicClient />
            \`----"
        `)
    }
  })
})