Skip to content

Commit 7bac0c4

Browse files
authored
[test] Use new Redbox matchers in app/ dynamic-error-trace (#76783)
1 parent 059c255 commit 7bac0c4

File tree

2 files changed

+14
-97
lines changed

2 files changed

+14
-97
lines changed

test/development/acceptance-app/dynamic-error.test.ts

-49
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
11
import { nextTestSetup } from 'e2e-utils'
2-
import {
3-
assertHasRedbox,
4-
getRedboxSource,
5-
hasRedboxCallStack,
6-
} from 'next-test-utils'
7-
import { outdent } from 'outdent'
8-
9-
function normalizeStackTrace(trace) {
10-
return trace.replace(/ \(.*\)/g, '')
11-
}
122

133
describe('app dir - dynamic error trace', () => {
144
const { next, skipped } = nextTestSetup({
@@ -20,44 +10,20 @@ describe('app dir - dynamic error trace', () => {
2010
it('should show the error trace', async () => {
2111
const browser = await next.browser('/')
2212

23-
await assertHasRedbox(browser)
24-
25-
await expect(
26-
browser.hasElementByCssSelector(
27-
'[data-nextjs-data-runtime-error-collapsed-action]'
28-
)
29-
).resolves.toEqual(false)
30-
31-
await hasRedboxCallStack(browser)
32-
const stackFrameElements = await browser.elementsByCss(
33-
'[data-nextjs-call-stack-frame]'
34-
)
35-
const stackFramesContent = // TODO: Why is this text empty?
36-
(await Promise.all(stackFrameElements.map((f) => f.innerText())))
37-
// Filter out the frames having code snippet but without methodName and source
38-
.filter(Boolean)
39-
.join('\n')
40-
41-
// TODO: Show useful stack
42-
const normalizedStack = normalizeStackTrace(stackFramesContent)
43-
expect(normalizedStack).toMatchInlineSnapshot(`
44-
"Foo
45-
app/lib.js"
13+
// TODO(veil): Where is the stackframe for app/page.js?
14+
await expect(browser).toDisplayRedbox(`
15+
{
16+
"count": 1,
17+
"description": "Error: Route / with \`dynamic = "error"\` couldn't be rendered statically because it used \`headers\`. See more info here: https://nextjs.org/docs/app/building-your-application/rendering/static-and-dynamic#dynamic-rendering",
18+
"environmentLabel": "Server",
19+
"label": "Unhandled Runtime Error",
20+
"source": "app/lib.js (4:13) @ Foo
21+
> 4 | useHeaders()
22+
| ^",
23+
"stack": [
24+
"Foo app/lib.js (4:13)",
25+
],
26+
}
4627
`)
47-
48-
const codeframe = await getRedboxSource(browser)
49-
expect(codeframe).toEqual(
50-
outdent`
51-
app/lib.js (4:13) @ Foo
52-
53-
2 |
54-
3 | export function Foo() {
55-
> 4 | useHeaders()
56-
| ^
57-
5 | return 'foo'
58-
6 | }
59-
7 |
60-
`
61-
)
6228
})
6329
})

0 commit comments

Comments
 (0)