test(desktop): stop the syntax-diff mock factory from leaking unhandled rejections (#94415)
The diff-lines error-boundary test mocked './syntax-diff' with a factory that THREW. vitest hoists the factory and registers its module promise in the mocker registry; a throwing factory leaves rejected promises there, and under CI load one escapes as "Vitest caught 1 unhandled error during the test run" attributed to whichever sibling file the worker is running (user-message-edit.test.tsx in run 32803716726) — an intermittent js-tests red on green code. Rework: the factory now resolves to a component that throws the fetch error during render — the same way React surfaces a rejected lazy payload — so no rejected promise ever sits in the registry. Guard proof (sabotage A/B): with the local syntax-diff ErrorBoundary removed from diff-lines.tsx, the reworked test still fails (workspace fallback renders), so the #93479 regression pin is intact. Full ui project: 596 files / 5729 tests green, no unhandled errors in 3 full-run repetitions.
This commit is contained in:
@@ -7,11 +7,20 @@ import { afterEach, describe, expect, it, vi } from 'vitest'
|
||||
// covers the *pending* state, so the rejection throws past it to the nearest
|
||||
// error boundary — which in production is the whole workspace `ContribBoundary`
|
||||
// — and blanks the transcript instead of degrading to the plain colored diff.
|
||||
vi.mock('./syntax-diff', () => {
|
||||
throw new Error(
|
||||
'Failed to fetch dynamically imported module: file:///Hermes.app/Contents/Resources/app.asar/dist/assets/syntax-diff-Bo0962zh.js'
|
||||
)
|
||||
})
|
||||
//
|
||||
// The mock resolves to a component that throws the fetch error during render —
|
||||
// the same way React surfaces a rejected lazy payload (a rejected import
|
||||
// re-throws at render time). Do NOT throw inside the factory itself: a
|
||||
// throwing factory leaves rejected promises in the vitest mocker registry,
|
||||
// and under CI load one escapes as an "unhandled error during the test run"
|
||||
// attributed to whichever sibling test file the worker is running (#94415).
|
||||
vi.mock('./syntax-diff', () => ({
|
||||
default: () => {
|
||||
throw new Error(
|
||||
'Failed to fetch dynamically imported module: file:///Hermes.app/Contents/Resources/app.asar/dist/assets/syntax-diff-Bo0962zh.js'
|
||||
)
|
||||
}
|
||||
}))
|
||||
|
||||
import { ErrorBoundary } from '@/components/error-boundary'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user