: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 { parseJsonObject } from './utils'
describe('dataset JSON utils', () => {
it.each([
['an array', '[1, 2]'],
['a number', '5'],
['null', 'null'],
])('rejects %s where a JSON object is required', (_name, value) => {
expect(() => parseJsonObject(value)).toThrow(TypeError)
})
it.each([
['a populated object', '{"key": "value"}', { key: 'value' }],
['an empty object', '{}', {}],
['an empty string', '', {}],
['null input', null, {}],
])('parses %s', (_name, value, expected) => {
expect(parseJsonObject(value)).toEqual(expected)
})
})