Skip to content

test(svg): add unit test suite for native p5.svg module - #9181

Closed
VANSH3104 wants to merge 15 commits into
processing:mainfrom
VANSH3104:test/svg-unit-tests
Closed

VANSH3104 wants to merge 15 commits into
processing:mainfrom
VANSH3104:test/svg-unit-tests

Conversation

@VANSH3104

Copy link
Copy Markdown
Member

Addresses #4630

Note: This work is part of the GSoC 2026 development for native SVG support in p5.js and is stacked on top of #9123 (feat/svg-integration). This PR contains only the unit test suite for the native SVG module to keep the review modular and focused.

The branch is based directly on feat/svg-integration. The SVG integration commits are therefore included in the current GitHub diff, but they are already covered by #9123 and should disappear from this PR once #9123 is merged.

Changes

Adds a comprehensive unit test suite for the native p5.svg feature module under test/unit/svg/.

  • test/unit/svg/svg_recorder.js: Tests ShapeRecorder AST node construction (ScopeNode, ShapeNode, BackgroundNode, ImageNode, and ClearNode), scope boundaries, method restoration on stop(), and TransformStack DOMMatrix operations (translate, rotate, and scale).

  • test/unit/svg/svg_export.js: Tests SVGVisitor serialization of p5.js drawing commands to SVG elements (<rect>, <circle>, <ellipse>, <line>, <polygon>, and <path>), color and opacity handling (fill-opacity, stroke-opacity), stroke styling, and nested <g transform="matrix(...)"> groups.

  • test/unit/svg/svg_import.js: Tests StyleResolver CSS/attribute precedence and inheritance, display/visibility filtering, element visitors, SVG path parsing (M, L, H, V, C, S, Q, T, A, and Z), scientific notation, and <defs>/<use> symbol reuse.

  • test/unit/svg/p5.svg.js: Tests the public APIs on p5.prototype (createShape, buildShape, createSVG, loadSVG, shape, getSVG, and saveSVG), canvas replay positioning and alignments (CORNER, CENTER, VIEWBOX), automatic frame export lifecycle hooks (predraw and postdraw), and FES experimental warning logging.

PR Checklist

@p5-bot

p5-bot Bot commented Sep 16, 2026

Copy link
Copy Markdown

Continuous Release

CDN link

Published Packages

Commit hash: f70fbb2

Previous deployments

This is an automated message.

@VANSH3104

Copy link
Copy Markdown
Member Author

It looks like stacked PRs aren't working cleanly in this setup since feat/svg-integration exists only in my fork. I'll keep this PR as-is for now and clean up the branch history/diff once the existing SVG integration PR is merged.

@VANSH3104
VANSH3104 marked this pull request as draft September 16, 2026 08:59
@VANSH3104

Copy link
Copy Markdown
Member Author

I’ve added these tests to the #9123. There’s no need for this PR now, so I’m closing it.

@VANSH3104 VANSH3104 closed this Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant