Skip to content

Update API to align with vitest-browser ecosystem#18

Merged
shairez merged 1 commit into
mainfrom
pr-api-alignment
Jan 15, 2026
Merged

Update API to align with vitest-browser ecosystem#18
shairez merged 1 commit into
mainfrom
pr-api-alignment

Conversation

@shairez
Copy link
Copy Markdown
Contributor

@shairez shairez commented Jan 14, 2026

This PR enhances the testing API with updated naming conventions and new features for querying elements.

✨ New Features

  • Render Result with Locator Methods: The render result now includes built-in locator methods (getByText, getByRole, getByLabelText, etc.) that query from baseElement (defaults to document.body)

  • Container Element: New container property provides direct access to the component's host element (shortcut for fixture.nativeElement)

  • Base Element Configuration: New baseElement option allows customizing the root element for queries, essential for testing components with portals/overlays

🔄 Breaking Changes (with deprecation period)

  • locator replaces component - Aligns with vitest-browser-vue and other libraries in the ecosystem

    • Old: const { component } = await render(...)
    • New: const { locator } = await render(...)
    • ⚠️ component is deprecated but still works for backward compatibility
  • ComponentRenderOptions replaces RenderConfig type - More descriptive naming

    • ⚠️ RenderConfig is deprecated but still works for backward compatibility

📚 Documentation

  • Comprehensive documentation updates with clear examples
  • Explains when to use locator vs screen query patterns
  • Examples updated to use the screen pattern where appropriate

Migration: All deprecated properties continue to work. Update at your convenience - simply rename componentlocator and RenderConfigComponentRenderOptions.

@shairez shairez changed the title feat: improve API ergonomics and align with vitest-browser ecosystem feat: update API to align with vitest-browser ecosystem Jan 14, 2026
@shairez shairez changed the title feat: update API to align with vitest-browser ecosystem Update API to align with vitest-browser ecosystem Jan 14, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jan 14, 2026

Open in StackBlitz

npm i https://pkg.pr.new/vitest-community/vitest-browser-angular@18

commit: 9ac828a

Comment thread README.md Outdated
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.

Looks good, just a small note

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.

Looks perfect, thank you!

@shairez shairez merged commit 9357a90 into main Jan 15, 2026
3 checks passed
@shairez shairez deleted the pr-api-alignment branch January 15, 2026 09:45
@github-actions github-actions Bot mentioned this pull request Jan 15, 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.

2 participants