MasterKale / SimpleWebAuthn

WebAuthn, Simplified. A collection of TypeScript-first libraries for simpler WebAuthn integration. Supports modern browsers, Node, Deno, and more.
https://simplewebauthn.dev
MIT License
1.63k stars 138 forks source link

fix/browser-tests #194

Closed MasterKale closed 2 years ago

MasterKale commented 2 years ago

Browser tests were kinda flaky because I misunderstood the nature of WebAuthn's errors (they're not discrete subclasses, but simply Error subclasses with custom names), and TypeScript wasn't liking the way I tried to declare the various error subclasses globally in the Jest environment. Try as I might, I think I'm running into some monorepo limitations of declaring custom types specifically for testing. I would be happy to end up wrong about this...

In lieu of globally defining unique Error subclasses, I've instead migrated to a new helper method in helpers/__jest__/ that can be imported like normal to easily generate these subclasses. TypeScript has no problem with this when running either test or test:watch scripts, and so this should resolve these tests working fine in CI but misbehaving during local development.