Skip to content

Commit 4c8edd4

Browse files
Zih0Lms24
authored andcommitted
test: server runtime capture level test
1 parent df2babb commit 4c8edd4

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

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

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

0 commit comments

Comments
 (0)