-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test case for loading 404 on invalid bundle (#14082)
This adds a test case to ensure hard navigating when a client bundle fails to load is occurring correctly x-ref: #13516
- Loading branch information
Showing
3 changed files
with
49 additions
and
8 deletions.
There are no files selected for viewing
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,7 @@ | ||
import Link from 'next/link' | ||
|
||
export default () => ( | ||
<Link href="/[id]/non-existent" as="/another/non-existent"> | ||
<a id="to-nonexistent">to 404</a> | ||
</Link> | ||
) |
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
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 |
---|---|---|
@@ -1,23 +1,48 @@ | ||
/* eslint-env jest */ | ||
|
||
import { join } from 'path' | ||
import { renderViaHTTP, findPort, launchApp, killApp } from 'next-test-utils' | ||
import { | ||
renderViaHTTP, | ||
findPort, | ||
launchApp, | ||
killApp, | ||
nextBuild, | ||
nextStart, | ||
} from 'next-test-utils' | ||
|
||
// test suite | ||
import clientNavigation from './client-navigation' | ||
|
||
const context = {} | ||
const appDir = join(__dirname, '../') | ||
jest.setTimeout(1000 * 60 * 5) | ||
|
||
const runTests = () => { | ||
clientNavigation(context, (p, q) => renderViaHTTP(context.appPort, p, q)) | ||
} | ||
|
||
describe('Client 404', () => { | ||
beforeAll(async () => { | ||
context.appPort = await findPort() | ||
context.server = await launchApp(join(__dirname, '../'), context.appPort) | ||
describe('dev mode', () => { | ||
beforeAll(async () => { | ||
context.appPort = await findPort() | ||
context.server = await launchApp(appDir, context.appPort) | ||
|
||
// pre-build page at the start | ||
await renderViaHTTP(context.appPort, '/') | ||
}) | ||
afterAll(() => killApp(context.server)) | ||
|
||
// pre-build page at the start | ||
await renderViaHTTP(context.appPort, '/') | ||
runTests() | ||
}) | ||
afterAll(() => killApp(context.server)) | ||
|
||
clientNavigation(context, (p, q) => renderViaHTTP(context.appPort, p, q)) | ||
describe('production mode', () => { | ||
beforeAll(async () => { | ||
await nextBuild(appDir) | ||
context.appPort = await findPort() | ||
context.server = await nextStart(appDir, context.appPort) | ||
}) | ||
afterAll(() => killApp(context.server)) | ||
|
||
runTests() | ||
}) | ||
}) |