Skip to content
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

Add unit tests for q5.js to ensure functionality #83

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

Add unit tests for q5.js to ensure functionality #83

quinton-ashley opened this issue Nov 17, 2024 · 3 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 debugging easier. Also the quality of the tests is quite mixed, several of them reference internal private variables (don't do that!) 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. 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.

An example test can be found in tests/core.test.js

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

@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
@atmajaa
Copy link

atmajaa commented Jan 4, 2025

Hey @quinton-ashley can I work on this issue?

@quinton-ashley
Copy link
Collaborator Author

@atmajaa Yes!

I would recommend using Node.js for the tests, since it's easy to debug within Visual Studio Code.

You can also make visual tests using the skia canvas npm package.

I'd start with tests of q5's core module.

If you need any help getting started let me know. I can even meet with you if you'd like.

@atmajaa
Copy link

atmajaa commented Jan 4, 2025

@quinton-ashley Sure! Thanks for your response.

I'll let you know if I need any help!

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

2 participants