Skip to content

Commit ee2da7c

Browse files
committed
fix tracing test
1 parent d36a778 commit ee2da7c

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

packages/tracing/test/hub.test.ts

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,9 @@ import { BrowserClient } from '@sentry/browser';
33
import { getMainCarrier, Hub } from '@sentry/hub';
44
import * as hubModule from '@sentry/hub';
55
import * as utilsModule from '@sentry/utils'; // for mocking
6-
import { base64ToUnicode, getGlobalObject, isNodeEnv, logger } from '@sentry/utils';
6+
import { computeTracestate, getGlobalObject, isNodeEnv, logger } from '@sentry/utils';
77
import * as nodeHttpModule from 'http';
88

9-
import { Transaction } from '../src';
109
import { BrowserTracing } from '../src/browser/browsertracing';
1110
import { addExtensionMethods } from '../src/hubextensions';
1211
import { extractTraceparentData, TRACEPARENT_REGEXP } from '../src/utils';
@@ -46,26 +45,26 @@ describe('Hub', () => {
4645
expect(transaction).toEqual(expect.objectContaining(transactionContext));
4746
});
4847

49-
it('creates a new tracestate value (with the right data) if not given one in transaction context', () => {
48+
it('creates a new tracestate value if not given one in transaction context', () => {
49+
const environment = 'dogpark';
50+
const release = 'off.leash.park';
5051
const hub = new Hub(
5152
new BrowserClient({
5253
dsn: 'https://[email protected]/12312012',
53-
release: 'off.leash.park',
54-
environment: 'dogpark',
54+
release,
55+
environment,
5556
}),
5657
);
5758
const transaction = hub.startTransaction({ name: 'FETCH /ball' });
5859

59-
const b64Value =
60-
'eyJwdWJsaWNfa2V5IjoiZG9nc2FyZWJhZGF0a2VlcGluZ3NlY3JldHMiLCJlbnZpcm9ubWVudCI6ImRvZ3BhcmsiLCJyZWxlYXNlI' +
61-
'joib2ZmLmxlYXNoLnBhcmsifQ.';
62-
63-
expect(transaction.tracestate).toEqual(b64Value);
64-
expect(JSON.parse(base64ToUnicode(b64Value.replace('.', '=')))).toEqual({
65-
environment: 'dogpark',
60+
const b64Value = computeTracestate({
61+
trace_id: transaction.traceId,
62+
environment,
63+
release,
6664
public_key: 'dogsarebadatkeepingsecrets',
67-
release: 'off.leash.park',
6865
});
66+
67+
expect(transaction.tracestate).toEqual(b64Value);
6968
});
7069
});
7170

0 commit comments

Comments
 (0)