: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
export class AsymmetricMatcher<T> {
protected sample: T
$$typeof: symbol
inverse?: boolean
constructor(sample: T) {
this.$$typeof = Symbol.for('jest.asymmetricMatcher')
this.sample = sample
}
}
class Truth extends AsymmetricMatcher<(value: any) => boolean> {
constructor(sample: (value: any) => boolean, inverse: boolean = false) {
if (typeof sample !== 'function') {
throw new Error('Expected is not a function')
}
super(sample)
this.inverse = inverse
}
asymmetricMatch(other: any): boolean {
const result = this.sample(other)
return this.inverse ? !result : result
}
override toString(): string {
return `${this.inverse ? 'Not' : ''}Truth`
}
toAsymmetricMatcher(): string {
return `Truth<${this.sample}>`
}
}
export const truth = (sample: (value: any) => boolean): Truth => new Truth(sample)
export function partial<T>(objectOrArray: T): T {
if (Array.isArray(objectOrArray)) {
return expect.arrayContaining(objectOrArray)
} else {
return expect.objectContaining(objectOrArray)
}
}