-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Expand file tree
/
Copy pathtest.ts
More file actions
49 lines (47 loc) · 1.73 KB
/
test.ts
File metadata and controls
49 lines (47 loc) · 1.73 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
import { afterAll, describe, expect } from 'vitest';
import { assertSentryTransaction } from '../../../utils/assertions';
import { cleanupChildProcesses, createEsmAndCjsTests } from '../../../utils/runner';
describe('express late init', () => {
afterAll(() => {
cleanupChildProcesses();
});
createEsmAndCjsTests(__dirname, 'scenario.mjs', 'instrument.mjs', (createRunner, test) => {
test('applies expressIntegration config set via Sentry.init() called after instrumentExpress()', async () => {
const runner = createRunner()
.expect({
transaction: transaction => {
assertSentryTransaction(transaction, {
transaction: 'GET /test/express',
contexts: {
trace: {
op: 'http.server',
status: 'ok',
},
},
});
// request_handler span IS present
// confirms the express patch was applied.
expect(transaction.spans).toContainEqual(
expect.objectContaining({
data: expect.objectContaining({
'express.type': 'request_handler',
}),
}),
);
// Middleware spans NOT present, ignoreLayersType: ['middleware']
// configured via the Sentry.init() AFTER instrumentExpress().
expect(transaction.spans).not.toContainEqual(
expect.objectContaining({
data: expect.objectContaining({
'express.type': 'middleware',
}),
}),
);
},
})
.start();
runner.makeRequest('get', '/test/express');
await runner.completed();
});
});
});