P5.js unit testing with Jest

Have a look at these two links:

color() not working in on-demand global mode outside setup()/draw() · Issue #1983 · processing/p5.js · GitHub
learn | p5.js

The first one could provide some insight which I think it applies here.
The second one is using mocha/chaj. Not sure if this would apply to jest but they do work with colors there. I think their approach is based on mocks.

Kf