Jest, nUnit and other unit test frameworks are an essential part of the modern arsenal of software engineering tools. So when I recently started a retro-computing project, which involves writing Z80 assembly code for the ZX Spectrum, an unfamiliar environment, where the smallest mistake can cause a crash, I did the obvious thing, and set up unit testing for the assembly code… using TypeScript.
The previous blog post (Part I) covered my chosen build pipeline for this modern old-fashioned ZX Spectrum ROM development. This post delves into how I implemented a modern unit-testing approach for code on 40-year-old machine, using Deno, TypeScript and WASM.
![[Code listing showing some Z80 unit tests… passing.]](https://dysphoria.net/wp-content/blogs.dir/1/files/2025/05/Screenshot-2025-05-17-at-16.19.58.png)
TL;DR
It is possible to use the core emulation engine from a Spectrum emulator, running ‘headless’ (without its UI), to run segments of target Z80 machine code in an isolated, deterministic, and reproducible environment.
If we select an emulator written in web technologies, it is possible to call from a standard TypeScript or JavaScript unit test framework. And it turns out that Deno’s built-in standard test framework is a very low-friction testing framework to call from TypeScript.
This is my story…
Continue reading