0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-11-24 18:07:17 +01:00
posthog/jest.setup.ts
Paul D'Ambra f236e2513a
fix: cannot read body twice (#19750)
* fix: cannot read body twice

* only read it once no matter what

* fix tests but yucky

* nicer

* does this mean backend checks won't incorrectly run

* comment
2024-01-15 07:44:43 +00:00

14 lines
443 B
TypeScript

import 'whatwg-fetch'
import 'jest-canvas-mock'
import { TextEncoder, TextDecoder } from 'util'
// Jest/JSDom don't know about TextEncoder but the browsers we support do
// https://github.com/jsdom/jsdom/issues/2524
global.TextDecoder = TextDecoder
global.TextEncoder = TextEncoder
window.scrollTo = jest.fn()
window.matchMedia = jest.fn(
() => ({ matches: false, addListener: jest.fn(), removeListener: jest.fn() } as MediaQueryList)
)