Skip to content

Add unit tests #83

Open
Open
@quinton-ashley

Description

@quinton-ashley

It'd be nice to have new unit tests for q5, especially for its exclusive functions. This is something I'd like to delegate to the community though. Let me know if you're interested!

The main benefit of unit tests is providing a quick way to ensure that a software library is functioning correctly after making updates to it.

See p5's page on unit testing: https://p5js.org/contribute/unit_testing/

Why not use p5's unit tests?

I was able to fork the test folder from p5.js and ran them with q5.js.

I liked the idea that these were browser based mocha tests, however since they run asynchronously I found that debugging them is a nightmare. That's pretty bad, since the whole point of unit tests is to make identifying issues easier. Also the quality of the tests is quite mixed, several of them reference internal private variables which makes them useless for our purposes. The visual WebGL tests seem great, but of course q5 doesn't have WebGL mode.

This still proved to be a valuable exercise though, since I did find and fix 4 bugs in q5. Yet, I'm not going to include p5's tests in the q5 repo as I had originally planned. If you're interested, download this, put it in the q5 folder, and open /p5-tests/test.html in a live server to see the results: p5-tests.zip

q5 unit testing

q5-server.js enables q5 to run with node.js, bun, or deno.

https://bun.sh/docs/cli/test
https://jestjs.io/docs/expect

Current tests and more info can be found in the test folder.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Maybe

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions