Skip to content

Commit

Permalink
only update existing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Jan 6, 2025
1 parent 6404a52 commit b24b95f
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 69 deletions.
63 changes: 63 additions & 0 deletions test/development/acceptance/ReactRefreshLogBox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { createSandbox } from 'development-sandbox'
import { FileRef, nextTestSetup } from 'e2e-utils'
import {
describeVariants as describe,
getStackFramesContent,
toggleCollapseCallStackFrames,
} from 'next-test-utils'
import path from 'path'
Expand Down Expand Up @@ -769,4 +770,66 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {

expect(callStackFrames.length).toBeGreaterThan(9)
})

// TODO: hide the anonymous frames between 2 ignored frames
test('should show anonymous frames from stack trace', async () => {
await using sandbox = await createSandbox(
next,
new Map([
[
'pages/index.js',
outdent`
export default function Page() {
[1, 2, 3].map(() => {
throw new Error("anonymous error!");
})
}`,
],
])
)

const { session, browser } = sandbox

await session.assertHasRedbox()

const stack = await getStackFramesContent(browser)
expect(stack).toMatchInlineSnapshot(`
"at Array.map ()
at Page (pages/index.js (2:13))"
`)
})

test('should collapse nodejs internal stack frames from stack trace', async () => {
await using sandbox = await createSandbox(
next,
new Map([
[
'pages/index.js',
outdent`
export default function Page() {}
function createURL() {
new URL("/", "invalid")
}
export function getServerSideProps() {
createURL()
return { props: {} }
}`,
],
])
)

const { session, browser } = sandbox
await session.assertHasRedbox()

const stack = await getStackFramesContent(browser)
expect(stack).toMatchInlineSnapshot(
`"at getServerSideProps (pages/index.js (8:3))"`
)

await toggleCollapseCallStackFrames(browser)
const stackCollapsed = await getStackFramesContent(browser)
expect(stackCollapsed).toContain('at new URL ()')
})
})
29 changes: 0 additions & 29 deletions test/development/errors/anonymous-stack-frame.test.ts

This file was deleted.

40 changes: 0 additions & 40 deletions test/development/errors/node-internal-stack-frame.test.ts

This file was deleted.

0 comments on commit b24b95f

Please sign in to comment.