Skip to content

: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.

1003 B
Raw Blame
import { isWebAuthnCancellation } from './utils'

describe('isWebAuthnCancellation', () => {
    it.each([
        ['plain NotAllowedError', { name: 'NotAllowedError' }, true],
        ['plain AbortError', { name: 'AbortError' }, true],
        ['DOMException-like NotAllowedError', new DOMException('cancelled', 'NotAllowedError'), true],
        ['nested SimpleWebAuthn-style cancellation', { error: { name: 'NotAllowedError' } }, true],
        ['nested SimpleWebAuthn-style abort', { error: { name: 'AbortError' } }, true],
        ['unrelated error name', { name: 'InvalidStateError' }, false],
        ['nested unrelated error name', { error: { name: 'InvalidStateError' } }, false],
        ['plain Error', new Error('boom'), false],
        ['string', 'NotAllowedError', false],
        ['null', null, false],
        ['undefined', undefined, false],
    ])('returns the right answer for %s', (_label, input, expected) => {
        expect(isWebAuthnCancellation(input)).toBe(expected)
    })
})