Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
make TS happy in http tests
  • Loading branch information
lobsterkatie committed Mar 1, 2021
commit b06ceccfc25eed83af90b4e5faa85a927054aa94
11 changes: 7 additions & 4 deletions packages/node/test/integrations/http.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { NodeClient } from '../../src/client';
import { Http as HttpIntegration } from '../../src/integrations/http';

describe('tracing', () => {
function createTransactionOnScope() {
function createTransactionOnScope(): Transaction {
const hub = new Hub(
new NodeClient({
dsn: 'https://[email protected]/12312012',
Expand All @@ -24,7 +24,10 @@ describe('tracing', () => {
jest.spyOn(sentryCore, 'getCurrentHub').mockReturnValue(hub);
jest.spyOn(hubModule, 'getCurrentHub').mockReturnValue(hub);

const transaction = hub.startTransaction({ name: 'dogpark' });
// we have to cast this to a Transaction (the class) because hub.startTransaction only returns a Transaction (the
// interface, which doesn't have things like spanRecorder) (and because @sentry/hub can't depend on @sentry/tracing,
// we can't fix that)
const transaction = hub.startTransaction({ name: 'dogpark' }) as Transaction;
hub.getScope()?.setSpan(transaction);

return transaction;
Expand All @@ -36,7 +39,7 @@ describe('tracing', () => {
.reply(200);

const transaction = createTransactionOnScope();
const spans = (transaction as Span).spanRecorder?.spans as Span[];
const spans = transaction.spanRecorder?.spans as Span[];

http.get('http://dogs.are.great/');

Expand All @@ -55,7 +58,7 @@ describe('tracing', () => {
.reply(200);

const transaction = createTransactionOnScope();
const spans = (transaction as Span).spanRecorder?.spans as Span[];
const spans = transaction.spanRecorder?.spans as Span[];

http.get('http://squirrelchasers.ingest.sentry.io/api/12312012/store/');

Expand Down