Barazo default frontend
barazo.forum
1import { reportError } from './error-reporting'
2
3describe('reportError', () => {
4 it('logs to console.error with structured context', () => {
5 const spy = vi.spyOn(console, 'error').mockImplementation(() => {})
6 const error = new Error('Test error')
7
8 reportError(error, { boundary: 'root' })
9
10 expect(spy).toHaveBeenCalledWith(
11 '[Barazo]',
12 'root',
13 'Test error',
14 expect.objectContaining({ boundary: 'root' })
15 )
16
17 spy.mockRestore()
18 })
19
20 it('includes additional context in the log', () => {
21 const spy = vi.spyOn(console, 'error').mockImplementation(() => {})
22 const error = new Error('Admin error')
23
24 reportError(error, { boundary: 'admin', page: '/admin/settings' })
25
26 expect(spy).toHaveBeenCalledWith(
27 '[Barazo]',
28 'admin',
29 'Admin error',
30 expect.objectContaining({ boundary: 'admin', page: '/admin/settings' })
31 )
32
33 spy.mockRestore()
34 })
35})