Skip to content

Commit 38e1097

Browse files
committed
fix tests
1 parent 78f9a08 commit 38e1097

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

packages/replay/src/integration.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { getCurrentHub } from '@sentry/core';
22
import type { BrowserClientReplayOptions, Integration } from '@sentry/types';
3-
import { logger } from '@sentry/utils';
43

54
import { DEFAULT_FLUSH_MAX_DELAY, DEFAULT_FLUSH_MIN_DELAY, MASK_ALL_TEXT_SELECTOR } from './constants';
65
import { ReplayContainer } from './replay';

packages/replay/test/integration/integrationSettings.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ describe('Integration | integrationSettings', () => {
5353
expect(mockConsole).toBeCalledTimes(1);
5454
});
5555

56-
it('works with defining 0 in integration', async () => {
56+
it('works with defining 0 in integration but logs warnings', async () => {
5757
const { replay } = await mockSdk({
5858
replayOptions: { sessionSampleRate: 0 },
5959
sentryOptions: { replaysSessionSampleRate: undefined },
6060
});
6161

6262
expect(replay.getOptions().sessionSampleRate).toBe(0);
63-
expect(mockConsole).toBeCalledTimes(1);
63+
expect(mockConsole).toBeCalledTimes(2);
6464
});
6565

6666
it('works with defining settings in SDK', async () => {
@@ -70,11 +70,11 @@ describe('Integration | integrationSettings', () => {
7070
expect(mockConsole).toBeCalledTimes(0);
7171
});
7272

73-
it('works with defining 0 in SDK', async () => {
73+
it('works with defining 0 in SDK but a warning is logged', async () => {
7474
const { replay } = await mockSdk({ sentryOptions: { replaysSessionSampleRate: 0 }, replayOptions: {} });
7575

7676
expect(replay.getOptions().sessionSampleRate).toBe(0);
77-
expect(mockConsole).toBeCalledTimes(0);
77+
expect(mockConsole).toBeCalledTimes(1);
7878
});
7979

8080
it('SDK option takes precedence', async () => {
@@ -87,14 +87,14 @@ describe('Integration | integrationSettings', () => {
8787
expect(mockConsole).toBeCalledTimes(1);
8888
});
8989

90-
it('SDK option takes precedence even when 0', async () => {
90+
it('SDK option takes precedence even when 0 but warnings are logged', async () => {
9191
const { replay } = await mockSdk({
9292
sentryOptions: { replaysSessionSampleRate: 0 },
9393
replayOptions: { sessionSampleRate: 0.1 },
9494
});
9595

9696
expect(replay.getOptions().sessionSampleRate).toBe(0);
97-
expect(mockConsole).toBeCalledTimes(1);
97+
expect(mockConsole).toBeCalledTimes(2);
9898
});
9999
});
100100

packages/replay/test/integration/sampling.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ useFakeTimers();
55

66
describe('Integration | sampling', () => {
77
it('does nothing if not sampled', async () => {
8+
const mockConsole = jest.spyOn(console, 'warn').mockImplementation(jest.fn());
89
const { record: mockRecord } = mockRrweb();
910
const { replay } = await mockSdk({
1011
replayOptions: {
@@ -29,5 +30,6 @@ describe('Integration | sampling', () => {
2930
);
3031
expect(mockRecord).not.toHaveBeenCalled();
3132
expect(spyAddListeners).not.toHaveBeenCalled();
33+
expect(mockConsole).toBeCalledTimes(1);
3234
});
3335
});

packages/replay/test/mocks/mockSdk.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export async function mockSdk({ replayOptions, sentryOptions, autoStart = true }
7575
integrations: [replayIntegration],
7676
});
7777

78-
// Instead of `setupOnce`, which is tricky to test, we call this manually here
78+
// Instead of `setupOnce`, which is tricky to test, we call this manually here)
7979
replayIntegration['_setup']();
8080

8181
if (autoStart) {

0 commit comments

Comments
 (0)