: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 { expectLogic } from 'kea-test-utils'
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
import { actionsModel } from './actionsModel'
describe('actionsModel', () => {
let requestCount: number
let logic: ReturnType<typeof actionsModel.build>
beforeEach(() => {
requestCount = 0
useMocks({
get: {
'/api/projects/:team/actions/': () => {
requestCount++
return [200, { results: [], count: 0 }]
},
},
})
initKeaTests()
logic = actionsModel.build()
})
it('reuses actions after a consumer remounts', async () => {
logic.mount()
await expectLogic(logic).toDispatchActions(['loadActionsSuccess'])
logic.unmount()
expect(logic.isMounted()).toBe(true)
logic.mount()
await new Promise((resolve) => setTimeout(resolve, 0))
expect(requestCount).toBe(1)
})
})