Skip to content

Commit 84f9dc1

Browse files
committed
test: server runtime capture level test
1 parent 49a5639 commit 84f9dc1

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

packages/core/test/lib/serverruntimeclient.test.ts

+50
Original file line numberDiff line numberDiff line change
@@ -153,4 +153,54 @@ describe('ServerRuntimeClient', () => {
153153
expect(sendEnvelopeSpy).toHaveBeenCalledTimes(0);
154154
});
155155
});
156+
157+
describe('captureException', () => {
158+
it('sends an exception event with level error', () => {
159+
const options = getDefaultClientOptions({ dsn: PUBLIC_DSN });
160+
client = new ServerRuntimeClient(options);
161+
162+
// @ts-expect-error accessing private method
163+
const sendEnvelopeSpy = jest.spyOn(client, '_sendEnvelope');
164+
165+
client.captureException(new Error('foo'));
166+
167+
expect(sendEnvelopeSpy).toHaveBeenCalledTimes(1);
168+
expect(sendEnvelopeSpy).toHaveBeenCalledWith([
169+
expect.any(Object),
170+
[
171+
[
172+
expect.any(Object),
173+
expect.objectContaining({
174+
level: 'error'
175+
})
176+
],
177+
],
178+
]);
179+
});
180+
});
181+
182+
describe('captureMessage', () => {
183+
it('sends a message event with level info', () => {
184+
const options = getDefaultClientOptions({ dsn: PUBLIC_DSN });
185+
client = new ServerRuntimeClient(options);
186+
187+
// @ts-expect-error accessing private method
188+
const sendEnvelopeSpy = jest.spyOn(client, '_sendEnvelope');
189+
190+
client.captureMessage('foo');
191+
192+
expect(sendEnvelopeSpy).toHaveBeenCalledTimes(1);
193+
expect(sendEnvelopeSpy).toHaveBeenCalledWith([
194+
expect.any(Object),
195+
[
196+
[
197+
expect.any(Object),
198+
expect.objectContaining({
199+
level: 'info'
200+
})
201+
],
202+
],
203+
]);
204+
});
205+
});
156206
});

0 commit comments

Comments
 (0)