Unverified Commit 14c8900e authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

style(dev-overlay): refine the error message header styling (#63823)

### What

Polish the UX based on the feedbacks from @sambecker 

* Fix the font that still use mono
* Align the color, to use red for the warnings
* Give the title to build error
* Only highlight the nextjs doc url as link

### After vs Before

#### Runtime Error


<img width="335" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/64f2f692-1eae-41db-9287-046aff9ba112">
<img width="335" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/2d4bad15-745e-4083-ba57-8968c0f321c2">

#### Build Error

<img width="335" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/ecfc3883-4522-40c6-b042-6d85e7ea970e">
<img width="335" alt="image"
src="https://github.com/vercel/next.js/assets/4800338/bbf37ec5-b639-4b95-a87f-9911182e431c">



Closes NEXT-2958
parent a1e5d0b0
...@@ -10,8 +10,9 @@ const splitRegexp = new RegExp(`(${MAGIC_IDENTIFIER_REGEX.source}|\\s+)`) ...@@ -10,8 +10,9 @@ const splitRegexp = new RegExp(`(${MAGIC_IDENTIFIER_REGEX.source}|\\s+)`)
export const HotlinkedText: React.FC<{ export const HotlinkedText: React.FC<{
text: string text: string
matcher?: (text: string) => boolean
}> = function HotlinkedText(props) { }> = function HotlinkedText(props) {
const { text } = props const { text, matcher } = props
const wordsAndWhitespaces = text.split(splitRegexp) const wordsAndWhitespaces = text.split(splitRegexp)
...@@ -20,9 +21,14 @@ export const HotlinkedText: React.FC<{ ...@@ -20,9 +21,14 @@ export const HotlinkedText: React.FC<{
{wordsAndWhitespaces.map((word, index) => { {wordsAndWhitespaces.map((word, index) => {
if (linkRegex.test(word)) { if (linkRegex.test(word)) {
const link = linkRegex.exec(word)! const link = linkRegex.exec(word)!
const href = link[0]
// If link matcher is present but the link doesn't match, don't turn it into a link
if (typeof matcher === 'function' && !matcher(href)) {
return word
}
return ( return (
<React.Fragment key={`link-${index}`}> <React.Fragment key={`link-${index}`}>
<a href={link[0]} target="_blank" rel="noreferrer noopener"> <a href={href} target="_blank" rel="noreferrer noopener">
{word} {word}
</a> </a>
</React.Fragment> </React.Fragment>
......
...@@ -22,16 +22,22 @@ export const BuildError: React.FC<BuildErrorProps> = function BuildError({ ...@@ -22,16 +22,22 @@ export const BuildError: React.FC<BuildErrorProps> = function BuildError({
<Overlay fixed> <Overlay fixed>
<Dialog <Dialog
type="error" type="error"
aria-labelledby="nextjs__container_build_error_label" aria-labelledby="nextjs__container_error_label"
aria-describedby="nextjs__container_build_error_desc" aria-describedby="nextjs__container_error_desc"
onClose={noop} onClose={noop}
> >
<DialogContent> <DialogContent>
<DialogHeader className="nextjs-container-build-error-header"> <DialogHeader className="nextjs-container-errors-header">
<h4 id="nextjs__container_build_error_label">Failed to compile</h4> <h1 id="nextjs__container_errors_label">{'Build Error'}</h1>
<p
id="nextjs__container_errors_desc"
className="nextjs__container_errors_desc"
>
Failed to compile
</p>
{versionInfo ? <VersionStalenessInfo {...versionInfo} /> : null} {versionInfo ? <VersionStalenessInfo {...versionInfo} /> : null}
</DialogHeader> </DialogHeader>
<DialogBody className="nextjs-container-build-error-body"> <DialogBody className="nextjs-container-errors-body">
<Terminal content={message} /> <Terminal content={message} />
<footer> <footer>
<p id="nextjs__container_build_error_desc"> <p id="nextjs__container_build_error_desc">
...@@ -49,24 +55,25 @@ export const BuildError: React.FC<BuildErrorProps> = function BuildError({ ...@@ -49,24 +55,25 @@ export const BuildError: React.FC<BuildErrorProps> = function BuildError({
} }
export const styles = css` export const styles = css`
.nextjs-container-build-error-header { .nextjs-container-errors-header > h1 {
display: flex; font-size: var(--size-font-big);
align-items: center; line-height: var(--size-font-bigger);
font-weight: bold;
margin: var(--size-gap-double) 0;
} }
.nextjs-container-build-error-header > h4 { .nextjs-container-errors-header p {
line-height: 1.5; font-size: var(--size-font-small);
margin: 0; line-height: var(--size-font-big);
padding: 0; white-space: pre-wrap;
} }
.nextjs-container-errors-body footer {
.nextjs-container-build-error-body footer {
margin-top: var(--size-gap); margin-top: var(--size-gap);
} }
.nextjs-container-build-error-body footer p { .nextjs-container-errors-body footer p {
margin: 0; margin: 0;
} }
.nextjs-container-build-error-body small { .nextjs-container-errors-body small {
color: var(--color-font); color: var(--color-font);
} }
` `
...@@ -44,6 +44,10 @@ type ReadyErrorEvent = ReadyRuntimeError ...@@ -44,6 +44,10 @@ type ReadyErrorEvent = ReadyRuntimeError
type DisplayState = 'minimized' | 'fullscreen' | 'hidden' type DisplayState = 'minimized' | 'fullscreen' | 'hidden'
function isNextjsLink(text: string): boolean {
return text.startsWith('https://nextjs.org')
}
function getErrorSignature(ev: SupportedErrorEvent): string { function getErrorSignature(ev: SupportedErrorEvent): string {
const { event } = ev const { event } = ev
switch (event.type) { switch (event.type) {
...@@ -268,19 +272,20 @@ export function Errors({ ...@@ -268,19 +272,20 @@ export function Errors({
id="nextjs__container_errors_desc" id="nextjs__container_errors_desc"
className="nextjs__container_errors_desc" className="nextjs__container_errors_desc"
> >
{error.name}: <HotlinkedText text={error.message} /> {error.name}:{' '}
<HotlinkedText text={error.message} matcher={isNextjsLink} />
</p> </p>
{hydrationWarning && ( {hydrationWarning && (
<> <>
<p <p
id="nextjs__container_errors__extra" id="nextjs__container_errors__notes"
className="nextjs__container_errors__extra" className="nextjs__container_errors__notes"
> >
{hydrationWarning} {hydrationWarning}
</p> </p>
{activeError.componentStackFrames?.length ? ( {activeError.componentStackFrames?.length ? (
<PseudoHtmlDiff <PseudoHtmlDiff
className="nextjs__container_errors__extra_code" className="nextjs__container_errors__component-stack"
hydrationMismatchType={hydrationErrorType} hydrationMismatchType={hydrationErrorType}
componentStackFrames={activeError.componentStackFrames} componentStackFrames={activeError.componentStackFrames}
firstContent={serverContent} firstContent={serverContent}
...@@ -312,7 +317,8 @@ export const styles = css` ...@@ -312,7 +317,8 @@ export const styles = css`
font-size: var(--size-font-big); font-size: var(--size-font-big);
line-height: var(--size-font-bigger); line-height: var(--size-font-bigger);
font-weight: bold; font-weight: bold;
margin: var(--size-gap-double) 0; margin: calc(var(--size-gap-double) * 1.5) 0;
color: var(--color-title-h1);
} }
.nextjs-container-errors-header small { .nextjs-container-errors-header small {
font-size: var(--size-font-small); font-size: var(--size-font-small);
...@@ -320,44 +326,45 @@ export const styles = css` ...@@ -320,44 +326,45 @@ export const styles = css`
margin-left: var(--size-gap-double); margin-left: var(--size-gap-double);
} }
.nextjs-container-errors-header small > span { .nextjs-container-errors-header small > span {
font-family: var(--font-stack-sans); font-family: var(--font-stack-monospace);
} }
.nextjs-container-errors-header p { .nextjs-container-errors-header p {
font-family: var(--font-stack-sans);
font-size: var(--size-font-small); font-size: var(--size-font-small);
line-height: var(--size-font-big); line-height: var(--size-font-big);
margin: 0;
margin-top: var(--size-gap);
white-space: pre-wrap; white-space: pre-wrap;
} }
.nextjs__container_errors_desc { .nextjs__container_errors_desc {
padding-left: var(--size-gap); font-family: var(--font-stack-monospace);
border-left: 4px solid var(--color-accents-1); padding: var(--size-gap) var(--size-gap-double);
border-left: 2px solid var(--color-text-color-red-1);
margin-top: var(--size-gap); margin-top: var(--size-gap);
font-weight: 500; font-weight: bold;
color: var(--color-stack-subline); color: var(--color-text-color-red-1);
background-color: var(--color-text-background-red-1);
} }
.nextjs__container_errors__extra { p.nextjs__container_errors__notes {
margin: var(--size-gap-half) 0; margin: var(--size-gap-double) auto;
color: var(--color-stack-headline); color: var(--color-stack-notes);
font-weight: 500; font-weight: 600;
font-size: 15px;
} }
.nextjs-container-errors-header > div > small { .nextjs-container-errors-header > div > small {
margin: 0; margin: 0;
margin-top: var(--size-gap-half); margin-top: var(--size-gap-half);
} }
.nextjs-container-errors-header > p > a { .nextjs-container-errors-header > p > a {
color: inherit;
font-weight: bold; font-weight: bold;
} }
.nextjs-container-errors-body > h2:not(:first-child) { .nextjs-container-errors-body > h2:not(:first-child) {
margin-top: calc(var(--size-gap-double) + var(--size-gap)); margin-top: calc(var(--size-gap-double) + var(--size-gap));
} }
.nextjs-container-errors-body > h2 { .nextjs-container-errors-body > h2 {
color: var(--color-title-color);
margin-bottom: var(--size-gap); margin-bottom: var(--size-gap);
font-size: var(--size-font-big); font-size: var(--size-font-big);
} }
.nextjs__container_errors__extra_code { .nextjs__container_errors__component-stack {
margin-top: var(--size-gap);
padding: 12px 32px; padding: 12px 32px;
color: var(--color-ansi-fg); color: var(--color-ansi-fg);
background: var(--color-ansi-bg); background: var(--color-ansi-bg);
......
...@@ -21,17 +21,22 @@ export function Base() { ...@@ -21,17 +21,22 @@ export function Base() {
--color-font: #757575; --color-font: #757575;
--color-backdrop: rgba(17, 17, 17, 0.2); --color-backdrop: rgba(17, 17, 17, 0.2);
--color-title-color: #1f1f1f;
--color-stack-h6: #222; --color-stack-h6: #222;
--color-stack-headline: #666; --color-stack-headline: #666;
--color-stack-subline: #999; --color-stack-subline: #999;
--color-stack-notes: #777;
--color-accents-1: #808080; --color-accents-1: #808080;
--color-accents-2: #222222; --color-accents-2: #222222;
--color-accents-3: #404040; --color-accents-3: #404040;
--color-text-color-red-1: #ff5555;
--color-text-background-red-1: #fff9f9;
--font-stack-monospace: 'SFMono-Regular', Consolas, 'Liberation Mono', --font-stack-monospace: 'SFMono-Regular', Consolas, 'Liberation Mono',
Menlo, Courier, monospace; Menlo, Courier, monospace;
--font-stack-sans: -apple-system, BlinkMacSystemFont, sans-serif; --font-stack-sans: -apple-system, 'Source Sans Pro', sans-serif;
--color-ansi-selection: rgba(95, 126, 151, 0.48); --color-ansi-selection: rgba(95, 126, 151, 0.48);
--color-ansi-bg: #111111; --color-ansi-bg: #111111;
...@@ -61,11 +66,15 @@ export function Base() { ...@@ -61,11 +66,15 @@ export function Base() {
--color-font: white; --color-font: white;
--color-backdrop: rgb(44, 44, 46); --color-backdrop: rgb(44, 44, 46);
--color-title-color: #fafafa;
--color-stack-h6: rgb(200, 200, 204); --color-stack-h6: rgb(200, 200, 204);
--color-stack-headline: rgb(99, 99, 102); --color-stack-headline: rgb(99, 99, 102);
--color-stack-notes: #a9a9a9;
--color-stack-subline: rgb(121, 121, 121); --color-stack-subline: rgb(121, 121, 121);
--color-accents-3: rgb(118, 118, 118); --color-accents-3: rgb(118, 118, 118);
--color-text-background-red-1: #2a1e1e;
} }
} }
......
...@@ -390,7 +390,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -390,7 +390,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
export default function Index() { export default function Index() {
const boom = useCallback(() => { const boom = useCallback(() => {
throw new Error('end http://nextjs.org') throw new Error('end https://nextjs.org')
}, []) }, [])
return ( return (
<main> <main>
...@@ -435,7 +435,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -435,7 +435,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
export default function Index() { export default function Index() {
const boom = useCallback(() => { const boom = useCallback(() => {
throw new Error('http://nextjs.org start') throw new Error('https://nextjs.org start')
}, []) }, [])
return ( return (
<main> <main>
...@@ -480,7 +480,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -480,7 +480,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
export default function Index() { export default function Index() {
const boom = useCallback(() => { const boom = useCallback(() => {
throw new Error('middle http://nextjs.org end') throw new Error('middle https://nextjs.org end')
}, []) }, [])
return ( return (
<main> <main>
...@@ -525,7 +525,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -525,7 +525,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
export default function Index() { export default function Index() {
const boom = useCallback(() => { const boom = useCallback(() => {
throw new Error('multiple http://nextjs.org links http://example.com') throw new Error('multiple https://nextjs.org links http://example.com')
}, []) }, [])
return ( return (
<main> <main>
...@@ -541,8 +541,9 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -541,8 +541,9 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
const header4 = await session.getRedboxDescription() const header4 = await session.getRedboxDescription()
expect(header4).toMatchInlineSnapshot( expect(header4).toMatchInlineSnapshot(
`"Error: multiple http://nextjs.org links http://example.com"` `"Error: multiple https://nextjs.org links http://example.com"`
) )
// Do not highlight example.com but do highlight nextjs.org
expect( expect(
await session.evaluate( await session.evaluate(
() => () =>
...@@ -551,7 +552,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -551,7 +552,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
.shadowRoot.querySelectorAll('#nextjs__container_errors_desc a') .shadowRoot.querySelectorAll('#nextjs__container_errors_desc a')
.length .length
) )
).toBe(2) ).toBe(1)
expect( expect(
await session.evaluate( await session.evaluate(
() => () =>
...@@ -575,7 +576,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -575,7 +576,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
) as any ) as any
).href ).href
) )
).toMatchSnapshot() ).toBe(null)
await cleanup() await cleanup()
}) })
......
...@@ -60,21 +60,19 @@ Syntax error: Selector "button" is not pure (pure selectors must contain at leas ...@@ -60,21 +60,19 @@ Syntax error: Selector "button" is not pure (pure selectors must contain at leas
| ^" | ^"
`; `;
exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 1`] = `"Error: end http://nextjs.org"`; exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 1`] = `"Error: end https://nextjs.org"`;
exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 2`] = `"http://nextjs.org/"`; exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 2`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 3`] = `"Error: http://nextjs.org start"`; exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 3`] = `"Error: https://nextjs.org start"`;
exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 4`] = `"http://nextjs.org/"`; exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 4`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 5`] = `"Error: middle http://nextjs.org end"`; exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 5`] = `"Error: middle https://nextjs.org end"`;
exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 6`] = `"http://nextjs.org/"`; exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 6`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 8`] = `"http://nextjs.org/"`; exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 8`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox app default logbox: anchors links in error messages 9`] = `"http://example.com/"`;
exports[`ReactRefreshLogBox app default module init error not shown 1`] = ` exports[`ReactRefreshLogBox app default module init error not shown 1`] = `
"index.js (3:7) @ eval "index.js (3:7) @ eval
...@@ -154,21 +152,19 @@ Parsing css source code failed ...@@ -154,21 +152,19 @@ Parsing css source code failed
Selector is not pure (pure selectors must contain at least one local class or id), (lightningcss, Selector(button, specificity = 0x1))" Selector is not pure (pure selectors must contain at least one local class or id), (lightningcss, Selector(button, specificity = 0x1))"
`; `;
exports[`ReactRefreshLogBox app turbo logbox: anchors links in error messages 1`] = `"Error: end http://nextjs.org"`; exports[`ReactRefreshLogBox app turbo logbox: anchors links in error messages 1`] = `"Error: end https://nextjs.org"`;
exports[`ReactRefreshLogBox app turbo logbox: anchors links in error messages 2`] = `"http://nextjs.org/"`;
exports[`ReactRefreshLogBox app turbo logbox: anchors links in error messages 3`] = `"Error: http://nextjs.org start"`; exports[`ReactRefreshLogBox app turbo logbox: anchors links in error messages 2`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox app turbo logbox: anchors links in error messages 4`] = `"http://nextjs.org/"`; exports[`ReactRefreshLogBox app turbo logbox: anchors links in error messages 3`] = `"Error: https://nextjs.org start"`;
exports[`ReactRefreshLogBox app turbo logbox: anchors links in error messages 5`] = `"Error: middle http://nextjs.org end"`; exports[`ReactRefreshLogBox app turbo logbox: anchors links in error messages 4`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox app turbo logbox: anchors links in error messages 6`] = `"http://nextjs.org/"`; exports[`ReactRefreshLogBox app turbo logbox: anchors links in error messages 5`] = `"Error: middle https://nextjs.org end"`;
exports[`ReactRefreshLogBox app turbo logbox: anchors links in error messages 8`] = `"http://nextjs.org/"`; exports[`ReactRefreshLogBox app turbo logbox: anchors links in error messages 6`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox app turbo logbox: anchors links in error messages 9`] = `"http://example.com/"`; exports[`ReactRefreshLogBox app turbo logbox: anchors links in error messages 8`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox app turbo module init error not shown 1`] = ` exports[`ReactRefreshLogBox app turbo module init error not shown 1`] = `
"index.js (3:7) @ <unknown> "index.js (3:7) @ <unknown>
......
...@@ -382,7 +382,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -382,7 +382,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
export default function Index() { export default function Index() {
const boom = useCallback(() => { const boom = useCallback(() => {
throw new Error('end http://nextjs.org') throw new Error('end https://nextjs.org')
}, []) }, [])
return ( return (
<main> <main>
...@@ -428,7 +428,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -428,7 +428,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
export default function Index() { export default function Index() {
const boom = useCallback(() => { const boom = useCallback(() => {
throw new Error('http://nextjs.org start') throw new Error('https://nextjs.org start')
}, []) }, [])
return ( return (
<main> <main>
...@@ -474,7 +474,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -474,7 +474,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
export default function Index() { export default function Index() {
const boom = useCallback(() => { const boom = useCallback(() => {
throw new Error('middle http://nextjs.org end') throw new Error('middle https://nextjs.org end')
}, []) }, [])
return ( return (
<main> <main>
...@@ -520,7 +520,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -520,7 +520,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
export default function Index() { export default function Index() {
const boom = useCallback(() => { const boom = useCallback(() => {
throw new Error('multiple http://nextjs.org links http://example.com') throw new Error('multiple https://nextjs.org links http://example.com')
}, []) }, [])
return ( return (
<main> <main>
...@@ -537,8 +537,9 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -537,8 +537,9 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
const header4 = await session.getRedboxDescription() const header4 = await session.getRedboxDescription()
expect(header4).toMatchInlineSnapshot( expect(header4).toMatchInlineSnapshot(
`"Error: multiple http://nextjs.org links http://example.com"` `"Error: multiple https://nextjs.org links http://example.com"`
) )
// Do not highlight the http://example.com link
expect( expect(
await session.evaluate( await session.evaluate(
() => () =>
...@@ -547,7 +548,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -547,7 +548,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
.shadowRoot.querySelectorAll('#nextjs__container_errors_desc a') .shadowRoot.querySelectorAll('#nextjs__container_errors_desc a')
.length .length
) )
).toBe(2) ).toBe(1)
expect( expect(
await session.evaluate( await session.evaluate(
() => () =>
...@@ -571,7 +572,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -571,7 +572,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
) as any ) as any
).href ).href
) )
).toMatchSnapshot() ).toBe(null)
await session.patch( await session.patch(
'index.js', 'index.js',
...@@ -580,7 +581,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -580,7 +581,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
export default function Index() { export default function Index() {
const boom = useCallback(() => { const boom = useCallback(() => {
throw new Error('multiple http://nextjs.org links (http://example.com)') throw new Error('multiple https://nextjs.org links (http://example.com)')
}, []) }, [])
return ( return (
<main> <main>
...@@ -597,8 +598,9 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -597,8 +598,9 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
const header5 = await session.getRedboxDescription() const header5 = await session.getRedboxDescription()
expect(header5).toMatchInlineSnapshot( expect(header5).toMatchInlineSnapshot(
`"Error: multiple http://nextjs.org links (http://example.com)"` `"Error: multiple https://nextjs.org links (http://example.com)"`
) )
// Do not highlight the http://example.com link
expect( expect(
await session.evaluate( await session.evaluate(
() => () =>
...@@ -607,7 +609,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -607,7 +609,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
.shadowRoot.querySelectorAll('#nextjs__container_errors_desc a') .shadowRoot.querySelectorAll('#nextjs__container_errors_desc a')
.length .length
) )
).toBe(2) ).toBe(1)
expect( expect(
await session.evaluate( await session.evaluate(
() => () =>
...@@ -631,7 +633,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -631,7 +633,7 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
) as any ) as any
).href ).href
) )
).toMatchSnapshot() ).toBe(null)
await cleanup() await cleanup()
}) })
......
...@@ -26,25 +26,21 @@ Syntax error: Selector "button" is not pure (pure selectors must contain at leas ...@@ -26,25 +26,21 @@ Syntax error: Selector "button" is not pure (pure selectors must contain at leas
| ^" | ^"
`; `;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 1`] = `"Error: end http://nextjs.org"`; exports[`ReactRefreshLogBox default logbox: anchors links in error messages 1`] = `"Error: end https://nextjs.org"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 2`] = `"http://nextjs.org/"`; exports[`ReactRefreshLogBox default logbox: anchors links in error messages 2`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 3`] = `"Error: http://nextjs.org start"`; exports[`ReactRefreshLogBox default logbox: anchors links in error messages 3`] = `"Error: https://nextjs.org start"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 4`] = `"http://nextjs.org/"`; exports[`ReactRefreshLogBox default logbox: anchors links in error messages 4`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 5`] = `"Error: middle http://nextjs.org end"`; exports[`ReactRefreshLogBox default logbox: anchors links in error messages 5`] = `"Error: middle https://nextjs.org end"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 6`] = `"http://nextjs.org/"`; exports[`ReactRefreshLogBox default logbox: anchors links in error messages 6`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 8`] = `"http://nextjs.org/"`; exports[`ReactRefreshLogBox default logbox: anchors links in error messages 8`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 9`] = `"http://example.com/"`; exports[`ReactRefreshLogBox default logbox: anchors links in error messages 10`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 11`] = `"http://nextjs.org/"`;
exports[`ReactRefreshLogBox default logbox: anchors links in error messages 12`] = `"http://example.com/"`;
exports[`ReactRefreshLogBox default module init error not shown 1`] = ` exports[`ReactRefreshLogBox default module init error not shown 1`] = `
"index.js (3:7) @ eval "index.js (3:7) @ eval
...@@ -94,25 +90,21 @@ Parsing css source code failed ...@@ -94,25 +90,21 @@ Parsing css source code failed
Selector is not pure (pure selectors must contain at least one local class or id), (lightningcss, Selector(button, specificity = 0x1))" Selector is not pure (pure selectors must contain at least one local class or id), (lightningcss, Selector(button, specificity = 0x1))"
`; `;
exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 1`] = `"Error: end http://nextjs.org"`; exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 1`] = `"Error: end https://nextjs.org"`;
exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 2`] = `"http://nextjs.org/"`;
exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 3`] = `"Error: http://nextjs.org start"`;
exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 4`] = `"http://nextjs.org/"`; exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 2`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 5`] = `"Error: middle http://nextjs.org end"`; exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 3`] = `"Error: https://nextjs.org start"`;
exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 6`] = `"http://nextjs.org/"`; exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 4`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 8`] = `"http://nextjs.org/"`; exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 5`] = `"Error: middle https://nextjs.org end"`;
exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 9`] = `"http://example.com/"`; exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 6`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 11`] = `"http://nextjs.org/"`; exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 8`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 12`] = `"http://example.com/"`; exports[`ReactRefreshLogBox turbo logbox: anchors links in error messages 10`] = `"https://nextjs.org/"`;
exports[`ReactRefreshLogBox turbo module init error not shown 1`] = ` exports[`ReactRefreshLogBox turbo module init error not shown 1`] = `
"index.js (3:7) @ <unknown> "index.js (3:7) @ <unknown>
......
...@@ -269,9 +269,7 @@ createNextDescribe( ...@@ -269,9 +269,7 @@ createNextDescribe(
const browser = await next.browser('/') const browser = await next.browser('/')
expect(await hasRedbox(browser)).toBe(true) expect(await hasRedbox(browser)).toBe(true)
expect( expect(
await browser await browser.elementByCss('#nextjs__container_errors_desc').text()
.elementByCss('#nextjs__container_build_error_label')
.text()
).toEqual('Failed to compile') ).toEqual('Failed to compile')
await next.patchFile('middleware.js', `export default function () {}`) await next.patchFile('middleware.js', `export default function () {}`)
await hasRedbox(browser) await hasRedbox(browser)
......
...@@ -753,7 +753,7 @@ export async function hasRedbox(browser: BrowserInterface): Promise<boolean> { ...@@ -753,7 +753,7 @@ export async function hasRedbox(browser: BrowserInterface): Promise<boolean> {
.call(document.querySelectorAll('nextjs-portal')) .call(document.querySelectorAll('nextjs-portal'))
.find((p) => .find((p) =>
p.shadowRoot.querySelector( p.shadowRoot.querySelector(
'#nextjs__container_errors_label, #nextjs__container_build_error_label, #nextjs__container_root_layout_error_label' '#nextjs__container_errors_label, #nextjs__container_errors_label'
) )
) )
) )
...@@ -811,7 +811,7 @@ export async function getRedboxSource(browser: BrowserInterface) { ...@@ -811,7 +811,7 @@ export async function getRedboxSource(browser: BrowserInterface) {
.call(document.querySelectorAll('nextjs-portal')) .call(document.querySelectorAll('nextjs-portal'))
.find((p) => .find((p) =>
p.shadowRoot.querySelector( p.shadowRoot.querySelector(
'#nextjs__container_errors_label, #nextjs__container_build_error_label, #nextjs__container_root_layout_error_label' '#nextjs__container_errors_label, #nextjs__container_errors_label'
) )
) )
const root = portal.shadowRoot const root = portal.shadowRoot
...@@ -858,7 +858,7 @@ export async function getRedboxDescriptionWarning(browser: BrowserInterface) { ...@@ -858,7 +858,7 @@ export async function getRedboxDescriptionWarning(browser: BrowserInterface) {
) )
const root = portal.shadowRoot const root = portal.shadowRoot
const text = root.querySelector( const text = root.querySelector(
'#nextjs__container_errors__extra' '#nextjs__container_errors__notes'
)?.innerText )?.innerText
return text return text
}), }),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment