-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcatcher.transport.test.ts
More file actions
33 lines (28 loc) · 1.06 KB
/
catcher.transport.test.ts
File metadata and controls
33 lines (28 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { describe, it, expect, vi, beforeEach } from 'vitest';
import { BreadcrumbManager } from '../src/addons/breadcrumbs';
import type { Transport } from '../src';
import { wait, createCatcher, createTransport } from './catcher.helpers';
const mockParse = vi.hoisted(() => vi.fn().mockResolvedValue([]));
vi.mock('@hawk.so/core', async (importOriginal) => {
const actual = await importOriginal<typeof import('@hawk.so/core')>();
return { ...actual, StackParser: class { parse = mockParse; } };
});
describe('Catcher', () => {
beforeEach(() => {
localStorage.clear();
mockParse.mockResolvedValue([]);
(BreadcrumbManager as any).instance = null;
});
describe('transport failure', () => {
it('should not throw when transport.send rejects', async () => {
const transport: Transport = {
send: vi.fn().mockRejectedValue(new Error('network error')),
};
const act = async () => {
createCatcher(transport).send(new Error('e'));
await wait();
};
await expect(act()).resolves.toBeUndefined();
});
});
});