-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
50 lines (47 loc) · 1.35 KB
/
test.ts
File metadata and controls
50 lines (47 loc) · 1.35 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
import { createTestServer } from '@sentry-internal/test-utils';
import { expect, test } from 'vitest';
import { createRunner } from '../../../../utils/runner';
test('captures spans for outgoing http requests', async () => {
expect.assertions(3);
const [SERVER_URL, closeTestServer] = await createTestServer()
.get('/api/v0', () => {
// Just ensure we're called
expect(true).toBe(true);
})
.get(
'/api/v1',
() => {
// Just ensure we're called
expect(true).toBe(true);
},
404,
)
.start();
await createRunner(__dirname, 'scenario.ts')
.withEnv({ SERVER_URL })
.expect({
transaction: {
transaction: 'test_transaction',
spans: expect.arrayContaining([
expect.objectContaining({
description: expect.stringMatching(/GET .*\/api\/v0/),
op: 'http.client',
origin: 'auto.http.client',
status: 'ok',
}),
expect.objectContaining({
description: expect.stringMatching(/GET .*\/api\/v1/),
op: 'http.client',
origin: 'auto.http.client',
status: 'not_found',
data: expect.objectContaining({
'http.response.status_code': 404,
}),
}),
]),
},
})
.start()
.completed();
closeTestServer();
});