: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 { runningExperimentId } from './runningExperimentId'
describe('runningExperimentId', () => {
it.each([
{ case: 'no experiment', metadata: null, expected: null },
{
case: 'a draft or completed experiment',
metadata: [{ id: 7, name: 'A', is_running: false }],
expected: null,
},
{
case: 'a running experiment among others',
metadata: [
{ id: 7, name: 'A', is_running: false },
{ id: 8, name: 'B', is_running: true },
],
expected: 8,
},
])('is $expected for a flag with $case', ({ metadata, expected }) => {
expect(runningExperimentId({ experiment_set_metadata: metadata })).toBe(expected)
})
})