1
0 Comments

Deterministic rendering & end-to-end tests oh my

Work continues apace on Jsfxr Pro. After a year of development I am down to the polishing tasks and getting ready for launch. \o/

Yesterday I added more end-to-end tests, fixed a bug, and modified the sound effect rendering engine to make sure it always returns the exact same sound deterministically.

Today I continued work on the e2e tests to get ready for testing the sync code. I also warmed up the email server with the help of a few friends and delivery was 100%.

Deterministic rendering

The underlying library Jsfxr has long had this problem where it uses Math.random() when rendering any sound effect built on noise (as opposed to a e.g. a squarewave). What this means is each time you render a noise based sound effect it comes out slightly different.

I fixed this using David Bau's wonderful seedrandom.js module. Now the (render-sound sound) function replaces the global Math.random() function temporarily with a deterministic one seeded on the sound effect's b58 representation, which is unique to each sound.

End to end tests.

The Jsfxr Pro codebase has both unit tests and end-to-end tests. In the past I have not been that big on tests but they have really been handy on this project. They help me make sure any datastructure changes are watertight so nobody loses any data. Already the tests have saved my bacon several times when a change in one part of the app has broken something in the other part.

I'm using Microsoft's Playwright framework to implement the end-to-end tests. It's neat watching them run:

, Founder of Icon for Jsfxr Pro
Jsfxr Pro
on November 11, 2022