Skip to content

Commit

Permalink
chore(tests/utils): suppress error boundary error log (#2112)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmkx authored Sep 2, 2023
1 parent ccba918 commit 5e5a5e6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/react/vanilla-utils/atomWithObservable.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useAtom, useAtomValue, useSetAtom } from 'jotai/react'
import { atom, createStore } from 'jotai/vanilla'
import { atomWithObservable } from 'jotai/vanilla/utils'

const consoleError = console.error
beforeEach(() => {
vi.useFakeTimers({ shouldAdvanceTime: true })
// A workaround for missing performance.mark after using fake timers
Expand All @@ -17,11 +18,23 @@ beforeEach(() => {
performance.clearMarks = (() => {}) as any
performance.clearMeasures = (() => {}) as any
}
// suppress ErrorBoundary error log
console.error = vi.fn((message: unknown, ...optionalParams: unknown[]) => {
if (
typeof message === 'string' &&
(message.includes('Error: Uncaught [Error: Test Error]') ||
message.includes('at ErrorBoundary'))
) {
return
}
return consoleError(message, ...optionalParams)
})
})

afterEach(() => {
vi.runAllTimers()
vi.useRealTimers()
console.error = consoleError
})

class ErrorBoundary extends Component<
Expand Down

1 comment on commit 5e5a5e6

@vercel
Copy link

@vercel vercel bot commented on 5e5a5e6 Sep 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.