diff --git a/test/integration/basic/pages/dynamic/ssr-true.js b/test/integration/basic/pages/dynamic/ssr-true.js new file mode 100644 index 00000000..8488001b --- /dev/null +++ b/test/integration/basic/pages/dynamic/ssr-true.js @@ -0,0 +1,5 @@ +import dynamic from 'next/dynamic' + +const Hello = dynamic(import('../../components/hello1'), { ssr: true }) + +export default Hello diff --git a/test/integration/basic/test/dynamic.js b/test/integration/basic/test/dynamic.js index c88984ab..0331616d 100644 --- a/test/integration/basic/test/dynamic.js +++ b/test/integration/basic/test/dynamic.js @@ -54,7 +54,7 @@ export default (context, render) => { }) }) describe('ssr:false option', () => { - it('Should render loading on the server side', async () => { + it('should render loading on the server side', async () => { const $ = await get$('/dynamic/no-ssr') expect($('body').html()).not.toContain('"dynamicIds"') expect($('p').text()).toBe('loading...') @@ -73,6 +73,26 @@ export default (context, render) => { }) }) + describe('ssr:true option', () => { + it('Should render the component on the server side', async () => { + const $ = await get$('/dynamic/ssr-true') + expect($('body').html()).toContain('"dynamicIds"') + expect($('p').text()).toBe('Hello World 1') + }) + + it('should render the component on client side', async () => { + let browser + try { + browser = await webdriver(context.appPort, '/dynamic/ssr-true') + await check(() => browser.elementByCss('body').text(), /Hello World 1/) + } finally { + if (browser) { + browser.close() + } + } + }) + }) + describe('custom chunkfilename', () => { it('should render the correct filename', async () => { const $ = await get$('/dynamic/chunkfilename') diff --git a/test/integration/production/pages/dynamic/ssr-true.js b/test/integration/production/pages/dynamic/ssr-true.js new file mode 100644 index 00000000..8488001b --- /dev/null +++ b/test/integration/production/pages/dynamic/ssr-true.js @@ -0,0 +1,5 @@ +import dynamic from 'next/dynamic' + +const Hello = dynamic(import('../../components/hello1'), { ssr: true }) + +export default Hello diff --git a/test/integration/production/test/dynamic.js b/test/integration/production/test/dynamic.js index d74b1391..719061c1 100644 --- a/test/integration/production/test/dynamic.js +++ b/test/integration/production/test/dynamic.js @@ -30,7 +30,7 @@ export default (context, render) => { }) }) describe('ssr:false option', () => { - it('Should render loading on the server side', async () => { + it('should render loading on the server side', async () => { const $ = await get$('/dynamic/no-ssr') expect($('p').text()).toBe('loading...') }) @@ -48,6 +48,25 @@ export default (context, render) => { }) }) + describe('ssr:true option', () => { + it('should render the component on the server side', async () => { + const $ = await get$('/dynamic/ssr-true') + expect($('p').text()).toBe('Hello World 1') + }) + + it('should render the component on client side', async () => { + let browser + try { + browser = await webdriver(context.appPort, '/dynamic/ssr-true') + await check(() => browser.elementByCss('body').text(), /Hello World 1/) + } finally { + if (browser) { + browser.close() + } + } + }) + }) + describe('custom loading', () => { it('should render custom loading on the server side when `ssr:false` and `loading` is provided', async () => { const $ = await get$('/dynamic/no-ssr-custom-loading')