Zebra Codes

How To Mock Overloaded Functions in Jest and TypeScript

10th June, 2026

To provide an implementation of a mock function you must know its function signature, but whichever one of the overloads you choose, TypeScript will give you an error. The fix is actually quite simple: use the signature of the actual implementation, not the overloads.

Read More >

How to Mock a Library with NodeJS, TypeScript, and Jest

18th September, 2023

The ability to provide a mock implementation of functionality is essential to unit testing, however the method for doing so with Jest and TypeScript is not well documented. This tutorial aims to elucidate the method for mocking a JavaScript library that is loaded into your TypeScript project. This is demonstrated with the ws WebSocket library but applies equally to any library, including built-in NodeJS modules.

Read More >