Skip to content

Commit

Permalink
add pages test
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsorban44 committed Feb 26, 2024
1 parent b7e27d4 commit 5932f8e
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
4 changes: 3 additions & 1 deletion test/development/acceptance-app/ReactRefreshLogBox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -869,11 +869,13 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox app %s', () => {
expect(texts).not.toContain('<unknown>\n<anonymous>')
expect(texts).toContain('foo\nbar (1:1)')

// Test that node:internal errors should be hidden

next.patchFile(
'app/page.js',
// Node.js will throw an error about the invalid URL since this is a server component
outdent`
export default function Index() {
export default function Page() {
new URL("/", "invalid");
}`
)
Expand Down
28 changes: 26 additions & 2 deletions test/development/acceptance/ReactRefreshLogBox.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -806,13 +806,37 @@ describe.each(['default', 'turbo'])('ReactRefreshLogBox %s', () => {
)
expect(await session.hasRedbox()).toBe(true)
await expandCallStack(browser)
const callStackFrames = await browser.elementsByCss(
let callStackFrames = await browser.elementsByCss(
'[data-nextjs-call-stack-frame]'
)
const texts = await Promise.all(callStackFrames.map((f) => f.innerText()))
let texts = await Promise.all(callStackFrames.map((f) => f.innerText()))
expect(texts).not.toContain('stringify\n<anonymous>')
expect(texts).not.toContain('<unknown>\n<anonymous>')
expect(texts).toContain('foo\nbar (1:1)')

// Test that node:internal errors should be hidden

next.patchFile(
'pages/index.js',
// Node.js will throw an error about the invalid URL since it happens server-side
outdent`
export default function Page() {}
export function getServerSideProps() {
new URL("/", "invalid");
return { props: {} };
}`
)

expect(await session.hasRedbox()).toBe(true)
await expandCallStack(browser)
callStackFrames = await browser.elementsByCss(
'[data-nextjs-call-stack-frame]'
)
texts = await Promise.all(callStackFrames.map((f) => f.innerText()))

expect(texts.filter((t) => t.includes('node:internal'))).toHaveLength(0)

await cleanup()
})
})

0 comments on commit 5932f8e

Please sign in to comment.