Skip to content

Add unit tests #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
quinton-ashley opened this issue Nov 17, 2024 · 0 comments
Open

Add unit tests #83

quinton-ashley opened this issue Nov 17, 2024 · 0 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@quinton-ashley
Copy link
Collaborator

quinton-ashley commented Nov 17, 2024

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.

@quinton-ashley quinton-ashley added help wanted Extra attention is needed good first issue Good for newcomers labels Nov 18, 2024
@quinton-ashley quinton-ashley changed the title Add tests for q5.js to ensure functionality Add unit tests for q5.js to ensure functionality Nov 18, 2024
@quinton-ashley quinton-ashley moved this to Todo in q5 Dec 9, 2024
@quinton-ashley quinton-ashley added this to q5 Dec 9, 2024
@quinton-ashley quinton-ashley moved this from Todo to Maybe in q5 Dec 9, 2024
@quinton-ashley quinton-ashley pinned this issue May 7, 2025
@quinton-ashley quinton-ashley changed the title Add unit tests for q5.js to ensure functionality Add unit tests May 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
Status: Maybe
Development

No branches or pull requests

1 participant