Skip to content

Commit 84c4952

Browse files
committed
fix tests
1 parent 730532f commit 84c4952

File tree

2 files changed

+13
-10
lines changed
  • dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-header-out
  • packages/node/test

2 files changed

+13
-10
lines changed

dev-packages/node-integration-tests/suites/express/sentry-trace/baggage-header-out/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ app.get('/test/express', (_req, res) => {
3131
const traceId = transaction?.spanContext().traceId;
3232
const headers = http.get('http://somewhere.not.sentry/').getHeaders();
3333
if (traceId) {
34-
headers['baggage'] = (headers['baggage'] as string).replace(traceId, '__SENTRY_TRACE_ID__')
34+
headers['baggage'] = (headers['baggage'] as string).replace(traceId, '__SENTRY_TRACE_ID__');
3535
}
3636
// Responding with the headers outgoing request headers back to the assertions.
3737
res.send({ test_data: headers });

packages/node/test/handlers.test.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
getMainCarrier,
1010
mergeScopeData,
1111
setCurrentClient,
12+
spanIsSampled,
1213
spanToJSON,
1314
withScope,
1415
} from '@sentry/core';
@@ -322,12 +323,13 @@ describe('tracingHandler', () => {
322323
dsc: { version: '1.0', environment: 'production' },
323324
});
324325

325-
const transaction = (res as any).__sentry_transaction;
326+
const transaction = (res as any).__sentry_transaction as Transaction;
326327

327328
// since we have no tracesSampler defined, the default behavior (inherit if possible) applies
328-
expect(transaction.traceId).toEqual('12312012123120121231201212312012');
329-
expect(transaction.parentSpanId).toEqual('1121201211212012');
330-
expect(transaction.sampled).toEqual(true);
329+
expect(transaction.spanContext().traceId).toEqual('12312012123120121231201212312012');
330+
expect(spanToJSON(transaction).parent_span_id).toEqual('1121201211212012');
331+
expect(spanIsSampled(transaction)).toEqual(true);
332+
// eslint-disable-next-line deprecation/deprecation
331333
expect(transaction.metadata?.dynamicSamplingContext).toStrictEqual({ version: '1.0', environment: 'production' });
332334
});
333335

@@ -341,7 +343,8 @@ describe('tracingHandler', () => {
341343

342344
expect(getPropagationContext().dsc).toEqual({ version: '1.0', environment: 'production' });
343345

344-
const transaction = (res as any).__sentry_transaction;
346+
const transaction = (res as any).__sentry_transaction as Transaction;
347+
// eslint-disable-next-line deprecation/deprecation
345348
expect(transaction.metadata?.dynamicSamplingContext).toStrictEqual({ version: '1.0', environment: 'production' });
346349
});
347350

@@ -364,7 +367,7 @@ describe('tracingHandler', () => {
364367
it('puts its transaction on the response object', () => {
365368
sentryTracingMiddleware(req, res, next);
366369

367-
const transaction = (res as any).__sentry_transaction;
370+
const transaction = (res as any).__sentry_transaction as Transaction;
368371

369372
expect(transaction).toBeDefined();
370373

@@ -396,7 +399,7 @@ describe('tracingHandler', () => {
396399

397400
sentryTracingMiddleware(req, res, next);
398401

399-
const transaction = (res as any).__sentry_transaction;
402+
const transaction = (res as any).__sentry_transaction as Transaction;
400403

401404
expect(spanToJSON(transaction).description).toBe(`${method.toUpperCase()} ${path}`);
402405
});
@@ -406,7 +409,7 @@ describe('tracingHandler', () => {
406409

407410
sentryTracingMiddleware(req, res, next);
408411

409-
const transaction = (res as any).__sentry_transaction;
412+
const transaction = (res as any).__sentry_transaction as Transaction;
410413

411414
expect(spanToJSON(transaction).description).toBe(`${method.toUpperCase()} ${path}`);
412415
});
@@ -416,7 +419,7 @@ describe('tracingHandler', () => {
416419

417420
sentryTracingMiddleware(req, res, next);
418421

419-
const transaction = (res as any).__sentry_transaction;
422+
const transaction = (res as any).__sentry_transaction as Transaction;
420423

421424
expect(spanToJSON(transaction).description).toBe(`${method.toUpperCase()} ${path}`);
422425
});

0 commit comments

Comments
 (0)