Skip to content

Commit 64d056a

Browse files
committed
Add tests for SDK metadata to node and node-core
1 parent b31cbc9 commit 64d056a

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

packages/node-core/test/sdk/init.test.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Integration } from '@sentry/core';
2-
import { logger } from '@sentry/core';
2+
import { logger, SDK_VERSION } from '@sentry/core';
33
import * as SentryOpentelemetry from '@sentry/opentelemetry';
44
import { type Mock, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
55
import { getClient } from '../../src/';
@@ -31,6 +31,24 @@ describe('init()', () => {
3131
vi.clearAllMocks();
3232
});
3333

34+
describe('metadata', () => {
35+
it('has the correct metadata', () => {
36+
init({ dsn: PUBLIC_DSN });
37+
38+
const client = getClient<NodeClient>();
39+
40+
expect(client?.getSdkMetadata()).toEqual(
41+
expect.objectContaining({
42+
sdk: {
43+
name: 'sentry.javascript.node-core',
44+
version: SDK_VERSION,
45+
packages: [{ name: 'npm:@sentry/node-core', version: SDK_VERSION }],
46+
},
47+
}),
48+
);
49+
});
50+
});
51+
3452
describe('integrations', () => {
3553
it("doesn't install default integrations if told not to", () => {
3654
init({ dsn: PUBLIC_DSN, defaultIntegrations: false });

packages/node/test/sdk/init.test.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Integration } from '@sentry/core';
2-
import { logger } from '@sentry/core';
2+
import { logger, SDK_VERSION } from '@sentry/core';
33
import * as SentryOpentelemetry from '@sentry/opentelemetry';
44
import { type Mock, type MockInstance, afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
55
import { getClient, NodeClient, validateOpenTelemetrySetup } from '../../src/';
@@ -38,6 +38,24 @@ describe('init()', () => {
3838
vi.clearAllMocks();
3939
});
4040

41+
describe('metadata', () => {
42+
it('has the correct metadata', () => {
43+
init({ dsn: PUBLIC_DSN });
44+
45+
const client = getClient<NodeClient>();
46+
47+
expect(client?.getSdkMetadata()).toEqual(
48+
expect.objectContaining({
49+
sdk: {
50+
name: 'sentry.javascript.node',
51+
version: SDK_VERSION,
52+
packages: [{ name: 'npm:@sentry/node', version: SDK_VERSION }],
53+
},
54+
}),
55+
);
56+
});
57+
});
58+
4159
describe('integrations', () => {
4260
it("doesn't install default integrations if told not to", () => {
4361
init({ dsn: PUBLIC_DSN, defaultIntegrations: false });

0 commit comments

Comments
 (0)