fmdatalab
fmdatalab
Explore posts from servers
TTCTheo's Typesafe Cult
Created by fmdatalab on 4/24/2024 in #questions
Large number of Vercel Edge Middleware Invocations coming from next-auth's `/api/auth/session`
No description
1 replies
TTCTheo's Typesafe Cult
Created by fmdatalab on 1/8/2023 in #questions
Hide console.error when mocking error response in jest?
I'm writing a few client-side unit tests and want to assert what happens when an error is returned from the procedure. My tests pass ok, but I end up with a wall of console.error's when I do so. I don't want to mock the return value of console.error so that it never fires, as there may be some valid errors that are thrown that I want to catch, especially when running my tests on my CI/CD. Is there any other way to prevent the console.error from logging when a procedure throws an error? I've tried updating my loggerLink in my config during testing so that it is disabled, like so;
loggerLink({
enabled: (opts) =>
process.env.NODE_ENV === 'test' ? false : process.env.NODE_ENV === 'development' || (opts.direction === 'down' && opts.
result instanceof Error),
}),
loggerLink({
enabled: (opts) =>
process.env.NODE_ENV === 'test' ? false : process.env.NODE_ENV === 'development' || (opts.direction === 'down' && opts.
result instanceof Error),
}),
While this does clear the likes of the following console.error's
console.error
<< mutation #2 user.delete {
console.error
<< mutation #2 user.delete {
I will still get the likes of
console.error
TRPCClientError: An error occured when attempting to delete your user account. Please try again.
console.error
TRPCClientError: An error occured when attempting to delete your user account. Please try again.
Any help would be greatly appreciated!
3 replies