Skip to content

feat: add minimal YAML parser for aria snapshot templates#13

Merged
hi-ogawa merged 12 commits intovitest-dev:masterfrom
hi-ogawa:feat/yaml-minimal-parser
Mar 19, 2026
Merged

feat: add minimal YAML parser for aria snapshot templates#13
hi-ogawa merged 12 commits intovitest-dev:masterfrom
hi-ogawa:feat/yaml-minimal-parser

Conversation

@hi-ogawa
Copy link
Copy Markdown
Collaborator

@hi-ogawa hi-ogawa commented Mar 19, 2026

AI port of minimal yaml parser to support aria snapshot needs. Got significant size decrease:

yaml package src/aria/yaml.ts reduction
Source lines 10,281 605 94%
Source size 308 KB 18 KB 94%
Minified 97 KB (before) 5.7 KB (after) 94%

For comparison, current @vitest/browser's expect-element.js is 23kb.

hi-ogawa and others added 6 commits March 19, 2026 14:32
Self-contained parser (~600 lines) that supports the YAML subset
needed by ariaSnapshot.ts: sequences, maps, scalars (plain, quoted,
numeric, boolean), and indentation-based nesting. Includes unit tests
(73 cases) ported from vendor/yaml/tests/ and covering every YAML
shape used in test/aria.test.ts.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@hi-ogawa hi-ogawa marked this pull request as ready for review March 19, 2026 06:29
Copy link
Copy Markdown
Member

@sheremet-va sheremet-va left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't notice how big it was

@hi-ogawa
Copy link
Copy Markdown
Collaborator Author

Okay, AI said ported/forked but it looks like the implementation is done from scratch 🙃 The code looks sound and a way clearer than original, but let me spend a bit for review.

@hi-ogawa hi-ogawa marked this pull request as draft March 19, 2026 08:13
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 19, 2026

npm i https://pkg.pr.new/ivya@13

commit: afc8374

@hi-ogawa
Copy link
Copy Markdown
Collaborator Author

I added the document yaml.md to make AI convince me hand-rolled yaml parser is legit. The implementation differs from the original yaml package significantly, but I'm convinced the approach is sound and reviewed the full idea (though not line-by-line verification nor manual human refactor to remove potential AI slop).

Ideally, we should have better yaml parsing test coverage, but since we own the aria yaml generation side, adopting this minimal implementation should be good enough.

@hi-ogawa hi-ogawa marked this pull request as ready for review March 19, 2026 11:06
@hi-ogawa hi-ogawa merged commit 68f8735 into vitest-dev:master Mar 19, 2026
6 checks passed
@hi-ogawa hi-ogawa deleted the feat/yaml-minimal-parser branch March 23, 2026 00:04
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.

2 participants