Unverified Commit baa4f787 authored by Jiwon Choi's avatar Jiwon Choi Committed by GitHub

[DevOverlay] Align old and new overlay (#74935)

Enable the new UI for the CI testings of existing redbox tests.

There are several changes made to let the test pass, including
backporting changes to the old UI or removing one from the new, and are
as follows:

- Added back `|` after line number in code frame
([link](https://github.com/vercel/next.js/pull/74935#discussion_r1925725941))
- Removed unnecessary `@` in Terminal component
([link](https://github.com/vercel/next.js/pull/74935#discussion_r1925727156))
- Set open overlay default value to `true` in Pages Router
([link](https://github.com/vercel/next.js/pull/74935#discussion_r1925728104))
- Backport displaying the first first-party call stack frame to the
CallStack component
([link](https://github.com/vercel/next.js/pull/74935#discussion_r1925731313))
- Move the devTools component back to the error boundary
([link](https://github.com/vercel/next.js/pull/74935#discussion_r1925732706))
- Was moved out at
https://github.com/vercel/next.js/pull/74999#discussion_r1922998021

Closes NDX-674
Closes NDX-687
parent b29b6aa7
...@@ -578,7 +578,7 @@ jobs: ...@@ -578,7 +578,7 @@ jobs:
uses: ./.github/workflows/build_reusable.yml uses: ./.github/workflows/build_reusable.yml
with: with:
nodeVersion: 18.18.2 nodeVersion: 18.18.2
afterBuild: __NEXT_EXPERIMENTAL_PPR=true NEXT_EXTERNAL_TESTS_FILTERS="test/ppr-tests-manifest.json" node run-tests.js --timings -c ${TEST_CONCURRENCY} --type integration afterBuild: __NEXT_EXPERIMENTAL_PPR=true __NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY=true NEXT_EXTERNAL_TESTS_FILTERS="test/ppr-tests-manifest.json" node run-tests.js --timings -c ${TEST_CONCURRENCY} --type integration
stepName: 'test-ppr-integration' stepName: 'test-ppr-integration'
secrets: inherit secrets: inherit
...@@ -593,7 +593,7 @@ jobs: ...@@ -593,7 +593,7 @@ jobs:
group: [1/6, 2/6, 3/6, 4/6, 5/6, 6/6] group: [1/6, 2/6, 3/6, 4/6, 5/6, 6/6]
uses: ./.github/workflows/build_reusable.yml uses: ./.github/workflows/build_reusable.yml
with: with:
afterBuild: __NEXT_EXPERIMENTAL_PPR=true NEXT_EXTERNAL_TESTS_FILTERS="test/ppr-tests-manifest.json" NEXT_TEST_MODE=dev node run-tests.js --timings -g ${{ matrix.group }} -c ${TEST_CONCURRENCY} --type development afterBuild: __NEXT_EXPERIMENTAL_PPR=true __NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY=true NEXT_EXTERNAL_TESTS_FILTERS="test/ppr-tests-manifest.json" NEXT_TEST_MODE=dev node run-tests.js --timings -g ${{ matrix.group }} -c ${TEST_CONCURRENCY} --type development
stepName: 'test-ppr-dev-${{ matrix.group }}' stepName: 'test-ppr-dev-${{ matrix.group }}'
secrets: inherit secrets: inherit
...@@ -608,7 +608,7 @@ jobs: ...@@ -608,7 +608,7 @@ jobs:
group: [1/7, 2/7, 3/7, 4/7, 5/7, 6/7, 7/7] group: [1/7, 2/7, 3/7, 4/7, 5/7, 6/7, 7/7]
uses: ./.github/workflows/build_reusable.yml uses: ./.github/workflows/build_reusable.yml
with: with:
afterBuild: __NEXT_EXPERIMENTAL_PPR=true NEXT_EXTERNAL_TESTS_FILTERS="test/ppr-tests-manifest.json" NEXT_TEST_MODE=start node run-tests.js --timings -g ${{ matrix.group }} -c ${TEST_CONCURRENCY} --type production afterBuild: __NEXT_EXPERIMENTAL_PPR=true __NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY=true NEXT_EXTERNAL_TESTS_FILTERS="test/ppr-tests-manifest.json" NEXT_TEST_MODE=start node run-tests.js --timings -g ${{ matrix.group }} -c ${TEST_CONCURRENCY} --type production
stepName: 'test-ppr-prod-${{ matrix.group }}' stepName: 'test-ppr-prod-${{ matrix.group }}'
secrets: inherit secrets: inherit
......
...@@ -286,7 +286,11 @@ export function getDefineEnv({ ...@@ -286,7 +286,11 @@ export function getDefineEnv({
} }
: undefined), : undefined),
'process.env.__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY': 'process.env.__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY':
config.experimental.newDevOverlay ?? false, // When `__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY` is set on CI,
// we need to pass it here so it can be enabled.
process.env.__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY === 'true' ||
config.experimental.newDevOverlay ||
false,
} }
const userDefines = config.compiler?.define ?? {} const userDefines = config.compiler?.define ?? {}
......
...@@ -3,13 +3,14 @@ import type { GlobalErrorComponent } from '../../../error-boundary' ...@@ -3,13 +3,14 @@ import type { GlobalErrorComponent } from '../../../error-boundary'
import { PureComponent } from 'react' import { PureComponent } from 'react'
import { RuntimeErrorHandler } from '../../../errors/runtime-error-handler' import { RuntimeErrorHandler } from '../../../errors/runtime-error-handler'
type DevToolsErrorBoundaryProps = { type DevOverlayErrorBoundaryProps = {
children: React.ReactNode children: React.ReactNode
onError: (value: boolean) => void devOverlay: React.ReactNode
globalError: [GlobalErrorComponent, React.ReactNode] globalError: [GlobalErrorComponent, React.ReactNode]
onError: (value: boolean) => void
} }
type DevToolsErrorBoundaryState = { type DevOverlayErrorBoundaryState = {
isReactError: boolean isReactError: boolean
reactError: unknown reactError: unknown
} }
...@@ -37,9 +38,9 @@ function ErroredHtml({ ...@@ -37,9 +38,9 @@ function ErroredHtml({
) )
} }
export class DevToolsErrorBoundary extends PureComponent< export class DevOverlayErrorBoundary extends PureComponent<
DevToolsErrorBoundaryProps, DevOverlayErrorBoundaryProps,
DevToolsErrorBoundaryState DevOverlayErrorBoundaryState
> { > {
state = { isReactError: false, reactError: null } state = { isReactError: false, reactError: null }
...@@ -61,13 +62,18 @@ export class DevToolsErrorBoundary extends PureComponent< ...@@ -61,13 +62,18 @@ export class DevToolsErrorBoundary extends PureComponent<
} }
render() { render() {
const { children, globalError, devOverlay } = this.props
const { isReactError, reactError } = this.state
const fallback = ( const fallback = (
<ErroredHtml <ErroredHtml globalError={globalError} error={reactError} />
globalError={this.props.globalError}
error={this.state.reactError}
/>
) )
return this.state.isReactError ? fallback : this.props.children return (
<>
{isReactError ? fallback : children}
{devOverlay}
</>
)
} }
} }
...@@ -2,7 +2,7 @@ import type { OverlayState } from '../../shared' ...@@ -2,7 +2,7 @@ import type { OverlayState } from '../../shared'
import type { GlobalErrorComponent } from '../../../error-boundary' import type { GlobalErrorComponent } from '../../../error-boundary'
import { useState } from 'react' import { useState } from 'react'
import { DevToolsErrorBoundary } from './error-boundary' import { DevOverlayErrorBoundary } from './error-boundary'
import { ShadowPortal } from '../internal/components/shadow-portal' import { ShadowPortal } from '../internal/components/shadow-portal'
import { Base } from '../internal/styles/base' import { Base } from '../internal/styles/base'
import { ComponentStyles } from '../internal/styles/component-styles' import { ComponentStyles } from '../internal/styles/component-styles'
...@@ -24,34 +24,35 @@ export default function ReactDevOverlay({ ...@@ -24,34 +24,35 @@ export default function ReactDevOverlay({
const [isErrorOverlayOpen, setIsErrorOverlayOpen] = useState(false) const [isErrorOverlayOpen, setIsErrorOverlayOpen] = useState(false)
const { readyErrors } = useErrorHook({ errors: state.errors, isAppDir: true }) const { readyErrors } = useErrorHook({ errors: state.errors, isAppDir: true })
return ( const devOverlay = (
<> <ShadowPortal>
<DevToolsErrorBoundary <CssReset />
onError={setIsErrorOverlayOpen} <Base />
globalError={globalError} <Colors />
> <ComponentStyles />
{children}
</DevToolsErrorBoundary>
<ShadowPortal> <DevToolsIndicator
<CssReset /> state={state}
<Base /> readyErrorsLength={readyErrors.length}
<Colors /> setIsErrorOverlayOpen={setIsErrorOverlayOpen}
<ComponentStyles /> />
<DevToolsIndicator <ErrorOverlay
state={state} state={state}
readyErrorsLength={readyErrors.length} readyErrors={readyErrors}
setIsErrorOverlayOpen={setIsErrorOverlayOpen} isErrorOverlayOpen={isErrorOverlayOpen}
/> setIsErrorOverlayOpen={setIsErrorOverlayOpen}
/>
</ShadowPortal>
)
<ErrorOverlay return (
state={state} <DevOverlayErrorBoundary
readyErrors={readyErrors} devOverlay={devOverlay}
isErrorOverlayOpen={isErrorOverlayOpen} globalError={globalError}
setIsErrorOverlayOpen={setIsErrorOverlayOpen} onError={setIsErrorOverlayOpen}
/> >
</ShadowPortal> {children}
</> </DevOverlayErrorBoundary>
) )
} }
...@@ -36,9 +36,7 @@ export function CodeFrame({ stackFrame, codeFrame }: CodeFrameProps) { ...@@ -36,9 +36,7 @@ export function CodeFrame({ stackFrame, codeFrame }: CodeFrameProps) {
.map((line, a) => .map((line, a) =>
~(a = line.indexOf('|')) ~(a = line.indexOf('|'))
? line.substring(0, a) + ? line.substring(0, a) +
line line.substring(a).replace(`^\\ {${miniLeadingSpacesLength}}`, '')
.substring(a + 1)
.replace(`^\\ {${miniLeadingSpacesLength}}`, '')
: line : line
) )
.join('\n') .join('\n')
......
...@@ -126,6 +126,7 @@ const DevToolsPopover = ({ ...@@ -126,6 +126,7 @@ const DevToolsPopover = ({
return ( return (
<Toast <Toast
data-nextjs-toast
style={{ style={{
boxShadow: 'none', boxShadow: 'none',
zIndex: 2147483647, zIndex: 2147483647,
...@@ -174,6 +175,7 @@ const DevToolsPopover = ({ ...@@ -174,6 +175,7 @@ const DevToolsPopover = ({
onClick={hide} onClick={hide}
/> />
<IndicatorRow <IndicatorRow
data-nextjs-route-type={isStaticRoute ? 'static' : 'dynamic'}
label="Route" label="Route"
value={isStaticRoute ? 'Static' : 'Dynamic'} value={isStaticRoute ? 'Static' : 'Dynamic'}
/> />
...@@ -205,14 +207,15 @@ const IndicatorRow = ({ ...@@ -205,14 +207,15 @@ const IndicatorRow = ({
label, label,
value, value,
onClick, onClick,
...props
}: { }: {
label: string label: string
value: React.ReactNode value: React.ReactNode
onClick?: () => void onClick?: () => void
}) => { } & React.HTMLAttributes<HTMLDivElement | HTMLButtonElement>) => {
const Wrapper = onClick ? 'button' : 'div' const Wrapper = onClick ? 'button' : 'div'
return ( return (
<Wrapper data-nextjs-dev-tools-row onClick={onClick}> <Wrapper data-nextjs-dev-tools-row onClick={onClick} {...props}>
<span data-nextjs-dev-tools-row-label>{label}</span> <span data-nextjs-dev-tools-row-label>{label}</span>
<span data-nextjs-dev-tools-row-value>{value}</span> <span data-nextjs-dev-tools-row-value>{value}</span>
</Wrapper> </Wrapper>
......
...@@ -301,7 +301,8 @@ export const NextLogo = ({ ...@@ -301,7 +301,8 @@ export const NextLogo = ({
aria-label="Open issues overlay" aria-label="Open issues overlay"
onClick={onIssuesClick} onClick={onIssuesClick}
> >
{issueCount} {issueCount === 1 ? 'Issue' : 'Issues'} <span data-issues-count>{issueCount}</span>{' '}
{issueCount === 1 ? 'Issue' : 'Issues'}
</button> </button>
<button <button
data-issues-collapse data-issues-collapse
......
...@@ -100,8 +100,8 @@ export const Terminal: React.FC<TerminalProps> = function Terminal({ ...@@ -100,8 +100,8 @@ export const Terminal: React.FC<TerminalProps> = function Terminal({
> >
<span> <span>
<FileIcon /> <FileIcon />
{getFrameSource(stackFrame)} @{' '} {getFrameSource(stackFrame)}
<HotlinkedText text={stackFrame.methodName} /> {/* TODO: Unlike the CodeFrame component, the `methodName` is unavailable. */}
</span> </span>
<ExternalIcon width={16} height={16} /> <ExternalIcon width={16} height={16} />
</p> </p>
......
import * as React from 'react' import * as React from 'react'
type DevToolsErrorBoundaryProps = { type DevOverlayErrorBoundaryProps = {
children?: React.ReactNode children?: React.ReactNode
onError: (error: Error, componentStack: string | null) => void onError: (error: Error, componentStack: string | null) => void
isMounted?: boolean isMounted?: boolean
} }
type DevToolsErrorBoundaryState = { error: Error | null } type DevOverlayErrorBoundaryState = { error: Error | null }
export class DevToolsErrorBoundary extends React.PureComponent< export class DevOverlayErrorBoundary extends React.PureComponent<
DevToolsErrorBoundaryProps, DevOverlayErrorBoundaryProps,
DevToolsErrorBoundaryState DevOverlayErrorBoundaryState
> { > {
state = { error: null } state = { error: null }
......
...@@ -6,7 +6,7 @@ import { Base } from '../internal/styles/base' ...@@ -6,7 +6,7 @@ import { Base } from '../internal/styles/base'
import { ComponentStyles } from '../internal/styles/component-styles' import { ComponentStyles } from '../internal/styles/component-styles'
import { CssReset } from '../internal/styles/css-reset' import { CssReset } from '../internal/styles/css-reset'
import { DevToolsErrorBoundary } from './error-boundary' import { DevOverlayErrorBoundary } from './error-boundary'
import { usePagesReactDevOverlay } from '../../pages/hooks' import { usePagesReactDevOverlay } from '../../pages/hooks'
import { Colors } from '../internal/styles/colors' import { Colors } from '../internal/styles/colors'
import { ErrorOverlay } from '../internal/components/errors/error-overlay/error-overlay' import { ErrorOverlay } from '../internal/components/errors/error-overlay/error-overlay'
...@@ -20,41 +20,50 @@ interface ReactDevOverlayProps { ...@@ -20,41 +20,50 @@ interface ReactDevOverlayProps {
} }
export default function ReactDevOverlay({ children }: ReactDevOverlayProps) { export default function ReactDevOverlay({ children }: ReactDevOverlayProps) {
const { isMounted, state, onComponentError, hasRuntimeErrors } = const {
usePagesReactDevOverlay() isMounted,
state,
const [isErrorOverlayOpen, setIsErrorOverlayOpen] = useState(hasRuntimeErrors) onComponentError,
hasRuntimeErrors,
hasBuildError,
} = usePagesReactDevOverlay()
const { readyErrors } = useErrorHook({ const { readyErrors } = useErrorHook({
errors: state.errors, errors: state.errors,
isAppDir: false, isAppDir: false,
}) })
const [isErrorOverlayOpen, setIsErrorOverlayOpen] = useState(true)
return ( return (
<> <>
<DevToolsErrorBoundary isMounted={isMounted} onError={onComponentError}> <DevOverlayErrorBoundary isMounted={isMounted} onError={onComponentError}>
{children ?? null} {children ?? null}
</DevToolsErrorBoundary> </DevOverlayErrorBoundary>
<ShadowPortal> {isMounted && (
<CssReset /> <ShadowPortal>
<Base /> <CssReset />
<Colors /> <Base />
<ComponentStyles /> <Colors />
<ComponentStyles />
<DevToolsIndicator
state={state} <DevToolsIndicator
readyErrorsLength={readyErrors.length} state={state}
setIsErrorOverlayOpen={setIsErrorOverlayOpen} readyErrorsLength={readyErrors.length}
/> setIsErrorOverlayOpen={setIsErrorOverlayOpen}
/>
<ErrorOverlay
state={state} {(hasRuntimeErrors || hasBuildError) && (
readyErrors={readyErrors} <ErrorOverlay
isErrorOverlayOpen={isErrorOverlayOpen} state={state}
setIsErrorOverlayOpen={setIsErrorOverlayOpen} readyErrors={readyErrors}
/> isErrorOverlayOpen={isErrorOverlayOpen}
</ShadowPortal> setIsErrorOverlayOpen={setIsErrorOverlayOpen}
/>
)}
</ShadowPortal>
)}
</> </>
) )
} }
...@@ -33,7 +33,7 @@ export function RuntimeError({ error }: RuntimeErrorProps) { ...@@ -33,7 +33,7 @@ export function RuntimeError({ error }: RuntimeErrorProps) {
? [] ? []
: filteredFrames.slice(0, firstFirstPartyFrameIndex), : filteredFrames.slice(0, firstFirstPartyFrameIndex),
trailingCallStackFrames: filteredFrames.slice( trailingCallStackFrames: filteredFrames.slice(
firstFirstPartyFrameIndex + 1 firstFirstPartyFrameIndex < 0 ? 0 : firstFirstPartyFrameIndex
), ),
} }
}, [error.frames, isIgnoredExpanded]) }, [error.frames, isIgnoredExpanded])
......
...@@ -799,7 +799,12 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -799,7 +799,12 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
const stackFrames = ( const stackFrames = (
await Promise.all(stackFrameElements.map((f) => f.innerText())) await Promise.all(stackFrameElements.map((f) => f.innerText()))
).filter(Boolean) ).filter(Boolean)
expect(stackFrames).toEqual([]) expect(stackFrames).toEqual([
outdent`
Page
app/page.js (4:11)
`,
])
}) })
test('Call stack for server error', async () => { test('Call stack for server error', async () => {
...@@ -831,7 +836,12 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -831,7 +836,12 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
const stackFrames = ( const stackFrames = (
await Promise.all(stackFrameElements.map((f) => f.innerText())) await Promise.all(stackFrameElements.map((f) => f.innerText()))
).filter(Boolean) ).filter(Boolean)
expect(stackFrames).toEqual([]) expect(stackFrames).toEqual([
outdent`
Page
app/page.js (2:9)
`,
])
}) })
test('should hide unrelated frames in stack trace with unknown anonymous calls', async () => { test('should hide unrelated frames in stack trace with unknown anonymous calls', async () => {
...@@ -876,12 +886,20 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -876,12 +886,20 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
// TODO: investigate the column number is off by 1 between turbo and webpack // TODO: investigate the column number is off by 1 between turbo and webpack
process.env.TURBOPACK process.env.TURBOPACK
? [ ? [
outdent`
<anonymous>
app/page.js (4:13)
`,
outdent` outdent`
Page Page
app/page.js (5:6) app/page.js (5:6)
`, `,
] ]
: [ : [
outdent`
eval
app/page.js (4:13)
`,
outdent` outdent`
Page Page
app/page.js (5:5) app/page.js (5:5)
...@@ -923,8 +941,8 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => { ...@@ -923,8 +941,8 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
stackFrameElements.map((f) => f.innerText()) stackFrameElements.map((f) => f.innerText())
) )
// No following rest of displayed stack frames by default // No ignore-listed frames to be displayed by default
expect(stackFrames.length).toBe(0) expect(stackFrames.length).toBe(1)
}) })
test('Server component errors should open up in fullscreen', async () => { test('Server component errors should open up in fullscreen', async () => {
...@@ -1211,13 +1229,15 @@ export default function Home() { ...@@ -1211,13 +1229,15 @@ export default function Home() {
if (isTurbopack) { if (isTurbopack) {
// FIXME: display the sourcemapped stack frames // FIXME: display the sourcemapped stack frames
expect(stackFrames).toMatchInlineSnapshot( expect(stackFrames).toMatchInlineSnapshot(`
`"at [project]/app/page.js [app-client] (ecmascript) (app/page.js (2:1))"` "at [project]/app/utils.ts [app-client] (ecmascript) (app/utils.ts (1:7))
) at [project]/app/page.js [app-client] (ecmascript) (app/page.js (2:1))"
`)
} else { } else {
// FIXME: Webpack stack frames are not source mapped // FIXME: Webpack stack frames are not source mapped
expect(stackFrames).toMatchInlineSnapshot(` expect(stackFrames).toMatchInlineSnapshot(`
"at ./app/utils.ts () "at eval (app/utils.ts (1:7))
at ./app/utils.ts ()
at options.factory () at options.factory ()
at __webpack_require__ () at __webpack_require__ ()
at fn () at fn ()
......
...@@ -793,10 +793,19 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -793,10 +793,19 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
await session.assertHasRedbox() await session.assertHasRedbox()
const stack = await getStackFramesContent(browser) const stack = await getStackFramesContent(browser)
expect(stack).toMatchInlineSnapshot(` if (process.env.TURBOPACK) {
"at Array.map () expect(stack).toMatchInlineSnapshot(`
at Page (pages/index.js (2:13))" "at <unknown> (pages/index.js (3:11))
`) at Array.map ()
at Page (pages/index.js (2:13))"
`)
} else {
expect(stack).toMatchInlineSnapshot(`
"at eval (pages/index.js (3:11))
at Array.map ()
at Page (pages/index.js (2:13))"
`)
}
}) })
test('should collapse nodejs internal stack frames from stack trace', async () => { test('should collapse nodejs internal stack frames from stack trace', async () => {
...@@ -824,9 +833,10 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => { ...@@ -824,9 +833,10 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
await session.assertHasRedbox() await session.assertHasRedbox()
const stack = await getStackFramesContent(browser) const stack = await getStackFramesContent(browser)
expect(stack).toMatchInlineSnapshot( expect(stack).toMatchInlineSnapshot(`
`"at getServerSideProps (pages/index.js (8:3))"` "at createURL (pages/index.js (4:3))
) at getServerSideProps (pages/index.js (8:3))"
`)
await toggleCollapseCallStackFrames(browser) await toggleCollapseCallStackFrames(browser)
const stackCollapsed = await getStackFramesContent(browser) const stackCollapsed = await getStackFramesContent(browser)
......
...@@ -42,45 +42,49 @@ describe('app-dir - capture-console-error-owner-stack', () => { ...@@ -42,45 +42,49 @@ describe('app-dir - capture-console-error-owner-stack', () => {
// TODO(veil): Inconsistent cursor position for the "Page" frame // TODO(veil): Inconsistent cursor position for the "Page" frame
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
{ {
"callStacks": "button "callStacks": "onClick
<anonymous> (0:0) app/browser/event/page.js (7:17)
Page button
app/browser/event/page.js (5:5)", <anonymous> (0:0)
"count": 1, Page
"description": "trigger an console <error>", app/browser/event/page.js (5:5)",
"source": "app/browser/event/page.js (7:17) @ onClick "count": 1,
"description": "trigger an console <error>",
5 | <button "source": "app/browser/event/page.js (7:17) @ onClick
6 | onClick={() => {
> 7 | console.error('trigger an console <%s>', 'error') 5 | <button
| ^ 6 | onClick={() => {
8 | }} > 7 | console.error('trigger an console <%s>', 'error')
9 | > | ^
10 | click to error", 8 | }}
"title": "Console Error", 9 | >
} 10 | click to error",
"title": "Console Error",
}
`) `)
} else { } else {
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
{ {
"callStacks": "button "callStacks": "onClick
<anonymous> (0:0) app/browser/event/page.js (7:17)
Page button
app/browser/event/page.js (5:6)", <anonymous> (0:0)
"count": 1, Page
"description": "trigger an console <error>", app/browser/event/page.js (5:6)",
"source": "app/browser/event/page.js (7:17) @ onClick "count": 1,
"description": "trigger an console <error>",
5 | <button "source": "app/browser/event/page.js (7:17) @ onClick
6 | onClick={() => {
> 7 | console.error('trigger an console <%s>', 'error') 5 | <button
| ^ 6 | onClick={() => {
8 | }} > 7 | console.error('trigger an console <%s>', 'error')
9 | > | ^
10 | click to error", 8 | }}
"title": "Console Error", 9 | >
} 10 | click to error",
"title": "Console Error",
}
`) `)
} }
}) })
...@@ -92,21 +96,22 @@ describe('app-dir - capture-console-error-owner-stack', () => { ...@@ -92,21 +96,22 @@ describe('app-dir - capture-console-error-owner-stack', () => {
const result = await getRedboxResult(browser) const result = await getRedboxResult(browser)
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
{ {
"callStacks": "", "callStacks": "Page
"count": 1, app/browser/render/page.js (4:11)",
"description": "trigger an console.error in render", "count": 1,
"source": "app/browser/render/page.js (4:11) @ Page "description": "trigger an console.error in render",
"source": "app/browser/render/page.js (4:11) @ Page
2 |
3 | export default function Page() { 2 |
> 4 | console.error('trigger an console.error in render') 3 | export default function Page() {
| ^ > 4 | console.error('trigger an console.error in render')
5 | return <p>render</p> | ^
6 | } 5 | return <p>render</p>
7 |", 6 | }
"title": "Console Error", 7 |",
} "title": "Console Error",
}
`) `)
}) })
...@@ -117,21 +122,22 @@ describe('app-dir - capture-console-error-owner-stack', () => { ...@@ -117,21 +122,22 @@ describe('app-dir - capture-console-error-owner-stack', () => {
const result = await getRedboxResult(browser) const result = await getRedboxResult(browser)
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
{ {
"callStacks": "", "callStacks": "Page
"count": 1, app/browser/render/page.js (4:11)",
"description": "trigger an console.error in render", "count": 1,
"source": "app/browser/render/page.js (4:11) @ Page "description": "trigger an console.error in render",
"source": "app/browser/render/page.js (4:11) @ Page
2 |
3 | export default function Page() { 2 |
> 4 | console.error('trigger an console.error in render') 3 | export default function Page() {
| ^ > 4 | console.error('trigger an console.error in render')
5 | return <p>render</p> | ^
6 | } 5 | return <p>render</p>
7 |", 6 | }
"title": "Console Error", 7 |",
} "title": "Console Error",
}
`) `)
}) })
...@@ -142,21 +148,22 @@ describe('app-dir - capture-console-error-owner-stack', () => { ...@@ -142,21 +148,22 @@ describe('app-dir - capture-console-error-owner-stack', () => {
const result = await getRedboxResult(browser) const result = await getRedboxResult(browser)
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
{ {
"callStacks": "", "callStacks": "Page
"count": 1, app/ssr/page.js (4:11)",
"description": "ssr console error:client", "count": 1,
"source": "app/ssr/page.js (4:11) @ Page "description": "ssr console error:client",
"source": "app/ssr/page.js (4:11) @ Page
2 |
3 | export default function Page() { 2 |
> 4 | console.error( 3 | export default function Page() {
| ^ > 4 | console.error(
5 | 'ssr console error:' + (typeof window === 'undefined' ? 'server' : 'client') | ^
6 | ) 5 | 'ssr console error:' + (typeof window === 'undefined' ? 'server' : 'client')
7 | return <p>ssr</p>", 6 | )
"title": "Console Error", 7 | return <p>ssr</p>",
} "title": "Console Error",
}
`) `)
}) })
...@@ -168,21 +175,22 @@ describe('app-dir - capture-console-error-owner-stack', () => { ...@@ -168,21 +175,22 @@ describe('app-dir - capture-console-error-owner-stack', () => {
const result = await getRedboxResult(browser) const result = await getRedboxResult(browser)
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
{ {
"callStacks": "", "callStacks": "Page
"count": 1, app/ssr-error-instance/page.js (4:17)",
"description": "Error: page error", "count": 1,
"source": "app/ssr-error-instance/page.js (4:17) @ Page "description": "Error: page error",
"source": "app/ssr-error-instance/page.js (4:17) @ Page
2 |
3 | export default function Page() { 2 |
> 4 | console.error(new Error('page error')) 3 | export default function Page() {
| ^ > 4 | console.error(new Error('page error'))
5 | return <p>ssr</p> | ^
6 | } 5 | return <p>ssr</p>
7 |", 6 | }
"title": "Console Error", 7 |",
} "title": "Console Error",
}
`) `)
}) })
...@@ -195,43 +203,47 @@ describe('app-dir - capture-console-error-owner-stack', () => { ...@@ -195,43 +203,47 @@ describe('app-dir - capture-console-error-owner-stack', () => {
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
{ {
"callStacks": "JSON.parse "callStacks": "Page
<anonymous> (0:0) app/rsc/page.js (2:17)
Page JSON.parse
<anonymous> (0:0)", <anonymous> (0:0)
"count": 1, Page
"description": "[ Server ] Error: boom", <anonymous> (0:0)",
"source": "app/rsc/page.js (2:17) @ Page "count": 1,
"description": "[ Server ] Error: boom",
1 | export default function Page() { "source": "app/rsc/page.js (2:17) @ Page
> 2 | console.error(new Error('boom'))
| ^ 1 | export default function Page() {
3 | return <p>rsc</p> > 2 | console.error(new Error('boom'))
4 | } | ^
5 |", 3 | return <p>rsc</p>
"title": "Console Error", 4 | }
} 5 |",
"title": "Console Error",
}
`) `)
} else { } else {
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
{ {
"callStacks": "JSON.parse "callStacks": "Page
<anonymous> (0:0) app/rsc/page.js (2:17)
Page JSON.parse
<anonymous> (0:0)", <anonymous> (0:0)
"count": 1, Page
"description": "[ Server ] Error: boom", <anonymous> (0:0)",
"source": "app/rsc/page.js (2:17) @ Page "count": 1,
"description": "[ Server ] Error: boom",
1 | export default function Page() { "source": "app/rsc/page.js (2:17) @ Page
> 2 | console.error(new Error('boom'))
| ^ 1 | export default function Page() {
3 | return <p>rsc</p> > 2 | console.error(new Error('boom'))
4 | } | ^
5 |", 3 | return <p>rsc</p>
"title": "Console Error", 4 | }
} 5 |",
"title": "Console Error",
}
`) `)
} }
}) })
......
...@@ -51,26 +51,28 @@ describe('app-dir - capture-console-error', () => { ...@@ -51,26 +51,28 @@ describe('app-dir - capture-console-error', () => {
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
{ {
"callStacks": "", "callStacks": "onClick
"count": 1, app/browser/event/page.js (7:17)",
"description": "trigger an console <error>", "count": 1,
"source": "app/browser/event/page.js (7:17) @ onClick "description": "trigger an console <error>",
"source": "app/browser/event/page.js (7:17) @ onClick
5 | <button
6 | onClick={() => { 5 | <button
> 7 | console.error('trigger an console <%s>', 'error') 6 | onClick={() => {
| ^ > 7 | console.error('trigger an console <%s>', 'error')
8 | }} | ^
9 | > 8 | }}
10 | click to error", 9 | >
"title": "Console Error", 10 | click to error",
} "title": "Console Error",
}
`) `)
} else { } else {
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
{ {
"callStacks": "", "callStacks": "onClick
app/browser/event/page.js (7:17)",
"count": 1, "count": 1,
"description": "trigger an console <error>", "description": "trigger an console <error>",
"source": "app/browser/event/page.js (7:17) @ onClick "source": "app/browser/event/page.js (7:17) @ onClick
...@@ -97,26 +99,28 @@ describe('app-dir - capture-console-error', () => { ...@@ -97,26 +99,28 @@ describe('app-dir - capture-console-error', () => {
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
{ {
"callStacks": "", "callStacks": "Page
"count": 2, app/browser/render/page.js (4:11)",
"description": "trigger an console.error in render", "count": 2,
"source": "app/browser/render/page.js (4:11) @ Page "description": "trigger an console.error in render",
"source": "app/browser/render/page.js (4:11) @ Page
2 |
3 | export default function Page() { 2 |
> 4 | console.error('trigger an console.error in render') 3 | export default function Page() {
| ^ > 4 | console.error('trigger an console.error in render')
5 | return <p>render</p> | ^
6 | } 5 | return <p>render</p>
7 |", 6 | }
"title": "Console Error", 7 |",
} "title": "Console Error",
}
`) `)
} else { } else {
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
{ {
"callStacks": "", "callStacks": "Page
app/browser/render/page.js (4:11)",
"count": 2, "count": 2,
"description": "trigger an console.error in render", "description": "trigger an console.error in render",
"source": "app/browser/render/page.js (4:11) @ Page "source": "app/browser/render/page.js (4:11) @ Page
...@@ -143,26 +147,28 @@ describe('app-dir - capture-console-error', () => { ...@@ -143,26 +147,28 @@ describe('app-dir - capture-console-error', () => {
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
{ {
"callStacks": "", "callStacks": "Page
"count": 2, app/browser/render/page.js (4:11)",
"description": "trigger an console.error in render", "count": 2,
"source": "app/browser/render/page.js (4:11) @ Page "description": "trigger an console.error in render",
"source": "app/browser/render/page.js (4:11) @ Page
2 |
3 | export default function Page() { 2 |
> 4 | console.error('trigger an console.error in render') 3 | export default function Page() {
| ^ > 4 | console.error('trigger an console.error in render')
5 | return <p>render</p> | ^
6 | } 5 | return <p>render</p>
7 |", 6 | }
"title": "Console Error", 7 |",
} "title": "Console Error",
}
`) `)
} else { } else {
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
{ {
"callStacks": "", "callStacks": "Page
app/browser/render/page.js (4:11)",
"count": 2, "count": 2,
"description": "trigger an console.error in render", "description": "trigger an console.error in render",
"source": "app/browser/render/page.js (4:11) @ Page "source": "app/browser/render/page.js (4:11) @ Page
...@@ -189,26 +195,28 @@ describe('app-dir - capture-console-error', () => { ...@@ -189,26 +195,28 @@ describe('app-dir - capture-console-error', () => {
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
{ {
"callStacks": "", "callStacks": "Page
"count": 2, app/ssr/page.js (4:11)",
"description": "ssr console error:client", "count": 2,
"source": "app/ssr/page.js (4:11) @ Page "description": "ssr console error:client",
"source": "app/ssr/page.js (4:11) @ Page
2 |
3 | export default function Page() { 2 |
> 4 | console.error( 3 | export default function Page() {
| ^ > 4 | console.error(
5 | 'ssr console error:' + (typeof window === 'undefined' ? 'server' : 'client') | ^
6 | ) 5 | 'ssr console error:' + (typeof window === 'undefined' ? 'server' : 'client')
7 | return <p>ssr</p>", 6 | )
"title": "Console Error", 7 | return <p>ssr</p>",
} "title": "Console Error",
}
`) `)
} else { } else {
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
{ {
"callStacks": "", "callStacks": "Page
app/ssr/page.js (4:11)",
"count": 2, "count": 2,
"description": "ssr console error:client", "description": "ssr console error:client",
"source": "app/ssr/page.js (4:11) @ Page "source": "app/ssr/page.js (4:11) @ Page
...@@ -235,39 +243,41 @@ describe('app-dir - capture-console-error', () => { ...@@ -235,39 +243,41 @@ describe('app-dir - capture-console-error', () => {
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
{ {
"callStacks": "", "callStacks": "Page
"count": 2, app/ssr-error-instance/page.js (4:17)",
"description": "Error: page error", "count": 2,
"source": "app/ssr-error-instance/page.js (4:17) @ Page "description": "Error: page error",
"source": "app/ssr-error-instance/page.js (4:17) @ Page
2 |
3 | export default function Page() { 2 |
> 4 | console.error(new Error('page error')) 3 | export default function Page() {
| ^ > 4 | console.error(new Error('page error'))
5 | return <p>ssr</p> | ^
6 | } 5 | return <p>ssr</p>
7 |", 6 | }
"title": "Console Error", 7 |",
} "title": "Console Error",
}
`) `)
} else { } else {
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
{ {
"callStacks": "", "callStacks": "Page
"count": 2, app/ssr-error-instance/page.js (4:17)",
"description": "Error: page error", "count": 2,
"source": "app/ssr-error-instance/page.js (4:17) @ Page "description": "Error: page error",
"source": "app/ssr-error-instance/page.js (4:17) @ Page
2 |
3 | export default function Page() { 2 |
> 4 | console.error(new Error('page error')) 3 | export default function Page() {
| ^ > 4 | console.error(new Error('page error'))
5 | return <p>ssr</p> | ^
6 | } 5 | return <p>ssr</p>
7 |", 6 | }
"title": "Console Error", 7 |",
} "title": "Console Error",
}
`) `)
} }
}) })
...@@ -281,39 +291,43 @@ describe('app-dir - capture-console-error', () => { ...@@ -281,39 +291,43 @@ describe('app-dir - capture-console-error', () => {
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
{ {
"callStacks": "JSON.parse "callStacks": "Page
<anonymous> (0:0)", app/rsc/page.js (2:17)
"count": 1, JSON.parse
"description": "[ Server ] Error: boom", <anonymous> (0:0)",
"source": "app/rsc/page.js (2:17) @ Page "count": 1,
"description": "[ Server ] Error: boom",
1 | export default function Page() { "source": "app/rsc/page.js (2:17) @ Page
> 2 | console.error(new Error('boom'))
| ^ 1 | export default function Page() {
3 | return <p>rsc</p> > 2 | console.error(new Error('boom'))
4 | } | ^
5 |", 3 | return <p>rsc</p>
"title": "Console Error", 4 | }
} 5 |",
"title": "Console Error",
}
`) `)
} else { } else {
expect(result).toMatchInlineSnapshot(` expect(result).toMatchInlineSnapshot(`
{ {
"callStacks": "JSON.parse "callStacks": "Page
<anonymous> (0:0)", app/rsc/page.js (2:17)
"count": 1, JSON.parse
"description": "[ Server ] Error: boom", <anonymous> (0:0)",
"source": "app/rsc/page.js (2:17) @ Page "count": 1,
"description": "[ Server ] Error: boom",
1 | export default function Page() { "source": "app/rsc/page.js (2:17) @ Page
> 2 | console.error(new Error('boom'))
| ^ 1 | export default function Page() {
3 | return <p>rsc</p> > 2 | console.error(new Error('boom'))
4 | } | ^
5 |", 3 | return <p>rsc</p>
"title": "Console Error", 4 | }
} 5 |",
"title": "Console Error",
}
`) `)
} }
}) })
......
...@@ -35,7 +35,10 @@ describe('app dir - dynamic error trace', () => { ...@@ -35,7 +35,10 @@ describe('app dir - dynamic error trace', () => {
// TODO: Show useful stack // TODO: Show useful stack
const normalizedStack = normalizeStackTrace(stackFramesContent) const normalizedStack = normalizeStackTrace(stackFramesContent)
expect(normalizedStack).toMatchInlineSnapshot(`""`) expect(normalizedStack).toMatchInlineSnapshot(`
"Foo
app/lib.js"
`)
const codeframe = await getRedboxSource(browser) const codeframe = await getRedboxSource(browser)
expect(codeframe).toEqual( expect(codeframe).toEqual(
......
...@@ -25,7 +25,9 @@ const isOwnerStackEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true' ...@@ -25,7 +25,9 @@ const isOwnerStackEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true'
const stackFramesContent = await getStackFramesContent(browser) const stackFramesContent = await getStackFramesContent(browser)
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(stackFramesContent).toMatchInlineSnapshot(`""`) expect(stackFramesContent).toMatchInlineSnapshot(
`"at BrowserOnly (app/browser/browser-only.js (8:7))"`
)
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"app/browser/browser-only.js (8:7) @ BrowserOnly "app/browser/browser-only.js (8:7) @ BrowserOnly
...@@ -38,7 +40,9 @@ const isOwnerStackEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true' ...@@ -38,7 +40,9 @@ const isOwnerStackEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true'
11 | }" 11 | }"
`) `)
} else { } else {
expect(stackFramesContent).toMatchInlineSnapshot(`""`) expect(stackFramesContent).toMatchInlineSnapshot(
`"at BrowserOnly (app/browser/browser-only.js (8:8))"`
)
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"app/browser/browser-only.js (8:8) @ BrowserOnly "app/browser/browser-only.js (8:8) @ BrowserOnly
...@@ -61,7 +65,9 @@ const isOwnerStackEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true' ...@@ -61,7 +65,9 @@ const isOwnerStackEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true'
const source = await getRedboxSource(browser) const source = await getRedboxSource(browser)
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(stackFramesContent).toMatchInlineSnapshot(`""`) expect(stackFramesContent).toMatchInlineSnapshot(
`"at Inner (app/rsc/page.js (5:11))"`
)
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"app/rsc/page.js (5:11) @ Inner "app/rsc/page.js (5:11) @ Inner
...@@ -74,7 +80,9 @@ const isOwnerStackEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true' ...@@ -74,7 +80,9 @@ const isOwnerStackEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true'
8 | export default function Page() {" 8 | export default function Page() {"
`) `)
} else { } else {
expect(stackFramesContent).toMatchInlineSnapshot(`""`) expect(stackFramesContent).toMatchInlineSnapshot(
`"at Inner (app/rsc/page.js (5:11))"`
)
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"app/rsc/page.js (5:11) @ Inner "app/rsc/page.js (5:11) @ Inner
...@@ -97,7 +105,9 @@ const isOwnerStackEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true' ...@@ -97,7 +105,9 @@ const isOwnerStackEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true'
const stackFramesContent = await getStackFramesContent(browser) const stackFramesContent = await getStackFramesContent(browser)
const source = await getRedboxSource(browser) const source = await getRedboxSource(browser)
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(stackFramesContent).toMatchInlineSnapshot(`""`) expect(stackFramesContent).toMatchInlineSnapshot(
`"at Inner (app/ssr/page.js (7:10))"`
)
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"app/ssr/page.js (7:10) @ Inner "app/ssr/page.js (7:10) @ Inner
...@@ -110,7 +120,9 @@ const isOwnerStackEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true' ...@@ -110,7 +120,9 @@ const isOwnerStackEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true'
10 | export default function Page() {" 10 | export default function Page() {"
`) `)
} else { } else {
expect(stackFramesContent).toMatchInlineSnapshot(`""`) expect(stackFramesContent).toMatchInlineSnapshot(
`"at Inner (app/ssr/page.js (7:11))"`
)
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"app/ssr/page.js (7:11) @ Inner "app/ssr/page.js (7:11) @ Inner
......
...@@ -26,8 +26,9 @@ const isOwnerStackEnabled = ...@@ -26,8 +26,9 @@ const isOwnerStackEnabled =
const stackFramesContent = await getStackFramesContent(browser) const stackFramesContent = await getStackFramesContent(browser)
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(stackFramesContent).toMatchInlineSnapshot(` expect(stackFramesContent).toMatchInlineSnapshot(`
"at Inner (app/browser/page.js (11:10)) "at BrowserOnly (app/browser/browser-only.js (8:7))
at Page (app/browser/page.js (15:10))" at Inner (app/browser/page.js (11:10))
at Page (app/browser/page.js (15:10))"
`) `)
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"app/browser/browser-only.js (8:7) @ BrowserOnly "app/browser/browser-only.js (8:7) @ BrowserOnly
...@@ -42,7 +43,8 @@ const isOwnerStackEnabled = ...@@ -42,7 +43,8 @@ const isOwnerStackEnabled =
`) `)
} else { } else {
expect(stackFramesContent).toMatchInlineSnapshot(` expect(stackFramesContent).toMatchInlineSnapshot(`
"at Inner (app/browser/page.js (11:11)) "at BrowserOnly (app/browser/browser-only.js (8:8))
at Inner (app/browser/page.js (11:11))
at Page (app/browser/page.js (15:11))" at Page (app/browser/page.js (15:11))"
`) `)
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
...@@ -67,9 +69,10 @@ const isOwnerStackEnabled = ...@@ -67,9 +69,10 @@ const isOwnerStackEnabled =
const source = await getRedboxSource(browser) const source = await getRedboxSource(browser)
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(stackFramesContent).toMatchInlineSnapshot( expect(stackFramesContent).toMatchInlineSnapshot(`
`"at Page (app/rsc/page.js (11:8))"` "at Inner (app/rsc/page.js (5:11))
) at Page (app/rsc/page.js (11:8))"
`)
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"app/rsc/page.js (5:11) @ Inner "app/rsc/page.js (5:11) @ Inner
...@@ -82,9 +85,10 @@ const isOwnerStackEnabled = ...@@ -82,9 +85,10 @@ const isOwnerStackEnabled =
8 | export default function Page() {" 8 | export default function Page() {"
`) `)
} else { } else {
expect(stackFramesContent).toMatchInlineSnapshot( expect(stackFramesContent).toMatchInlineSnapshot(`
`"at Page (app/rsc/page.js (11:8))"` "at Inner (app/rsc/page.js (5:11))
) at Page (app/rsc/page.js (11:8))"
`)
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"app/rsc/page.js (5:11) @ Inner "app/rsc/page.js (5:11) @ Inner
...@@ -107,9 +111,10 @@ const isOwnerStackEnabled = ...@@ -107,9 +111,10 @@ const isOwnerStackEnabled =
const stackFramesContent = await getStackFramesContent(browser) const stackFramesContent = await getStackFramesContent(browser)
const source = await getRedboxSource(browser) const source = await getRedboxSource(browser)
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(stackFramesContent).toMatchInlineSnapshot( expect(stackFramesContent).toMatchInlineSnapshot(`
`"at Page (app/ssr/page.js (13:7))"` "at Inner (app/ssr/page.js (7:10))
) at Page (app/ssr/page.js (13:7))"
`)
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"app/ssr/page.js (7:10) @ Inner "app/ssr/page.js (7:10) @ Inner
...@@ -122,9 +127,10 @@ const isOwnerStackEnabled = ...@@ -122,9 +127,10 @@ const isOwnerStackEnabled =
10 | export default function Page() {" 10 | export default function Page() {"
`) `)
} else { } else {
expect(stackFramesContent).toMatchInlineSnapshot( expect(stackFramesContent).toMatchInlineSnapshot(`
`"at Page (app/ssr/page.js (13:8))"` "at Inner (app/ssr/page.js (7:11))
) at Page (app/ssr/page.js (13:8))"
`)
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"app/ssr/page.js (7:11) @ Inner "app/ssr/page.js (7:11) @ Inner
......
...@@ -24,8 +24,9 @@ const isOwnerStackEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true' ...@@ -24,8 +24,9 @@ const isOwnerStackEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true'
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(stackFramesContent).toMatchInlineSnapshot(` expect(stackFramesContent).toMatchInlineSnapshot(`
"at span () "at span (<anonymous> (0:0))
at Page (app/rsc/page.tsx (6:13))" at <anonymous> (app/rsc/page.tsx (7:10))
at Page (app/rsc/page.tsx (6:13))"
`) `)
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"app/rsc/page.tsx (7:10) @ <anonymous> "app/rsc/page.tsx (7:10) @ <anonymous>
...@@ -40,8 +41,9 @@ const isOwnerStackEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true' ...@@ -40,8 +41,9 @@ const isOwnerStackEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true'
`) `)
} else { } else {
expect(stackFramesContent).toMatchInlineSnapshot(` expect(stackFramesContent).toMatchInlineSnapshot(`
"at span () "at span (<anonymous> (0:0))
at Page (app/rsc/page.tsx (6:13))" at eval (app/rsc/page.tsx (7:10))
at Page (app/rsc/page.tsx (6:13))"
`) `)
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"app/rsc/page.tsx (7:10) @ eval "app/rsc/page.tsx (7:10) @ eval
...@@ -65,9 +67,10 @@ const isOwnerStackEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true' ...@@ -65,9 +67,10 @@ const isOwnerStackEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true'
const source = await getRedboxSource(browser) const source = await getRedboxSource(browser)
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(stackFramesContent).toMatchInlineSnapshot(` expect(stackFramesContent).toMatchInlineSnapshot(`
"at p () "at p (<anonymous> (0:0))
at Array.map () at <unknown> (app/ssr/page.tsx (9:9))
at Page (app/ssr/page.tsx (8:13))" at Array.map (<anonymous> (0:0))
at Page (app/ssr/page.tsx (8:13))"
`) `)
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"app/ssr/page.tsx (9:9) @ <unknown> "app/ssr/page.tsx (9:9) @ <unknown>
...@@ -82,9 +85,10 @@ const isOwnerStackEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true' ...@@ -82,9 +85,10 @@ const isOwnerStackEnabled = process.env.__NEXT_EXPERIMENTAL_PPR === 'true'
`) `)
} else { } else {
expect(stackFramesContent).toMatchInlineSnapshot(` expect(stackFramesContent).toMatchInlineSnapshot(`
"at p () "at p (<anonymous> (0:0))
at Array.map () at eval (app/ssr/page.tsx (9:10))
at Page (app/ssr/page.tsx (8:13))" at Array.map (<anonymous> (0:0))
at Page (app/ssr/page.tsx (8:13))"
`) `)
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"app/ssr/page.tsx (9:10) @ eval "app/ssr/page.tsx (9:10) @ eval
......
...@@ -61,7 +61,9 @@ async function getStackFramesContent(browser) { ...@@ -61,7 +61,9 @@ async function getStackFramesContent(browser) {
const source = await getRedboxSource(browser) const source = await getRedboxSource(browser)
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(stackFramesContent).toMatchInlineSnapshot(`""`) expect(stackFramesContent).toMatchInlineSnapshot(
`"at Page (app/rsc/page.tsx (5:6))"`
)
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"app/rsc/page.tsx (5:6) @ Page "app/rsc/page.tsx (5:6) @ Page
...@@ -74,7 +76,9 @@ async function getStackFramesContent(browser) { ...@@ -74,7 +76,9 @@ async function getStackFramesContent(browser) {
8 | ))}" 8 | ))}"
`) `)
} else { } else {
expect(stackFramesContent).toMatchInlineSnapshot(`""`) expect(stackFramesContent).toMatchInlineSnapshot(
`"at Page (app/rsc/page.tsx (5:6))"`
)
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"app/rsc/page.tsx (5:6) @ Page "app/rsc/page.tsx (5:6) @ Page
...@@ -96,7 +100,9 @@ async function getStackFramesContent(browser) { ...@@ -96,7 +100,9 @@ async function getStackFramesContent(browser) {
const stackFramesContent = await getStackFramesContent(browser) const stackFramesContent = await getStackFramesContent(browser)
const source = await getRedboxSource(browser) const source = await getRedboxSource(browser)
if (process.env.TURBOPACK) { if (process.env.TURBOPACK) {
expect(stackFramesContent).toMatchInlineSnapshot(`""`) expect(stackFramesContent).toMatchInlineSnapshot(
`"at Page (app/ssr/page.tsx (7:5))"`
)
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"app/ssr/page.tsx (7:5) @ Page "app/ssr/page.tsx (7:5) @ Page
...@@ -109,7 +115,9 @@ async function getStackFramesContent(browser) { ...@@ -109,7 +115,9 @@ async function getStackFramesContent(browser) {
10 | ))}" 10 | ))}"
`) `)
} else { } else {
expect(stackFramesContent).toMatchInlineSnapshot(`""`) expect(stackFramesContent).toMatchInlineSnapshot(
`"at Page (app/ssr/page.tsx (7:6))"`
)
expect(source).toMatchInlineSnapshot(` expect(source).toMatchInlineSnapshot(`
"app/ssr/page.tsx (7:6) @ Page "app/ssr/page.tsx (7:6) @ Page
......
...@@ -49,6 +49,9 @@ describe('app-dir - owner-stack', () => { ...@@ -49,6 +49,9 @@ describe('app-dir - owner-stack', () => {
files: __dirname, files: __dirname,
}) })
const isNewDevOverlay =
process.env.__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY === 'true'
it('should log stitched error for browser uncaught errors', async () => { it('should log stitched error for browser uncaught errors', async () => {
const browser = await next.browser('/browser/uncaught') const browser = await next.browser('/browser/uncaught')
...@@ -56,53 +59,97 @@ describe('app-dir - owner-stack', () => { ...@@ -56,53 +59,97 @@ describe('app-dir - owner-stack', () => {
const stackFramesContent = await getStackFramesContent(browser) const stackFramesContent = await getStackFramesContent(browser)
expect(stackFramesContent).toMatchInlineSnapshot(` expect(stackFramesContent).toMatchInlineSnapshot(`
"at useErrorHook (app/browser/uncaught/page.js (10:3)) "at useThrowError (app/browser/uncaught/page.js (5:11))
at Page (app/browser/uncaught/page.js (14:3))" at useErrorHook (app/browser/uncaught/page.js (10:3))
`) at Page (app/browser/uncaught/page.js (14:3))"
`)
const logs = await browser.log() const logs = await browser.log()
const errorLog = logs.find((log) => { const errorLog = logs.find((log) => {
return log.message.includes('Error: browser error') return log.message.includes('Error: browser error')
}).message }).message
if (process.env.TURBOPACK) { // TODO(jiwon): Remove this once we have a new dev overlay at stable.
expect(normalizeStackTrace(errorLog)).toMatchInlineSnapshot(` if (isNewDevOverlay) {
"%o if (process.env.TURBOPACK) {
%s Error: browser error expect(normalizeStackTrace(errorLog)).toMatchInlineSnapshot(`
at useThrowError "%o
at useErrorHook %s Error: browser error
at Page at useThrowError
at react-stack-bottom-frame at useErrorHook
at renderWithHooks at Page
at updateFunctionComponent at react-stack-bottom-frame
at beginWork at renderWithHooks
at runWithFiberInDEV at updateFunctionComponent
at performUnitOfWork at beginWork
at workLoopSync at runWithFiberInDEV
at renderRootSync at performUnitOfWork
at performWorkOnRoot at workLoopSync
at performWorkOnRootViaSchedulerTask at renderRootSync
at MessagePort.performWorkUntilDeadline The above error occurred in the <Page> component. It was handled by the <ReactDevOverlay> error boundary." at performWorkOnRoot
at performWorkOnRootViaSchedulerTask
at MessagePort.performWorkUntilDeadline The above error occurred in the <Page> component. It was handled by the <DevOverlayErrorBoundary> error boundary."
`)
} else {
expect(normalizeStackTrace(errorLog)).toMatchInlineSnapshot(`
"%o
%s Error: browser error
at useThrowError
at useErrorHook
at Page
at react-stack-bottom-frame
at renderWithHooks
at updateFunctionComponent
at beginWork
at runWithFiberInDEV
at performUnitOfWork
at workLoopSync
at renderRootSync
at performWorkOnRoot
at performWorkOnRootViaSchedulerTask
at MessagePort.performWorkUntilDeadline The above error occurred in the <Page> component. It was handled by the <DevOverlayErrorBoundary> error boundary."
`) `)
}
} else { } else {
expect(normalizeStackTrace(errorLog)).toMatchInlineSnapshot(` if (process.env.TURBOPACK) {
"%o expect(normalizeStackTrace(errorLog)).toMatchInlineSnapshot(`
%s Error: browser error "%o
at useThrowError %s Error: browser error
at useErrorHook at useThrowError
at Page at useErrorHook
at react-stack-bottom-frame at Page
at renderWithHooks at react-stack-bottom-frame
at updateFunctionComponent at renderWithHooks
at beginWork at updateFunctionComponent
at runWithFiberInDEV at beginWork
at performUnitOfWork at runWithFiberInDEV
at workLoopSync at performUnitOfWork
at renderRootSync at workLoopSync
at performWorkOnRoot at renderRootSync
at performWorkOnRootViaSchedulerTask at performWorkOnRoot
at MessagePort.performWorkUntilDeadline The above error occurred in the <Page> component. It was handled by the <ReactDevOverlay> error boundary." at performWorkOnRootViaSchedulerTask
at MessagePort.performWorkUntilDeadline The above error occurred in the <Page> component. It was handled by the <ReactDevOverlay> error boundary."
`)
} else {
expect(normalizeStackTrace(errorLog)).toMatchInlineSnapshot(`
"%o
%s Error: browser error
at useThrowError
at useErrorHook
at Page
at react-stack-bottom-frame
at renderWithHooks
at updateFunctionComponent
at beginWork
at runWithFiberInDEV
at performUnitOfWork
at workLoopSync
at renderRootSync
at performWorkOnRoot
at performWorkOnRootViaSchedulerTask
at MessagePort.performWorkUntilDeadline The above error occurred in the <Page> component. It was handled by the <ReactDevOverlay> error boundary."
`) `)
}
} }
}) })
...@@ -121,18 +168,20 @@ describe('app-dir - owner-stack', () => { ...@@ -121,18 +168,20 @@ describe('app-dir - owner-stack', () => {
const stackFramesContent = await getStackFramesContent(browser) const stackFramesContent = await getStackFramesContent(browser)
if (isTurbopack) { if (isTurbopack) {
expect(stackFramesContent).toMatchInlineSnapshot(` expect(stackFramesContent).toMatchInlineSnapshot(`
"at useErrorHook (app/browser/caught/page.js (39:3)) "at useThrowError (app/browser/caught/page.js (34:11))
at useErrorHook (app/browser/caught/page.js (39:3))
at Thrower (app/browser/caught/page.js (29:3)) at Thrower (app/browser/caught/page.js (29:3))
at Inner (app/browser/caught/page.js (23:7)) at Inner (app/browser/caught/page.js (23:7))
at Page (app/browser/caught/page.js (43:10))" at Page (app/browser/caught/page.js (43:10))"
`) `)
} else { } else {
expect(stackFramesContent).toMatchInlineSnapshot(` expect(stackFramesContent).toMatchInlineSnapshot(`
"at useErrorHook (app/browser/caught/page.js (39:3)) "at useThrowError (app/browser/caught/page.js (34:11))
at Thrower (app/browser/caught/page.js (29:3)) at useErrorHook (app/browser/caught/page.js (39:3))
at Inner (app/browser/caught/page.js (23:8)) at Thrower (app/browser/caught/page.js (29:3))
at Page (app/browser/caught/page.js (43:11))" at Inner (app/browser/caught/page.js (23:8))
`) at Page (app/browser/caught/page.js (43:11))"
`)
} }
expect(normalizeStackTrace(errorLog)).toMatchInlineSnapshot(` expect(normalizeStackTrace(errorLog)).toMatchInlineSnapshot(`
...@@ -162,33 +211,55 @@ describe('app-dir - owner-stack', () => { ...@@ -162,33 +211,55 @@ describe('app-dir - owner-stack', () => {
const stackFramesContent = await getStackFramesContent(browser) const stackFramesContent = await getStackFramesContent(browser)
expect(stackFramesContent).toMatchInlineSnapshot(` expect(stackFramesContent).toMatchInlineSnapshot(`
"at useErrorHook (app/ssr/page.js (8:3)) "at useThrowError (app/ssr/page.js (4:9))
at Page (app/ssr/page.js (12:3))" at useErrorHook (app/ssr/page.js (8:3))
`) at Page (app/ssr/page.js (12:3))"
`)
const logs = await browser.log() const logs = await browser.log()
const errorLog = logs.find((log) => { const errorLog = logs.find((log) => {
return log.message.includes('Error: ssr error') return log.message.includes('Error: ssr error')
}).message }).message
expect(normalizeStackTrace(errorLog)).toMatchInlineSnapshot(` if (isNewDevOverlay) {
"%o expect(normalizeStackTrace(errorLog)).toMatchInlineSnapshot(`
%s Error: ssr error "%o
at useThrowError %s Error: ssr error
at useErrorHook at useThrowError
at Page at useErrorHook
at react-stack-bottom-frame at Page
at renderWithHooks at react-stack-bottom-frame
at updateFunctionComponent at renderWithHooks
at beginWork at updateFunctionComponent
at runWithFiberInDEV at beginWork
at performUnitOfWork at runWithFiberInDEV
at workLoopSync at performUnitOfWork
at renderRootSync at workLoopSync
at performWorkOnRoot at renderRootSync
at performWorkOnRootViaSchedulerTask at performWorkOnRoot
at MessagePort.performWorkUntilDeadline The above error occurred in the <Page> component. It was handled by the <ReactDevOverlay> error boundary." at performWorkOnRootViaSchedulerTask
at MessagePort.performWorkUntilDeadline The above error occurred in the <Page> component. It was handled by the <DevOverlayErrorBoundary> error boundary."
`)
} else {
expect(normalizeStackTrace(errorLog)).toMatchInlineSnapshot(`
"%o
%s Error: ssr error
at useThrowError
at useErrorHook
at Page
at react-stack-bottom-frame
at renderWithHooks
at updateFunctionComponent
at beginWork
at runWithFiberInDEV
at performUnitOfWork
at workLoopSync
at renderRootSync
at performWorkOnRoot
at performWorkOnRootViaSchedulerTask
at MessagePort.performWorkUntilDeadline The above error occurred in the <Page> component. It was handled by the <ReactDevOverlay> error boundary."
`) `)
}
}) })
it('should capture unhandled promise rejections', async () => { it('should capture unhandled promise rejections', async () => {
......
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
import { retry } from 'next-test-utils' import { getRouteTypeFromDevToolsIndicator, retry } from 'next-test-utils'
import { BrowserInterface } from 'next-webdriver' import { BrowserInterface } from 'next-webdriver'
describe('prerender indicator', () => { describe('prerender indicator', () => {
...@@ -7,7 +7,16 @@ describe('prerender indicator', () => { ...@@ -7,7 +7,16 @@ describe('prerender indicator', () => {
files: __dirname, files: __dirname,
}) })
const isNewDevOverlay =
process.env.__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY === 'true'
async function hasStaticIndicator(browser: BrowserInterface) { async function hasStaticIndicator(browser: BrowserInterface) {
if (isNewDevOverlay) {
const routeType = await getRouteTypeFromDevToolsIndicator(browser)
console.log({ routeType })
return routeType === 'Static'
}
const staticIndicatorPresent = await browser.eval(() => const staticIndicatorPresent = await browser.eval(() =>
Boolean( Boolean(
document document
...@@ -63,28 +72,31 @@ describe('prerender indicator', () => { ...@@ -63,28 +72,31 @@ describe('prerender indicator', () => {
} }
}) })
it('should not show the indicator if disabled in next.config', async () => { // TODO(jiwon): The new UI will always show the route type.
await next.stop() if (!isNewDevOverlay) {
it.skip('should not show the indicator if disabled in next.config', async () => {
await next.patchFile( await next.stop()
'next.config.js',
` await next.patchFile(
module.exports = { 'next.config.js',
devIndicators: { `
appIsrStatus: false module.exports = {
devIndicators: {
appIsrStatus: false
}
} }
} `
` )
)
try { try {
await next.start() await next.start()
const browser = await next.browser('/') const browser = await next.browser('/')
expect(await hasStaticIndicator(browser)).toBe(false) expect(await hasStaticIndicator(browser)).toBe(false)
} finally { } finally {
await next.deleteFile('app/page.tsx') await next.deleteFile('app/page.tsx')
} }
}) })
}
it('should not have static indicator when using force-dynamic', async () => { it('should not have static indicator when using force-dynamic', async () => {
const browser = await next.browser('/force-dynamic') const browser = await next.browser('/force-dynamic')
......
...@@ -5,6 +5,10 @@ import { ...@@ -5,6 +5,10 @@ import {
getRedboxSource, getRedboxSource,
} from 'next-test-utils' } from 'next-test-utils'
// Enabling PPR testing also enables the new dev overlay.
const isNewDevOverlay =
process.env.__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY === 'true'
describe('app-dir - server-component-next-dynamic-ssr-false', () => { describe('app-dir - server-component-next-dynamic-ssr-false', () => {
const { next } = nextTestSetup({ const { next } = nextTestSetup({
files: __dirname, files: __dirname,
...@@ -19,8 +23,43 @@ describe('app-dir - server-component-next-dynamic-ssr-false', () => { ...@@ -19,8 +23,43 @@ describe('app-dir - server-component-next-dynamic-ssr-false', () => {
} }
expect(redbox.description).toBe('Failed to compile') expect(redbox.description).toBe('Failed to compile')
if (process.env.TURBOPACK) {
expect(redbox.source).toMatchInlineSnapshot(` // TODO(jiwon): Remove this once we have a new dev overlay at stable.
if (isNewDevOverlay) {
if (process.env.TURBOPACK) {
expect(redbox.source).toMatchInlineSnapshot(`
"./app/page.js (3:23)
Ecmascript file had an error
1 | import dynamic from 'next/dynamic'
2 |
> 3 | const DynamicClient = dynamic(() => import('./client'), { ssr: false })
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 |
5 | export default function Page() {
6 | return <DynamicClient />
\`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a client component."
`)
} else {
expect(redbox.source).toMatchInlineSnapshot(`
"./app/page.js
Error: x \`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a client component.
,-[3:1]
1 | import dynamic from 'next/dynamic'
2 |
3 | const DynamicClient = dynamic(() => import('./client'), { ssr: false })
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 |
5 | export default function Page() {
6 | return <DynamicClient />
\`----"
`)
}
} else {
if (process.env.TURBOPACK) {
expect(redbox.source).toMatchInlineSnapshot(`
"./app/page.js:3:23 "./app/page.js:3:23
Ecmascript file had an error Ecmascript file had an error
1 | import dynamic from 'next/dynamic' 1 | import dynamic from 'next/dynamic'
...@@ -33,8 +72,8 @@ describe('app-dir - server-component-next-dynamic-ssr-false', () => { ...@@ -33,8 +72,8 @@ describe('app-dir - server-component-next-dynamic-ssr-false', () => {
\`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a client component." \`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a client component."
`) `)
} else { } else {
expect(redbox.source).toMatchInlineSnapshot(` expect(redbox.source).toMatchInlineSnapshot(`
"./app/page.js "./app/page.js
Error: x \`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a client component. Error: x \`ssr: false\` is not allowed with \`next/dynamic\` in Server Components. Please move it into a client component.
,-[3:1] ,-[3:1]
...@@ -47,6 +86,7 @@ describe('app-dir - server-component-next-dynamic-ssr-false', () => { ...@@ -47,6 +86,7 @@ describe('app-dir - server-component-next-dynamic-ssr-false', () => {
6 | return <DynamicClient /> 6 | return <DynamicClient />
\`----" \`----"
`) `)
}
} }
}) })
}) })
...@@ -8,6 +8,7 @@ import { ...@@ -8,6 +8,7 @@ import {
} from 'next-test-utils' } from 'next-test-utils'
const isReactExperimental = process.env.__NEXT_EXPERIMENTAL_PPR === 'true' const isReactExperimental = process.env.__NEXT_EXPERIMENTAL_PPR === 'true'
const isNewDevOverlay = isReactExperimental
const isReact18 = parseInt(process.env.NEXT_TEST_REACT_VERSION) === 18 const isReact18 = parseInt(process.env.NEXT_TEST_REACT_VERSION) === 18
describe('react-dom/server in React Server environment', () => { describe('react-dom/server in React Server environment', () => {
...@@ -393,7 +394,35 @@ describe('react-dom/server in React Server environment', () => { ...@@ -393,7 +394,35 @@ describe('react-dom/server in React Server environment', () => {
} }
`) `)
} else { } else {
expect(redbox).toMatchInlineSnapshot(` // TODO(jiwon): Remove this once we have a new dev overlay at stable.
if (isNewDevOverlay) {
expect(redbox).toMatchInlineSnapshot(`
{
"description": "Failed to compile",
"source": "./app/exports/app-code/react-dom-server-node-implicit/page.js
Error: x You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security.
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering
,-[1:1]
1 | import * as ReactDOMServerNode from 'react-dom/server'
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2 | // Fine to drop once React is on ESM
3 | import ReactDOMServerNodeDefault from 'react-dom/server'
\`----
x You're importing a component that imports react-dom/server. To fix it, render or return the content directly as a Server Component instead for perf and security.
| Learn more: https://nextjs.org/docs/app/building-your-application/rendering
,-[3:1]
1 | import * as ReactDOMServerNode from 'react-dom/server'
2 | // Fine to drop once React is on ESM
3 | import ReactDOMServerNodeDefault from 'react-dom/server'
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
4 |
5 | export const runtime = 'nodejs'
\`----",
}
`)
} else {
expect(redbox).toMatchInlineSnapshot(`
{ {
"description": "Failed to compile", "description": "Failed to compile",
"source": "./app/exports/app-code/react-dom-server-node-implicit/page.js "source": "./app/exports/app-code/react-dom-server-node-implicit/page.js
...@@ -417,6 +446,7 @@ describe('react-dom/server in React Server environment', () => { ...@@ -417,6 +446,7 @@ describe('react-dom/server in React Server environment', () => {
\`----", \`----",
} }
`) `)
}
} }
}) })
......
...@@ -13,6 +13,9 @@ describe('app-dir - error-on-next-codemod-comment', () => { ...@@ -13,6 +13,9 @@ describe('app-dir - error-on-next-codemod-comment', () => {
skipDeployment: true, skipDeployment: true,
}) })
const isNewDevOverlay =
process.env.__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY === 'true'
if (isNextDev) { if (isNextDev) {
beforeAll(async () => { beforeAll(async () => {
await next.start() await next.start()
...@@ -23,9 +26,12 @@ describe('app-dir - error-on-next-codemod-comment', () => { ...@@ -23,9 +26,12 @@ describe('app-dir - error-on-next-codemod-comment', () => {
await assertHasRedbox(browser) await assertHasRedbox(browser)
if (process.env.TURBOPACK) { // TODO(jiwon): Remove this once we have a new dev overlay at stable.
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` if (isNewDevOverlay) {
"./app/page.tsx:2:2 if (process.env.TURBOPACK) {
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"./app/page.tsx (2:2)
Ecmascript file had an error Ecmascript file had an error
1 | export default function Page() { 1 | export default function Page() {
> 2 | // @next-codemod-error remove jsx of next line > 2 | // @next-codemod-error remove jsx of next line
...@@ -37,8 +43,40 @@ describe('app-dir - error-on-next-codemod-comment', () => { ...@@ -37,8 +43,40 @@ describe('app-dir - error-on-next-codemod-comment', () => {
You have an unresolved @next/codemod comment "remove jsx of next line" that needs review. You have an unresolved @next/codemod comment "remove jsx of next line" that needs review.
After review, either remove the comment if you made the necessary changes or replace "@next-codemod-error" with "@next-codemod-ignore" to bypass the build error if no action at this line can be taken." After review, either remove the comment if you made the necessary changes or replace "@next-codemod-error" with "@next-codemod-ignore" to bypass the build error if no action at this line can be taken."
`) `)
} else {
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"./app/page.tsx
Error: x You have an unresolved @next/codemod comment "remove jsx of next line" that needs review.
| After review, either remove the comment if you made the necessary changes or replace "@next-codemod-error" with "@next-codemod-ignore" to bypass the build error if no action at this line can
| be taken.
|
,-[2:1]
1 | export default function Page() {
2 | // @next-codemod-error remove jsx of next line
: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 | return <p>hello world</p>
4 | }
\`----"
`)
}
} else { } else {
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(` if (process.env.TURBOPACK) {
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"./app/page.tsx:2:2
Ecmascript file had an error
1 | export default function Page() {
> 2 | // @next-codemod-error remove jsx of next line
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3 | return <p>hello world</p>
4 | }
5 |
You have an unresolved @next/codemod comment "remove jsx of next line" that needs review.
After review, either remove the comment if you made the necessary changes or replace "@next-codemod-error" with "@next-codemod-ignore" to bypass the build error if no action at this line can be taken."
`)
} else {
expect(await getRedboxSource(browser)).toMatchInlineSnapshot(`
"./app/page.tsx "./app/page.tsx
Error: x You have an unresolved @next/codemod comment "remove jsx of next line" that needs review. Error: x You have an unresolved @next/codemod comment "remove jsx of next line" that needs review.
| After review, either remove the comment if you made the necessary changes or replace "@next-codemod-error" with "@next-codemod-ignore" to bypass the build error if no action at this line can | After review, either remove the comment if you made the necessary changes or replace "@next-codemod-error" with "@next-codemod-ignore" to bypass the build error if no action at this line can
...@@ -52,6 +90,7 @@ describe('app-dir - error-on-next-codemod-comment', () => { ...@@ -52,6 +90,7 @@ describe('app-dir - error-on-next-codemod-comment', () => {
4 | } 4 | }
\`----" \`----"
`) `)
}
} }
}) })
......
...@@ -117,6 +117,8 @@ describe('non-root-project-monorepo', () => { ...@@ -117,6 +117,8 @@ describe('non-root-project-monorepo', () => {
).toMatchInlineSnapshot(` ).toMatchInlineSnapshot(`
"<unknown> "<unknown>
[project]/apps/web/app/separate-file.ts [app-rsc] (ecmascript) (rsc://React/Server/file://<full-path>/apps/web/.next/server/chunks/ssr/apps_web_XXXXXX._.js (7:7) [project]/apps/web/app/separate-file.ts [app-rsc] (ecmascript) (rsc://React/Server/file://<full-path>/apps/web/.next/server/chunks/ssr/apps_web_XXXXXX._.js (7:7)
innerArrowFunction
app/source-maps-rsc/page.tsx (13:28)
innerFunction innerFunction
app/source-maps-rsc/page.tsx (10:3) app/source-maps-rsc/page.tsx (10:3)
Page Page
...@@ -134,7 +136,9 @@ describe('non-root-project-monorepo', () => { ...@@ -134,7 +136,9 @@ describe('non-root-project-monorepo', () => {
// TODO webpack runtime code shouldn't be included in stack trace // TODO webpack runtime code shouldn't be included in stack trace
expect(normalizeStackTrace(await getRedboxCallStack(browser))) expect(normalizeStackTrace(await getRedboxCallStack(browser)))
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
"<unknown> "eval
app/separate-file.ts (1:11)
<unknown>
rsc)/./app/separate-file.ts (rsc://React/Server/file://<full-path>/apps/web/.next/server/app/source-maps-rsc/page.js rsc)/./app/separate-file.ts (rsc://React/Server/file://<full-path>/apps/web/.next/server/app/source-maps-rsc/page.js
__webpack_require__ __webpack_require__
file://<full-path>/apps/web/.next/server/webpack-runtime.js file://<full-path>/apps/web/.next/server/webpack-runtime.js
...@@ -164,7 +168,9 @@ describe('non-root-project-monorepo', () => { ...@@ -164,7 +168,9 @@ describe('non-root-project-monorepo', () => {
`) `)
expect(normalizeStackTrace(await getRedboxCallStack(browser))) expect(normalizeStackTrace(await getRedboxCallStack(browser)))
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
"innerArrowFunction "[project]/apps/web/app/separate-file.ts [app-client] (ecmascript)
app/separate-file.ts (1:7)
innerArrowFunction
app/source-maps-ssr/page.tsx (15:28) app/source-maps-ssr/page.tsx (15:28)
innerFunction innerFunction
app/source-maps-ssr/page.tsx (12:3) app/source-maps-ssr/page.tsx (12:3)
...@@ -183,7 +189,9 @@ describe('non-root-project-monorepo', () => { ...@@ -183,7 +189,9 @@ describe('non-root-project-monorepo', () => {
// TODO webpack runtime code shouldn't be included in stack trace // TODO webpack runtime code shouldn't be included in stack trace
expect(normalizeStackTrace(await getRedboxCallStack(browser))) expect(normalizeStackTrace(await getRedboxCallStack(browser)))
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
"./app/separate-file.ts "eval
app/separate-file.ts (1:7)
./app/separate-file.ts
file://<full-path>/apps/web/.next/static/chunks/app/source-maps-ssr/page.js (27:1) file://<full-path>/apps/web/.next/static/chunks/app/source-maps-ssr/page.js (27:1)
options.factory options.factory
file://<full-path>/apps/web/.next/static/chunks/webpack.js (700:31) file://<full-path>/apps/web/.next/static/chunks/webpack.js (700:31)
...@@ -217,7 +225,9 @@ describe('non-root-project-monorepo', () => { ...@@ -217,7 +225,9 @@ describe('non-root-project-monorepo', () => {
`) `)
expect(normalizeStackTrace(await getRedboxCallStack(browser))) expect(normalizeStackTrace(await getRedboxCallStack(browser)))
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
"innerArrowFunction "[project]/apps/web/app/separate-file.ts [app-client] (ecmascript)
app/separate-file.ts (1:7)
innerArrowFunction
app/source-maps-client/page.tsx (16:28) app/source-maps-client/page.tsx (16:28)
innerFunction innerFunction
app/source-maps-client/page.tsx (13:3) app/source-maps-client/page.tsx (13:3)
...@@ -236,7 +246,9 @@ describe('non-root-project-monorepo', () => { ...@@ -236,7 +246,9 @@ describe('non-root-project-monorepo', () => {
// TODO webpack runtime code shouldn't be included in stack trace // TODO webpack runtime code shouldn't be included in stack trace
expect(normalizeStackTrace(await getRedboxCallStack(browser))) expect(normalizeStackTrace(await getRedboxCallStack(browser)))
.toMatchInlineSnapshot(` .toMatchInlineSnapshot(`
"./app/separate-file.ts "eval
app/separate-file.ts (1:7)
./app/separate-file.ts
file://<full-path>/apps/web/.next/static/chunks/app/source-maps-client/page.js (27:1) file://<full-path>/apps/web/.next/static/chunks/app/source-maps-client/page.js (27:1)
options.factory options.factory
file://<full-path>/apps/web/.next/static/chunks/webpack.js (712:31) file://<full-path>/apps/web/.next/static/chunks/webpack.js (712:31)
......
...@@ -29,6 +29,9 @@ describe('use-cache-unknown-cache-kind', () => { ...@@ -29,6 +29,9 @@ describe('use-cache-unknown-cache-kind', () => {
return return
} }
const isNewDevOverlay =
process.env.__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY === 'true'
if (isNextStart) { if (isNextStart) {
it('should fail the build with an error', async () => { it('should fail the build with an error', async () => {
const { cliOutput } = await next.build() const { cliOutput } = await next.build()
...@@ -87,8 +90,39 @@ describe('use-cache-unknown-cache-kind', () => { ...@@ -87,8 +90,39 @@ describe('use-cache-unknown-cache-kind', () => {
expect(errorDescription).toBe('Failed to compile') expect(errorDescription).toBe('Failed to compile')
if (isTurbopack) { // TODO(jiwon): Remove this once we have a new dev overlay at stable.
expect(errorSource).toMatchInlineSnapshot(` if (isNewDevOverlay) {
if (isTurbopack) {
expect(errorSource).toMatchInlineSnapshot(`
"./app/page.tsx (1:1)
Ecmascript file had an error
> 1 | 'use cache: custom'
| ^^^^^^^^^^^^^^^^^^^
2 |
3 | export default async function Page() {
4 | return <p>hello world</p>
Unknown cache kind "custom". Please configure a cache handler for this kind in the "experimental.cacheHandlers" object in your Next.js config."
`)
} else {
expect(errorSource).toMatchInlineSnapshot(`
"./app/page.tsx
Error: x Unknown cache kind "custom". Please configure a cache handler for this kind in the "experimental.cacheHandlers" object in your Next.js config.
|
,-[1:1]
1 | 'use cache: custom'
: ^^^^^^^^^^^^^^^^^^^
2 |
3 | export default async function Page() {
4 | return <p>hello world</p>
\`----"
`)
}
} else {
if (isTurbopack) {
expect(errorSource).toMatchInlineSnapshot(`
"./app/page.tsx:1:1 "./app/page.tsx:1:1
Ecmascript file had an error Ecmascript file had an error
> 1 | 'use cache: custom' > 1 | 'use cache: custom'
...@@ -99,8 +133,8 @@ describe('use-cache-unknown-cache-kind', () => { ...@@ -99,8 +133,8 @@ describe('use-cache-unknown-cache-kind', () => {
Unknown cache kind "custom". Please configure a cache handler for this kind in the "experimental.cacheHandlers" object in your Next.js config." Unknown cache kind "custom". Please configure a cache handler for this kind in the "experimental.cacheHandlers" object in your Next.js config."
`) `)
} else { } else {
expect(errorSource).toMatchInlineSnapshot(` expect(errorSource).toMatchInlineSnapshot(`
"./app/page.tsx "./app/page.tsx
Error: x Unknown cache kind "custom". Please configure a cache handler for this kind in the "experimental.cacheHandlers" object in your Next.js config. Error: x Unknown cache kind "custom". Please configure a cache handler for this kind in the "experimental.cacheHandlers" object in your Next.js config.
| |
...@@ -112,6 +146,7 @@ describe('use-cache-unknown-cache-kind', () => { ...@@ -112,6 +146,7 @@ describe('use-cache-unknown-cache-kind', () => {
4 | return <p>hello world</p> 4 | return <p>hello world</p>
\`----" \`----"
`) `)
}
} }
}) })
......
...@@ -24,6 +24,9 @@ describe('use-cache-without-dynamic-io', () => { ...@@ -24,6 +24,9 @@ describe('use-cache-without-dynamic-io', () => {
return return
} }
const isNewDevOverlay =
process.env.__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY === 'true'
if (isNextStart) { if (isNextStart) {
it('should fail the build with an error', async () => { it('should fail the build with an error', async () => {
const { cliOutput } = await next.build() const { cliOutput } = await next.build()
...@@ -86,35 +89,71 @@ describe('use-cache-without-dynamic-io', () => { ...@@ -86,35 +89,71 @@ describe('use-cache-without-dynamic-io', () => {
expect(errorDescription).toBe('Failed to compile') expect(errorDescription).toBe('Failed to compile')
if (isTurbopack) { // TODO(jiwon): Remove this once we have a new dev overlay at stable.
expect(errorSource).toMatchInlineSnapshot(` if (isNewDevOverlay) {
"./app/page.tsx:1:1 if (isTurbopack) {
Ecmascript file had an error expect(errorSource).toMatchInlineSnapshot(`
> 1 | 'use cache' "./app/page.tsx (1:1)
| ^^^^^^^^^^^
2 | Ecmascript file had an error
3 | export default async function Page() { > 1 | 'use cache'
4 | return <p>hello world</p> | ^^^^^^^^^^^
2 |
To use "use cache", please enable the experimental feature flag "dynamicIO" in your Next.js config. 3 | export default async function Page() {
4 | return <p>hello world</p>
Read more: https://nextjs.org/docs/canary/app/api-reference/directives/use-cache#usage"
`) To use "use cache", please enable the experimental feature flag "dynamicIO" in your Next.js config.
Read more: https://nextjs.org/docs/canary/app/api-reference/directives/use-cache#usage"
`)
} else {
expect(errorSource).toMatchInlineSnapshot(`
"./app/page.tsx
Error: x To use "use cache", please enable the experimental feature flag "dynamicIO" in your Next.js config.
|
| Read more: https://nextjs.org/docs/canary/app/api-reference/directives/use-cache#usage
|
,-[1:1]
1 | 'use cache'
: ^^^^^^^^^^^
2 |
3 | export default async function Page() {
4 | return <p>hello world</p>
\`----"
`)
}
} else { } else {
expect(errorSource).toMatchInlineSnapshot(` if (isTurbopack) {
"./app/page.tsx expect(errorSource).toMatchInlineSnapshot(`
Error: x To use "use cache", please enable the experimental feature flag "dynamicIO" in your Next.js config. "./app/page.tsx:1:1
| Ecmascript file had an error
| Read more: https://nextjs.org/docs/canary/app/api-reference/directives/use-cache#usage > 1 | 'use cache'
| | ^^^^^^^^^^^
,-[1:1] 2 |
1 | 'use cache' 3 | export default async function Page() {
: ^^^^^^^^^^^ 4 | return <p>hello world</p>
2 |
3 | export default async function Page() { To use "use cache", please enable the experimental feature flag "dynamicIO" in your Next.js config.
4 | return <p>hello world</p>
\`----" Read more: https://nextjs.org/docs/canary/app/api-reference/directives/use-cache#usage"
`) `)
} else {
expect(errorSource).toMatchInlineSnapshot(`
"./app/page.tsx
Error: x To use "use cache", please enable the experimental feature flag "dynamicIO" in your Next.js config.
|
| Read more: https://nextjs.org/docs/canary/app/api-reference/directives/use-cache#usage
|
,-[1:1]
1 | 'use cache'
: ^^^^^^^^^^^
2 |
3 | export default async function Page() {
4 | return <p>hello world</p>
\`----"
`)
}
} }
}) })
......
...@@ -36,6 +36,10 @@ export { shouldRunTurboDevTest } ...@@ -36,6 +36,10 @@ export { shouldRunTurboDevTest }
export const nextServer = server export const nextServer = server
export const pkg = _pkg export const pkg = _pkg
// TODO(jiwon): Remove this once we have a new dev overlay at stable.
const isNewDevOverlay =
process.env.__NEXT_EXPERIMENTAL_NEW_DEV_OVERLAY === 'true'
export function initNextServerScript( export function initNextServerScript(
scriptPath: string, scriptPath: string,
successRegexp: RegExp, successRegexp: RegExp,
...@@ -883,13 +887,18 @@ export async function assertNoRedbox(browser: BrowserInterface) { ...@@ -883,13 +887,18 @@ export async function assertNoRedbox(browser: BrowserInterface) {
export async function hasErrorToast( export async function hasErrorToast(
browser: BrowserInterface browser: BrowserInterface
): Promise<boolean> { ): Promise<boolean> {
return browser.eval(() => { return (
return Boolean( (await browser.eval(() => {
Array.from(document.querySelectorAll('nextjs-portal')).find((p) => return Boolean(
p.shadowRoot.querySelector('[data-nextjs-toast]') [].slice.call(document.querySelectorAll('nextjs-portal')).find((p) =>
p.shadowRoot.querySelector(
// TODO(jiwon): data-nextjs-toast may not be an error indicator in new UI
isNewDevOverlay ? '[data-issues]' : '[data-nextjs-toast]'
)
)
) )
) })) ?? false // When browser.eval() throws, it returns null.
}) )
} }
/** /**
...@@ -898,7 +907,13 @@ export async function hasErrorToast( ...@@ -898,7 +907,13 @@ export async function hasErrorToast(
*/ */
export async function openRedbox(browser: BrowserInterface): Promise<void> { export async function openRedbox(browser: BrowserInterface): Promise<void> {
try { try {
browser.waitForElementByCss('[data-nextjs-toast]', 5000).click() //TODO(jiwon): data-nextjs-toast won't open red box in new UI.
if (isNewDevOverlay) {
await browser.waitForElementByCss('[data-error-expanded="true"]')
await browser.waitForElementByCss('[data-issues-open]').click()
} else {
await browser.waitForElementByCss('[data-nextjs-toast]').click()
}
} catch (cause) { } catch (cause) {
const error = new Error('No Redbox to open.', { cause }) const error = new Error('No Redbox to open.', { cause })
Error.captureStackTrace(error, openRedbox) Error.captureStackTrace(error, openRedbox)
...@@ -907,6 +922,49 @@ export async function openRedbox(browser: BrowserInterface): Promise<void> { ...@@ -907,6 +922,49 @@ export async function openRedbox(browser: BrowserInterface): Promise<void> {
await assertHasRedbox(browser) await assertHasRedbox(browser)
} }
export async function openDevToolsIndicatorPopover(
browser: BrowserInterface
): Promise<void> {
try {
await browser.waitForElementByCss('[data-nextjs-dev-tools-button]').click()
} catch (cause) {
const error = new Error('No DevTools Indicator to open.', { cause })
Error.captureStackTrace(error, openDevToolsIndicatorPopover)
throw error
}
}
export async function getRouteTypeFromDevToolsIndicator(
browser: BrowserInterface
): Promise<'Static' | 'Dynamic'> {
await openDevToolsIndicatorPopover(browser)
return browser.eval(() => {
const portal = [].slice
.call(document.querySelectorAll('nextjs-portal'))
.find((p) => p.shadowRoot.querySelector('[data-nextjs-toast]'))
const root = portal?.shadowRoot
// 'Route\nStatic' || 'Route\nDynamic'
const routeTypeText = root?.querySelector(
'[data-nextjs-route-type]'
)?.innerText
if (!routeTypeText) {
throw new Error('No Route Type Text Found')
}
// 'Static' || 'Dynamic'
const routeType = routeTypeText.split('\n').pop()
if (routeType !== 'Static' && routeType !== 'Dynamic') {
throw new Error(`Invalid Route Type: ${routeType}`)
}
return routeType as 'Static' | 'Dynamic'
})
}
export function getRedboxHeader(browser: BrowserInterface) { export function getRedboxHeader(browser: BrowserInterface) {
return browser.eval(() => { return browser.eval(() => {
const portal = [].slice const portal = [].slice
...@@ -917,7 +975,26 @@ export function getRedboxHeader(browser: BrowserInterface) { ...@@ -917,7 +975,26 @@ export function getRedboxHeader(browser: BrowserInterface) {
}) })
} }
export function getRedboxFloatingHeaderText(
browser: BrowserInterface
): Promise<string> {
return browser.eval(() => {
const portal = [].slice
.call(document.querySelectorAll('nextjs-portal'))
.find((p) => p.shadowRoot.querySelector('.error-overlay-floating-header'))
const root = portal.shadowRoot
return root.querySelector('.error-overlay-floating-header')?.innerText
})
}
export async function getRedboxTotalErrorCount(browser: BrowserInterface) { export async function getRedboxTotalErrorCount(browser: BrowserInterface) {
// TODO(jiwon): Remove this once we have a new dev overlay at stable.
if (isNewDevOverlay) {
// N/M\nNext.js X.Y.Z -> M
const text = (await getRedboxFloatingHeaderText(browser)) || ''
return parseInt(text.match(/\/(\d+)/)?.[1])
}
const header = (await getRedboxHeader(browser)) || '' const header = (await getRedboxHeader(browser)) || ''
return parseInt(header.match(/\d+ of (\d+) issue/)?.[1], 10) return parseInt(header.match(/\d+ of (\d+) issue/)?.[1], 10)
} }
......
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