Skip to content

Commit

Permalink
test(vercel#39609): move from e2e to intergration
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Aug 18, 2022
1 parent 8698929 commit 90dc72a
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 61 deletions.
61 changes: 0 additions & 61 deletions test/e2e/dynamic-with-suspense/index.test.ts

This file was deleted.

19 changes: 19 additions & 0 deletions test/integration/next-dynamic-with-suspense/pages/index.js
@@ -0,0 +1,19 @@
import { Suspense } from 'react'
import dynamic from 'next/dynamic'

const Thing = dynamic(() => import('./thing'), {
ssr: false,
suspense: true,
loading: () => 'Loading...',
})

export default function IndexPage() {
return (
<div>
<p>Next.js Example</p>
<Suspense fallback="Loading...">
<Thing />
</Suspense>
</div>
)
}
3 changes: 3 additions & 0 deletions test/integration/next-dynamic-with-suspense/pages/thing.js
@@ -0,0 +1,3 @@
export default function Thing() {
return 'Thing'
}
41 changes: 41 additions & 0 deletions test/integration/next-dynamic-with-suspense/test/index.test.ts
@@ -0,0 +1,41 @@
/* eslint-env jest */

import webdriver from 'next-webdriver'
import { join } from 'path'
import {
renderViaHTTP,
findPort,
launchApp,
killApp,
hasRedbox,
} from 'next-test-utils'

let app
let appPort: number
const appDir = join(__dirname, '../')

describe('next/dynamic with suspense', () => {
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort)
})
afterAll(() => killApp(app))

it('should render server-side', async () => {
const html = await renderViaHTTP(appPort, '/')
expect(html).toContain('Next.js Example')
expect(html).toContain('Thing')
})

it('should render client-side', async () => {
const browser = await webdriver(appPort, '/')
const warnings = (await browser.log()).map((log) => log.message).join('\n')

expect(await hasRedbox(browser)).toBe(false)
expect(warnings).toMatch(
/"ssr: false" is ignored by next\/dynamic because you can not enable "suspense" while disabling "ssr" at the same time/gim
)

await browser.close()
})
})

0 comments on commit 90dc72a

Please sign in to comment.