-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
54 lines (50 loc) · 1.57 KB
/
test.ts
File metadata and controls
54 lines (50 loc) · 1.57 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { expect, it } from 'vitest';
import { eventEnvelope } from '../../expect';
import { createRunner } from '../../runner';
it('captures an error thrown in Bun.serve fetch handler', async ({ signal }) => {
const runner = createRunner(__dirname)
.expect(
eventEnvelope(
{
level: 'error',
exception: {
values: [
{
type: 'Error',
value: 'This is a test error from the Bun integration tests',
stacktrace: {
frames: expect.any(Array),
},
mechanism: { type: 'auto.http.bun.serve', handled: false },
},
],
},
request: expect.objectContaining({
method: 'GET',
url: expect.stringContaining('/error'),
}),
},
{ includeSampleRand: true, includeTransaction: false },
),
)
.ignore('transaction')
.start(signal);
await runner.makeRequest('get', '/error', { expectError: true });
await runner.completed();
});
it('captures a manually sent message', async ({ signal }) => {
const runner = createRunner(__dirname)
.expect(envelope => {
const [, envelopeItems] = envelope;
const [itemHeader, itemPayload] = envelopeItems[0];
expect(itemHeader.type).toBe('event');
expect(itemPayload).toMatchObject({
level: 'info',
message: 'Hello from Bun',
});
})
.ignore('transaction')
.start(signal);
await runner.makeRequest('get', '/message');
await runner.completed();
});