Add unit test coverage for WebGL text rendering
Topic
Description
WebGL text rendering currently has minimal unit test coverage, despite being a core and complex feature. This makes regressions harder to catch and increases risk when modifying WebGL text-related code.
Current State
src/webgl/text.jscontains the WebGL text implementation- Existing WebGL unit tests do not cover text rendering behavior
- No tests currently verify basic text rendering, fill behavior, or text sizing in WEBGL mode
Proposed Improvement
Add initial unit tests to verify:
- Text renders with a loaded OpenType/TrueType font in WEBGL
noFill()prevents text rendering- Fill color behavior is consistent between 2D and WEBGL
textSize()affects rendered output in WEBGL
Why This Matters
Improved test coverage will:
- Increase confidence in the WebGL text rendering pipeline
- Reduce risk when fixing TODOs or refactoring WebGL text code
- Help ensure consistency between 2D and WEBGL text behavior
Scope
This issue focuses on tests only and does not propose changes to existing implementation code.
I have opened a PR that addresses this issue: #8437
Hi, thanks for your interest! We actually do have significant test coverage now in the dev-2.0 branch for p5 2.x in the visual tests folder: https://github.com/processing/p5.js/blob/dev-2.0/test/unit/visual/cases/typography.js
In general, unit tests probably shouldn't be checking the pixels array because it's pretty hard for humans to understand what's going on, and there are often ways for false positives to not trigger a failure, so we use the visual test system instead. More info: https://github.com/processing/p5.js/blob/dev-2.0/contributor_docs/unit_testing.md#visual-tests-in-p5js-20
We do have an earlier version of this system in the 1.x main branch, but also 1.x is currently just accepting bug fixes, and 2.x will become the default later this year, so for now I'm going to close this PR/issue.
Thanks for the clarification and for the links! That makes sense. I’ll take a look at the visual test system in dev-2.0 and keep this in mind for future contributions.