Skip to content

Commit 39b5a75

Browse files
committed
add tests for new integration exports
1 parent 71116cc commit 39b5a75

File tree

3 files changed

+32
-19
lines changed

3 files changed

+32
-19
lines changed
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import { Integrations } from '../src/index.bundle';
2-
import { testOnlyIfNodeVersionAtLeast } from './testutils';
32

43
describe('Integrations export', () => {
5-
// TODO `Object.values` doesn't work on Node < 8
6-
testOnlyIfNodeVersionAtLeast(8)('is exported correctly', () => {
7-
Object.values(Integrations).forEach(integration => {
8-
expect(integration.id).toStrictEqual(expect.any(String));
4+
it('is exported correctly', () => {
5+
Object.keys(Integrations).forEach(key => {
6+
expect(Integrations[key as keyof typeof Integrations].id).toStrictEqual(expect.any(String));
97
});
108
});
119
});

packages/tracing/test/index.test.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { getCurrentHub } from '@sentry/hub';
2+
3+
import { BrowserTracing, Integrations } from '../src';
4+
5+
describe('index', () => {
6+
describe('Integrations', () => {
7+
it('is exported correctly', () => {
8+
Object.keys(Integrations).forEach(key => {
9+
expect(Integrations[key as keyof typeof Integrations].id).toStrictEqual(expect.any(String));
10+
});
11+
});
12+
13+
it('contains BrowserTracing', () => {
14+
expect(Integrations.BrowserTracing).toEqual(BrowserTracing);
15+
});
16+
});
17+
18+
it('patches the global hub as a side effect', () => {
19+
const hub = getCurrentHub();
20+
const transaction = hub.startTransaction({ name: 'test', endTimestamp: 123 });
21+
expect(transaction).toBeDefined();
22+
});
23+
24+
it('patches the global hub as a side effect', () => {
25+
const hub = getCurrentHub();
26+
const transaction = hub.startTransaction({ name: 'test', endTimestamp: 123 });
27+
expect(transaction).toBeDefined();
28+
});
29+
});

packages/tracing/test/testutils.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,3 @@ export function getSymbolObjectKeyByName(obj: Record<string | symbol, any>, desc
4242

4343
return matches[0] || undefined;
4444
}
45-
46-
export const testOnlyIfNodeVersionAtLeast = (minVersion: number): jest.It => {
47-
const currentNodeVersion = process.env.NODE_VERSION;
48-
49-
try {
50-
if (Number(currentNodeVersion?.split('.')[0]) < minVersion) {
51-
return it.skip;
52-
}
53-
} catch (oO) {
54-
// we can't tell, so err on the side of running the test
55-
}
56-
57-
return it;
58-
};

0 commit comments

Comments
 (0)