Skip to content

fix: support empty template in parseAriaTemplate#17

Merged
hi-ogawa merged 4 commits into
vitest-dev:masterfrom
mayrang:fix/empty-template-support
Apr 27, 2026
Merged

fix: support empty template in parseAriaTemplate#17
hi-ogawa merged 4 commits into
vitest-dev:masterfrom
mayrang:fix/empty-template-support

Conversation

@mayrang

@mayrang mayrang commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Closes #16

Problem

parseAriaTemplate('') throws "Aria snapshot must be a YAML sequence" because
yaml.parseDocument('') returns contents: null, which is not a YAMLSeq.

Fix

Add an early return for null contents — return an empty fragment node
{ kind: 'role', role: 'fragment' } with no errors. This also simplifies the
existing error path since yamlDoc.contents is guaranteed non-null after the
new guard, removing the ternary fallback for the range.

Context

This unblocks the vitest-side fix for vitest-dev/vitest#10158
(vitest-dev/vitest#10188), which correctly distinguishes empty string from
undefined in domain snapshots but needs ivya to handle empty templates.

Test

Updated the existing empty input test case in test/aria.test.ts to expect
an empty fragment instead of an error.

@pkg-pr-new

pkg-pr-new Bot commented Apr 27, 2026

Copy link
Copy Markdown
npm i https://pkg.pr.new/ivya@17

commit: 01626de

@hi-ogawa hi-ogawa left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks. Adjusted some test cases with more coverage.

@hi-ogawa hi-ogawa merged commit 1c16a6a into vitest-dev:master Apr 27, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants