Skip to content

Commit 762c678

Browse files
committed
fix test
1 parent 3ba2f65 commit 762c678

File tree

1 file changed

+21
-27
lines changed

1 file changed

+21
-27
lines changed

packages/core/test/lib/baseclient.test.ts

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ declare var global: any;
2929
const clientEventFromException = jest.spyOn(TestClient.prototype, 'eventFromException');
3030
const clientProcess = jest.spyOn(TestClient.prototype as any, '_process');
3131

32-
jest.spyOn(miscModule, 'uuid4').mockImplementation(() => '42');
32+
jest.spyOn(miscModule, 'uuid4').mockImplementation(() => '12312012123120121231201212312012');
3333
jest.spyOn(loggerModule, 'consoleSandbox').mockImplementation(cb => cb());
3434
jest.spyOn(stringModule, 'truncate').mockImplementation(str => str);
3535
jest.spyOn(timeModule, 'dateTimestampInSeconds').mockImplementation(() => 2020);
@@ -265,7 +265,7 @@ describe('BaseClient', () => {
265265
expect(TestClient.instance!.event).toEqual(
266266
expect.objectContaining({
267267
environment: 'production',
268-
event_id: '42',
268+
event_id: '12312012123120121231201212312012',
269269
exception: {
270270
values: [
271271
{
@@ -378,7 +378,7 @@ describe('BaseClient', () => {
378378
expect(TestClient.instance!.event).toEqual(
379379
expect.objectContaining({
380380
environment: 'production',
381-
event_id: '42',
381+
event_id: '12312012123120121231201212312012',
382382
level: 'info',
383383
message: 'test message',
384384
timestamp: 2020,
@@ -488,7 +488,7 @@ describe('BaseClient', () => {
488488
expect(TestClient.instance!.event).toEqual(
489489
expect.objectContaining({
490490
environment: 'production',
491-
event_id: '42',
491+
event_id: '12312012123120121231201212312012',
492492
message: 'message',
493493
timestamp: 2020,
494494
}),
@@ -516,14 +516,14 @@ describe('BaseClient', () => {
516516
expect(TestClient.instance!.event).toEqual(
517517
expect.objectContaining({
518518
environment: 'production',
519-
event_id: '42',
519+
event_id: '12312012123120121231201212312012',
520520
message: 'message',
521521
timestamp: 1234,
522522
}),
523523
);
524524
});
525525

526-
test('it adds a trace context all events', () => {
526+
test('it adds a trace context to all events xxx', () => {
527527
expect.assertions(1);
528528

529529
const options = getDefaultTestClientOptions({ dsn: PUBLIC_DSN });
@@ -532,17 +532,11 @@ describe('BaseClient', () => {
532532

533533
client.captureEvent({ message: 'message' }, { event_id: 'wat' }, scope);
534534

535-
expect(TestClient.instance!.event!).toEqual(
536-
expect.objectContaining({
537-
contexts: {
538-
trace: {
539-
parent_span_id: undefined,
540-
span_id: expect.stringMatching(/[a-f0-9]{16}/),
541-
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
542-
},
543-
},
544-
}),
545-
);
535+
expect(TestClient.instance?.event?.contexts?.trace).toEqual({
536+
parent_span_id: undefined,
537+
span_id: expect.stringMatching(/[a-f0-9]{16}/),
538+
trace_id: expect.stringMatching(/[a-f0-9]{32}/),
539+
});
546540
});
547541

548542
test('adds `event_id` from hint if available', () => {
@@ -576,7 +570,7 @@ describe('BaseClient', () => {
576570
expect(TestClient.instance!.event!).toEqual(
577571
expect.objectContaining({
578572
environment: 'production',
579-
event_id: '42',
573+
event_id: '12312012123120121231201212312012',
580574
message: 'message',
581575
timestamp: 2020,
582576
}),
@@ -595,7 +589,7 @@ describe('BaseClient', () => {
595589
expect(TestClient.instance!.event!).toEqual(
596590
expect.objectContaining({
597591
environment: 'env',
598-
event_id: '42',
592+
event_id: '12312012123120121231201212312012',
599593
message: 'message',
600594
timestamp: 2020,
601595
}),
@@ -614,7 +608,7 @@ describe('BaseClient', () => {
614608
expect(TestClient.instance!.event!).toEqual(
615609
expect.objectContaining({
616610
environment: 'production',
617-
event_id: '42',
611+
event_id: '12312012123120121231201212312012',
618612
message: 'message',
619613
timestamp: 2020,
620614
}),
@@ -633,7 +627,7 @@ describe('BaseClient', () => {
633627
expect(TestClient.instance!.event!).toEqual(
634628
expect.objectContaining({
635629
environment: 'production',
636-
event_id: '42',
630+
event_id: '12312012123120121231201212312012',
637631
message: 'message',
638632
release: 'v1.0.0',
639633
timestamp: 2020,
@@ -651,7 +645,7 @@ describe('BaseClient', () => {
651645

652646
client.captureEvent({ message: 'message' }, undefined, scope);
653647

654-
expect(TestClient.instance!.event!).toHaveProperty('event_id', '42');
648+
expect(TestClient.instance!.event!).toHaveProperty('event_id', '12312012123120121231201212312012');
655649
expect(TestClient.instance!.event!).toHaveProperty('message', 'message');
656650
expect(TestClient.instance!.event!).toHaveProperty('breadcrumbs');
657651
expect(TestClient.instance!.event!.breadcrumbs![0]).toHaveProperty('message', 'breadcrumb');
@@ -690,7 +684,7 @@ describe('BaseClient', () => {
690684
expect(TestClient.instance!.event!).toEqual(
691685
expect.objectContaining({
692686
environment: 'production',
693-
event_id: '42',
687+
event_id: '12312012123120121231201212312012',
694688
extra: { b: 'b' },
695689
message: 'message',
696690
tags: { a: 'a' },
@@ -713,7 +707,7 @@ describe('BaseClient', () => {
713707
expect(TestClient.instance!.event!).toEqual(
714708
expect.objectContaining({
715709
environment: 'production',
716-
event_id: '42',
710+
event_id: '12312012123120121231201212312012',
717711
fingerprint: ['abcd'],
718712
message: 'message',
719713
timestamp: 2020,
@@ -813,7 +807,7 @@ describe('BaseClient', () => {
813807
// also has trace context from global scope
814808
contexts: { ...normalizedObject, trace: expect.anything() },
815809
environment: 'production',
816-
event_id: '42',
810+
event_id: '12312012123120121231201212312012',
817811
extra: normalizedObject,
818812
timestamp: 2020,
819813
user: normalizedObject,
@@ -863,7 +857,7 @@ describe('BaseClient', () => {
863857
// also has trace context from global scope
864858
contexts: { ...normalizedObject, trace: expect.anything() },
865859
environment: 'production',
866-
event_id: '42',
860+
event_id: '12312012123120121231201212312012',
867861
extra: normalizedObject,
868862
timestamp: 2020,
869863
user: normalizedObject,
@@ -918,7 +912,7 @@ describe('BaseClient', () => {
918912
// also has trace context from global scope
919913
contexts: { ...normalizedObject, trace: expect.anything() },
920914
environment: 'production',
921-
event_id: '42',
915+
event_id: '12312012123120121231201212312012',
922916
extra: normalizedObject,
923917
timestamp: 2020,
924918
user: normalizedObject,

0 commit comments

Comments
 (0)