Skip to content

Commit 608c8fe

Browse files
committed
fix tests
1 parent 3b7513f commit 608c8fe

File tree

7 files changed

+38
-1
lines changed

7 files changed

+38
-1
lines changed

packages/core/test/lib/request.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
11
import { Event, SentryRequest, TransactionSamplingMethod } from '@sentry/types';
2+
import { addBase64MethodsToCarrier } from '@sentry/utils';
23

4+
// Note: yes, it's gross importing from another package by path rather than the real way, but the real way causes
5+
// circular dependency warnings, even though it's only for tests. See https://github.com/lerna/lerna/issues/1198.
6+
// @ts-ignore See above
7+
import { unsafeFromBase64, unsafeToBase64 } from '../../../node/src/string';
38
import { API } from '../../src/api';
49
import { eventToSentryRequest } from '../../src/request';
510

11+
addBase64MethodsToCarrier({ unsafeFromBase64, unsafeToBase64 });
12+
613
describe('eventToSentryRequest', () => {
714
function parseEnvelopeRequest(request: SentryRequest): any {
815
const [envelopeHeaderString, itemHeaderString, eventString] = request.body.split('\n');

packages/node/test/integrations/http.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ import * as sentryCore from '@sentry/core';
22
import { Hub } from '@sentry/hub';
33
import * as hubModule from '@sentry/hub';
44
import { addExtensionMethods, SENTRY_TRACE_REGEX, Span, Transaction } from '@sentry/tracing';
5+
import { addBase64MethodsToCarrier } from '@sentry/utils';
56
import * as http from 'http';
67
import * as nock from 'nock';
78

89
import { NodeClient } from '../../src/client';
910
import { Http as HttpIntegration } from '../../src/integrations/http';
11+
import { unsafeFromBase64, unsafeToBase64 } from '../../src/string';
12+
13+
addBase64MethodsToCarrier({ unsafeFromBase64, unsafeToBase64 });
1014

1115
describe('tracing', () => {
1216
function createTransactionOnScope(): Transaction {

packages/tracing/test/browser/request.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* @jest-environment ../../../.jest/dom-environment
3+
*/
4+
15
import { BrowserClient } from '@sentry/browser';
26
import { Hub, makeMain } from '@sentry/hub';
37
import * as utils from '@sentry/utils';

packages/tracing/test/httpheaders.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@ import { API } from '@sentry/core';
33
import { Hub } from '@sentry/hub';
44
import { SentryRequest } from '@sentry/types';
55
import * as utilsPackage from '@sentry/utils';
6-
import { base64ToUnicode } from '@sentry/utils';
6+
import { addBase64MethodsToCarrier, base64ToUnicode } from '@sentry/utils';
77

8+
// Note: yes, it's gross importing from another package by path rather than the real way, but the real way causes
9+
// circular dependency warnings, even though it's only for tests. See https://github.com/lerna/lerna/issues/1198.
10+
// @ts-ignore See above
11+
import { unsafeFromBase64, unsafeToBase64 } from '../../node/src/string';
812
import { Span } from '../src/span';
913
import { Transaction } from '../src/transaction';
1014
import { computeTracestateValue } from '../src/utils';
1115

1216
// TODO gather sentry-trace and tracestate tests here
1317

18+
addBase64MethodsToCarrier({ unsafeFromBase64, unsafeToBase64 });
19+
1420
function parseEnvelopeRequest(request: SentryRequest): any {
1521
const [envelopeHeaderString, itemHeaderString, eventString] = request.body.split('\n');
1622

packages/tracing/test/hub.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
/**
2+
* @jest-environment ../../../.jest/dom-environment
3+
*/
4+
15
/* eslint-disable @typescript-eslint/unbound-method */
6+
27
import { BrowserClient } from '@sentry/browser';
38
import { Hub } from '@sentry/hub';
49
import * as hubModule from '@sentry/hub';

packages/tracing/test/span.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/**
2+
* @jest-environment ../../../.jest/dom-environment
3+
*/
4+
15
import { BrowserClient } from '@sentry/browser';
26
import { Hub, Scope } from '@sentry/hub';
37
import * as hubPackage from '@sentry/hub';

packages/utils/test/string.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1+
// Note: yes, it's gross importing from another package by path rather than the real way, but the real way causes
2+
// circular dependency warnings, even though it's only for tests. See https://github.com/lerna/lerna/issues/1198.
3+
// @ts-ignore See above
4+
import { unsafeFromBase64, unsafeToBase64 } from '../../node/src/string';
5+
import { addBase64MethodsToCarrier } from '../src/compat';
16
import { base64ToUnicode, isMatchingPattern, truncate, unicodeToBase64 } from '../src/string';
27

8+
addBase64MethodsToCarrier({ unsafeFromBase64, unsafeToBase64 });
9+
310
// See https://tools.ietf.org/html/rfc4648#section-4 for base64 spec
411
// eslint-disable-next-line no-useless-escape
512
const BASE64_REGEX = /([a-zA-Z0-9+/]{4})*(|([a-zA-Z0-9+/]{3}=)|([a-zA-Z0-9+/]{2}==))/;

0 commit comments

Comments
 (0)