:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { FetchResponse } from '~/common/utils/request'
jest.mock('~/common/utils/request', () => {
return {
fetch: jest.fn(() =>
Promise.resolve({
status: 200,
headers: {},
json: () => Promise.resolve({ success: true }),
text: () => Promise.resolve(JSON.stringify({ success: true })),
} as FetchResponse)
),
internalFetch: jest.fn(() =>
Promise.resolve({
status: 200,
headers: {},
json: () => Promise.resolve({}),
text: () => Promise.resolve(''),
} as FetchResponse)
),
closeSharedAgents: jest.fn(() => Promise.resolve()),
}
})
export const mockFetch: jest.Mock<Promise<FetchResponse>> = require('~/common/utils/request').fetch
export const mockInternalFetch: jest.Mock<Promise<FetchResponse>> = require('~/common/utils/request').internalFetch