-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: only wrap once when patching (#1245)
* fix: only wrap once when patching * only init once * fix * we might actually want to wrap twice e.g. trace headers
- Loading branch information
1 parent
b4b0050
commit 554f061
Showing
2 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
src/__tests__/extensions/replay/rrweb-plugins/patch.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { patch } from '../../../../extensions/replay/rrweb-plugins/patch' | ||
|
||
const fakeWindow = { | ||
fakeFetch: () => {}, | ||
} | ||
|
||
// JS-DOM doesn't have fetch and its fake XHR doesn't work with our patch, | ||
// so we can't test them directly | ||
describe('patch', () => { | ||
it('marks a function as wrapped', () => { | ||
patch(fakeWindow, 'fakeFetch', () => () => {}) | ||
// eslint-disable-next-line compat/compat | ||
expect((fakeWindow.fakeFetch as any).__posthog_wrapped__).toBe(true) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters