Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[test] Fix flaky error-recovery test #76789

Merged
merged 1 commit into from
Mar 4, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions test/development/acceptance-app/error-recovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,28 +534,31 @@ describe('Error recovery app', () => {
outdent`
import * as React from 'react';
let i = 0
setInterval(() => {
i++
throw Error('no ' + i)
}, 1000)
window.triggerError = () => {
// TODO(veil): sync thrown errors do not trigger Redbox.
setTimeout(() => {
i++
throw Error('no ' + i)
}, 0)
}
export default function FunctionNamed() {
return <div />
}
`
)

await new Promise((resolve) => setTimeout(resolve, 1000))
await browser.eval('window.triggerError()')
await expect(browser).toDisplayCollapsedRedbox(`
{
"count": 1,
"description": "Error: no 1",
"environmentLabel": null,
"label": "Unhandled Runtime Error",
"source": "index.js (5:9) @ eval
> 5 | throw Error('no ' + i)
| ^",
"source": "index.js (7:11) @ eval
> 7 | throw Error('no ' + i)
| ^",
"stack": [
"eval index.js (5:9)",
"eval index.js (7:11)",
],
}
`)
Expand All @@ -566,10 +569,13 @@ describe('Error recovery app', () => {
outdent`
import * as React from 'react';
let i = 0
setInterval(() => {
i++
throw Error('no ' + i)
}, 1000)
window.triggerError = () => {
// TODO(veil): sync thrown errors do not trigger Redbox.
setTimeout(() => {
i++
throw Error('no ' + i)
}, 0)
}
export default function FunctionNamed() {
`
)
Expand Down Expand Up @@ -598,13 +604,10 @@ describe('Error recovery app', () => {
"label": "Build Error",
"source": "./index.js
Error: x Expected '}', got '<eof>'
,-[7:1]
4 | i++
5 | throw Error('no ' + i)
6 | }, 1000)
7 | export default function FunctionNamed() {
: ^
\`----
,-[10:1]
10 | export default function FunctionNamed() {
: ^
\`----
Caused by:
Syntax Error
Import trace for requested module:
Expand All @@ -616,7 +619,7 @@ describe('Error recovery app', () => {
}

// Test that runtime error does not take over:
await new Promise((resolve) => setTimeout(resolve, 2000))
await browser.eval('window.triggerError()')
if (isTurbopack) {
await expect(browser).toDisplayRedbox(`
{
Expand All @@ -640,13 +643,10 @@ describe('Error recovery app', () => {
"label": "Build Error",
"source": "./index.js
Error: x Expected '}', got '<eof>'
,-[7:1]
4 | i++
5 | throw Error('no ' + i)
6 | }, 1000)
7 | export default function FunctionNamed() {
: ^
\`----
,-[10:1]
10 | export default function FunctionNamed() {
: ^
\`----
Caused by:
Syntax Error
Import trace for requested module:
Expand Down
Loading