Skip to content

Commit

Permalink
fixing typying for transaction in runner
Browse files Browse the repository at this point in the history
  • Loading branch information
obecny committed Sep 18, 2024
1 parent d62a967 commit b9590c4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { TransactionEvent } from '@sentry/types';
import { cleanupChildProcesses, createRunner } from '../../../utils/runner';

jest.setTimeout(30_000);
Expand Down Expand Up @@ -35,16 +36,16 @@ describe('amqplib auto-instrumentation', () => {
readyMatches: ['Time to start RabbitMQ'],
})
.expect({
transaction: (transaction: any) => {
transaction: (transaction: TransactionEvent) => {
expect(transaction.transaction).toEqual('Test Server Start1');
expect(transaction.spans.length).toEqual(1);
expect(transaction.spans[0]).toMatchObject(EXPECTED_MESSAGE_SPAN_PRODUCER);
expect(transaction.spans?.length).toEqual(1);
expect(transaction.spans![0]).toMatchObject(EXPECTED_MESSAGE_SPAN_PRODUCER);
},
})
.expect({
transaction: (transaction: any) => {
transaction: (transaction: TransactionEvent) => {
expect(transaction.transaction).toEqual('queue1 process');
expect(transaction.contexts.trace).toMatchObject(EXPECTED_MESSAGE_SPAN_CONSUMER);
expect(transaction.contexts?.trace).toMatchObject(EXPECTED_MESSAGE_SPAN_CONSUMER);
},
})
.start(done);
Expand Down
5 changes: 3 additions & 2 deletions dev-packages/node-integration-tests/utils/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type {
SerializedCheckIn,
SerializedSession,
SessionAggregates,
TransactionEvent,
} from '@sentry/types';
import axios from 'axios';
import { createBasicSentryServer } from './server';
Expand Down Expand Up @@ -151,7 +152,7 @@ type Expected =
event: Partial<Event> | ((event: Event) => void);
}
| {
transaction: Partial<Event> | ((event: Event) => void);
transaction: Partial<TransactionEvent> | ((event: TransactionEvent) => void);
}
| {
session: Partial<SerializedSession> | ((event: SerializedSession) => void);
Expand Down Expand Up @@ -317,7 +318,7 @@ export function createRunner(...paths: string[]) {
}

if ('transaction' in expected) {
const event = item[1] as Event;
const event = item[1] as TransactionEvent;
if (typeof expected.transaction === 'function') {
expected.transaction(event);
} else {
Expand Down

0 comments on commit b9590c4

Please sign in to comment.