When unit testing WebGL/Three.js code, how do you do it? Are you using a test framework or writing your own tests without a framework? I tried using Jest, but it causes all kinds of headaches and is extremely slow to run. Additionally, my library heavily relies on ‘three/node’ and Jest seems to have a problem with it.
Anyone have any tips on how to write unit test for three.js code?
Example with Tape here:
If you need to instantiate renderers, controls, or other things that rely on the DOM, it gets a bit more complicated and you may want additional tools like jsdom (to mock the browser environment in Node.js) or sinon (to stub out methods on objects).
I’d try to avoid running actual WebGL in tests, unless it’s absolutely essential to what you’re testing. Tools like Cypress can help with screenshot tests, but require more work than traditional unit tests.