When changing error handling, add/maintain tests that:
useErrorBoundary: true and useErrorBoundary: (err) => boolean).NODE_ENV or other globals unless the behavior truly differs.Promise.reject(err) / then(() => Promise.reject(err))).Example (boundary + config variant):
it('lets errors fall through when useErrorBoundary is falsey', async () => {
const key = queryKey()
function Page() {
useQueries({
queries: [{
queryKey: key,
queryFn: () => Promise.reject(new Error('boom')),
useErrorBoundary: (err) => err.message.includes('boom'),
}],
})
return null
}
// assert: boundary behavior matches the function result
})
Example (redaction rule):
const queryClient = createQueryClient({
defaultOptions: {
dehydrate: {
shouldDehydrateQuery: () => true,
shouldRedactErrors: () => false,
},
},
})
await expect(
dehydrate(queryClient).queries[0]!.promise,
).resolves.toBeInstanceOf(Promise) // and then assert the thrown error is the original
The goal is confidence that error propagation/redaction behaves exactly as intended across supported modes, without relying on brittle or misleading test setup.
Enter the URL of a public GitHub repository