| |
| new file mode 100644 |
| |
| |
| |
| @@ -0,0 +1,7 @@ |
| +export default function RootLayout({ children }) { |
| + return ( |
| + <html> |
| + <body>{children}</body> |
| + </html> |
| + ) |
| +} |
| |
| new file mode 100644 |
| |
| |
| |
| @@ -0,0 +1,10 @@ |
| +'use client' |
| + |
| +function throwError() { |
| + throw new Error('ssr-throw') |
| +} |
| + |
| +export function Thrower() { |
| + throwError() |
| + return null |
| +} |
| |
| new file mode 100644 |
| |
| |
| |
| @@ -0,0 +1,5 @@ |
| +import { Thrower } from './Thrower' |
| + |
| +export default function Page() { |
| + return <Thrower /> |
| +} |
| |
| new file mode 100644 |
| |
| |
| |
| @@ -0,0 +1 @@ |
| +module.exports = {} |
| |
| new file mode 100644 |
| |
| |
| |
| @@ -0,0 +1,66 @@ |
| +import * as path from 'path' |
| +import { nextTestSetup } from 'e2e-utils' |
| +import stripAnsi from 'strip-ansi' |
| +import { getRedboxSource, retry } from 'next-test-utils' |
| + |
| +function setup(subDir: string) { |
| + return nextTestSetup({ |
| + files: path.join(__dirname, 'fixtures'), |
| + subDir, |
| + }) |
| +} |
| + |
| +async function assertSymbolicatedSSRError( |
| + next: ReturnType<typeof setup>['next'] |
| +) { |
| + const outputIndex = next.cliOutput.length |
| + const browser = await next.browser('/ssr-throw') |
| + |
| + await retry(() => { |
| + expect(next.cliOutput.slice(outputIndex)).toContain('Error: ssr-throw') |
| + }) |
| + |
| + const cliOutput = stripAnsi(next.cliOutput.slice(outputIndex)) |
| + expect(cliOutput).toContain('at throwError (app/ssr-throw/Thrower.js:4:9)') |
| + expect(cliOutput).toContain('at Thrower (app/ssr-throw/Thrower.js:8:3)') |
| + expect(cliOutput).toContain("throw new Error('ssr-throw')") |
| + |
| + let redboxSource: string | null = null |
| + await retry(async () => { |
| + redboxSource = await getRedboxSource(browser) |
| + expect(redboxSource).not.toBeNull() |
| + }) |
| + expect(redboxSource).toContain('app/ssr-throw/Thrower.js (4:9) @ throwError') |
| + expect(redboxSource).toContain("throw new Error('ssr-throw')") |
| +} |
| + |
| +// Symbolication must work in project directories whose absolute path |
| +// contains characters that need percent-encoding in URLs. |
| +describe('special project paths', () => { |
| + describe('in "space dir"', () => { |
| + const { skipped, next } = setup('space dir') |
| + if (skipped) return |
| + |
| + it('symbolicates thrown SSR errors', async () => { |
| + await assertSymbolicatedSSRError(next) |
| + }) |
| + }) |
| + |
| + describe('in "ünïcode-dir"', () => { |
| + const { skipped, next } = setup('ünïcode-dir') |
| + if (skipped) return |
| + |
| + it('symbolicates thrown SSR errors', async () => { |
| + await assertSymbolicatedSSRError(next) |
| + }) |
| + }) |
| + |
| + describe('in "bracket [dir]"', () => { |
| + const { skipped, next } = setup('bracket [dir]') |
| + if (skipped) return |
| + |
| + it('symbolicates thrown SSR errors', async () => { |
| + await assertSymbolicatedSSRError(next) |
| + }) |
| + }) |
| +}) |
|
|