1
1
import { afterEach , beforeEach , describe , expect , it , test , vi } from 'vitest' ;
2
2
import {
3
3
Scope ,
4
- SentryError ,
5
4
SyncPromise ,
6
5
addBreadcrumb ,
7
6
dsnToString ,
@@ -13,6 +12,7 @@ import {
13
12
withMonitor ,
14
13
} from '../../src' ;
15
14
import type { BaseClient , Client } from '../../src/client' ;
15
+ import { _makeInternalError } from '../../src/client' ;
16
16
import * as integrationModule from '../../src/integration' ;
17
17
import type { Envelope , ErrorEvent , Event , SpanJSON , TransactionEvent } from '../../src/types-hoist' ;
18
18
import * as loggerModule from '../../src/utils-hoist/logger' ;
@@ -533,7 +533,7 @@ describe('Client', () => {
533
533
) ;
534
534
} ) ;
535
535
536
- test ( 'it adds a trace context to all events xxx ' , ( ) => {
536
+ test ( 'it adds a trace context to all events' , ( ) => {
537
537
expect . assertions ( 1 ) ;
538
538
539
539
const options = getDefaultTestClientOptions ( { dsn : PUBLIC_DSN } ) ;
@@ -1206,7 +1206,7 @@ describe('Client', () => {
1206
1206
const options = getDefaultTestClientOptions ( { dsn : PUBLIC_DSN , beforeSend } ) ;
1207
1207
const client = new TestClient ( options ) ;
1208
1208
const captureExceptionSpy = vi . spyOn ( client , 'captureException' ) ;
1209
- const loggerWarnSpy = vi . spyOn ( loggerModule . logger , 'log' ) ;
1209
+ const loggerLogSpy = vi . spyOn ( loggerModule . logger , 'log' ) ;
1210
1210
1211
1211
client . captureEvent ( { message : 'hello' } ) ;
1212
1212
@@ -1215,7 +1215,7 @@ describe('Client', () => {
1215
1215
// This proves that the reason the event didn't send/didn't get set on the test client is not because there was an
1216
1216
// error, but because `beforeSend` returned `null`
1217
1217
expect ( captureExceptionSpy ) . not . toBeCalled ( ) ;
1218
- expect ( loggerWarnSpy ) . toBeCalledWith ( 'before send for type `error` returned `null`, will not send event.' ) ;
1218
+ expect ( loggerLogSpy ) . toBeCalledWith ( 'before send for type `error` returned `null`, will not send event.' ) ;
1219
1219
} ) ;
1220
1220
1221
1221
test ( 'calls `beforeSendTransaction` and discards the event' , ( ) => {
@@ -1225,7 +1225,7 @@ describe('Client', () => {
1225
1225
const options = getDefaultTestClientOptions ( { dsn : PUBLIC_DSN , beforeSendTransaction } ) ;
1226
1226
const client = new TestClient ( options ) ;
1227
1227
const captureExceptionSpy = vi . spyOn ( client , 'captureException' ) ;
1228
- const loggerWarnSpy = vi . spyOn ( loggerModule . logger , 'log' ) ;
1228
+ const loggerLogSpy = vi . spyOn ( loggerModule . logger , 'log' ) ;
1229
1229
1230
1230
client . captureEvent ( { transaction : '/dogs/are/great' , type : 'transaction' } ) ;
1231
1231
@@ -1234,7 +1234,7 @@ describe('Client', () => {
1234
1234
// This proves that the reason the event didn't send/didn't get set on the test client is not because there was an
1235
1235
// error, but because `beforeSendTransaction` returned `null`
1236
1236
expect ( captureExceptionSpy ) . not . toBeCalled ( ) ;
1237
- expect ( loggerWarnSpy ) . toBeCalledWith ( 'before send for type `transaction` returned `null`, will not send event.' ) ;
1237
+ expect ( loggerLogSpy ) . toBeCalledWith ( 'before send for type `transaction` returned `null`, will not send event.' ) ;
1238
1238
} ) ;
1239
1239
1240
1240
test ( 'does not discard span and warn when returning null from `beforeSendSpan' , ( ) => {
@@ -1294,7 +1294,7 @@ describe('Client', () => {
1294
1294
expect ( beforeSend ) . toHaveBeenCalled ( ) ;
1295
1295
expect ( TestClient . instance ! . event ) . toBeUndefined ( ) ;
1296
1296
expect ( loggerWarnSpy ) . toBeCalledWith (
1297
- new SentryError ( 'before send for type `error` must return `null` or a valid event.' ) ,
1297
+ _makeInternalError ( 'before send for type `error` must return `null` or a valid event.' ) . message ,
1298
1298
) ;
1299
1299
}
1300
1300
} ) ;
@@ -1315,7 +1315,7 @@ describe('Client', () => {
1315
1315
expect ( beforeSendTransaction ) . toHaveBeenCalled ( ) ;
1316
1316
expect ( TestClient . instance ! . event ) . toBeUndefined ( ) ;
1317
1317
expect ( loggerWarnSpy ) . toBeCalledWith (
1318
- new SentryError ( 'before send for type `transaction` must return `null` or a valid event.' ) ,
1318
+ _makeInternalError ( 'before send for type `transaction` must return `null` or a valid event.' ) . message ,
1319
1319
) ;
1320
1320
}
1321
1321
} ) ;
@@ -1688,9 +1688,9 @@ describe('Client', () => {
1688
1688
originalException : exception ,
1689
1689
} ) ;
1690
1690
expect ( loggerWarnSpy ) . toBeCalledWith (
1691
- new SentryError (
1691
+ _makeInternalError (
1692
1692
`Event processing pipeline threw an error, original event will not be sent. Details have been sent as a new event.\nReason: ${ exception } ` ,
1693
- ) ,
1693
+ ) . message ,
1694
1694
) ;
1695
1695
} ) ;
1696
1696
0 commit comments