Skip to content

Commit 867d345

Browse files
committed
add integration tests
1 parent 3075cfd commit 867d345

File tree

4 files changed

+109
-0
lines changed

4 files changed

+109
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import * as Sentry from '@sentry/node';
2+
import { loggingTransport } from '@sentry-internal/node-integration-tests';
3+
4+
Sentry.init({
5+
dsn: 'https://public@dsn.ingest.sentry.io/1337',
6+
release: '1.0.0',
7+
environment: 'test',
8+
serverName: 'mi-servidor.com',
9+
transport: loggingTransport,
10+
});
11+
12+
async function run(): Promise<void> {
13+
Sentry.metrics.count('test.counter', 1, { attributes: { endpoint: '/api/test' } });
14+
15+
await Sentry.flush();
16+
}
17+
18+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
19+
run();
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { afterAll, describe, expect, test } from 'vitest';
2+
import { cleanupChildProcesses, createRunner } from '../../../../utils/runner';
3+
4+
describe('metrics server.address', () => {
5+
afterAll(() => {
6+
cleanupChildProcesses();
7+
});
8+
9+
test('should add server.address attribute to metrics when serverName is set', async () => {
10+
const runner = createRunner(__dirname, 'scenario.ts')
11+
.expect({
12+
trace_metric: {
13+
items: [
14+
{
15+
timestamp: expect.any(Number),
16+
trace_id: expect.any(String),
17+
name: 'test.counter',
18+
type: 'counter',
19+
value: 1,
20+
attributes: {
21+
endpoint: { value: '/api/test', type: 'string' },
22+
'server.address': { value: 'mi-servidor.com', type: 'string' },
23+
'sentry.release': { value: '1.0.0', type: 'string' },
24+
'sentry.environment': { value: 'test', type: 'string' },
25+
'sentry.sdk.name': { value: 'sentry.javascript.node', type: 'string' },
26+
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
27+
},
28+
},
29+
],
30+
},
31+
})
32+
.start();
33+
34+
await runner.completed();
35+
});
36+
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import * as Sentry from '@sentry/node';
2+
import { loggingTransport } from '@sentry-internal/node-integration-tests';
3+
4+
Sentry.init({
5+
dsn: 'https://public@dsn.ingest.sentry.io/1337',
6+
release: '1.0.0',
7+
environment: 'test',
8+
transport: loggingTransport,
9+
});
10+
11+
async function run(): Promise<void> {
12+
Sentry.metrics.count('test.counter', 1, { attributes: { endpoint: '/api/test' } });
13+
14+
await Sentry.flush();
15+
}
16+
17+
// eslint-disable-next-line @typescript-eslint/no-floating-promises
18+
run();
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { afterAll, describe, expect, test } from 'vitest';
2+
import { cleanupChildProcesses, createRunner } from '../../../../utils/runner';
3+
4+
describe('metrics server.address', () => {
5+
afterAll(() => {
6+
cleanupChildProcesses();
7+
});
8+
9+
test('should add server.address attribute to metrics when serverName is set', async () => {
10+
const runner = createRunner(__dirname, 'scenario.ts')
11+
.expect({
12+
trace_metric: {
13+
items: [
14+
{
15+
timestamp: expect.any(Number),
16+
trace_id: expect.any(String),
17+
name: 'test.counter',
18+
type: 'counter',
19+
value: 1,
20+
attributes: {
21+
endpoint: { value: '/api/test', type: 'string' },
22+
'server.address': { value: expect.any(String), type: 'string' },
23+
'sentry.release': { value: '1.0.0', type: 'string' },
24+
'sentry.environment': { value: 'test', type: 'string' },
25+
'sentry.sdk.name': { value: 'sentry.javascript.node', type: 'string' },
26+
'sentry.sdk.version': { value: expect.any(String), type: 'string' },
27+
},
28+
},
29+
],
30+
},
31+
})
32+
.start();
33+
34+
await runner.completed();
35+
});
36+
});

0 commit comments

Comments
 (0)