Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: simplify test setup #955

Merged
merged 2 commits into from
Jan 11, 2024
Merged
Changes from all commits
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
33 changes: 7 additions & 26 deletions src/__tests__/extensions/replay/sessionrecording.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,13 @@ describe('SessionRecording', () => {
let onFeatureFlagsCallback: ((flags: string[]) => void) | null

beforeEach(() => {
assignableWindow.rrwebRecord = jest.fn()
_addCustomEvent.mockClear()
assignableWindow.rrwebRecord = _addCustomEvent
assignableWindow.rrwebRecord = jest.fn(({ emit }) => {
_emit = emit
return () => {}
})
assignableWindow.rrwebRecord.takeFullSnapshot = jest.fn()
assignableWindow.rrwebRecord.addCustomEvent = _addCustomEvent

assignableWindow.rrwebConsoleRecord = {
getRecordConsolePlugin: jest.fn(),
}
Expand Down Expand Up @@ -219,11 +223,6 @@ describe('SessionRecording', () => {
describe('afterDecideResponse()', () => {
beforeEach(() => {
jest.spyOn(sessionRecording, 'startRecordingIfEnabled')
;(loadScript as any).mockImplementation((_path: any, callback: any) => callback())
assignableWindow.rrwebRecord = jest.fn(({ emit }) => {
_emit = emit
return () => {}
})
})

it('buffers snapshots until decide is received and drops them if disabled', () => {
Expand Down Expand Up @@ -302,17 +301,6 @@ describe('SessionRecording', () => {
})

describe('recording', () => {
beforeEach(() => {
const mockFullSnapshot = jest.fn()
assignableWindow.rrwebRecord = jest.fn(({ emit }) => {
_emit = emit
return () => {}
})
assignableWindow.rrwebRecord.takeFullSnapshot = mockFullSnapshot
assignableWindow.rrwebRecord.addCustomEvent = _addCustomEvent
;(loadScript as any).mockImplementation((_path: any, callback: any) => callback())
})

describe('sampling', () => {
it('does not emit to capture if the sample rate is 0', () => {
sessionRecording.startRecordingIfEnabled()
Expand Down Expand Up @@ -1082,13 +1070,6 @@ describe('SessionRecording', () => {
})

describe('buffering minimum duration', () => {
beforeEach(() => {
assignableWindow.rrwebRecord = jest.fn(({ emit }) => {
_emit = emit
return () => {}
})
})

it('can report no duration when no data', () => {
sessionRecording.startRecordingIfEnabled()
expect(sessionRecording['status']).toBe('buffering')
Expand Down
Loading