forked from vercel/next.js
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(vercel#39609): move from e2e to intergration
- Loading branch information
Showing
4 changed files
with
63 additions
and
61 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
19 changes: 19 additions & 0 deletions
19
test/integration/next-dynamic-with-suspense/pages/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Thing() { | ||
return 'Thing' | ||
} |
41 changes: 41 additions & 0 deletions
41
test/integration/next-dynamic-with-suspense/test/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
}) | ||
}) |