A comprehensive interactive guide demonstrating how to test shadcn/ui components using TWD (Testing While Developing).
This repository showcases testing patterns for 22+ shadcn/ui components. Each component page displays:
- Live Component Preview – Interactive demonstration
- Component Code – Reusable implementation example
- TWD Test Code – Complete test patterns with recommended selectors
Perfect for developers learning how to test shadcn/ui components effectively.
- 21 Fully Documented Components with TWD tests
- 2 WIP Placeholder Pages (Range Calendar, Data Table)
- Node.js 18+
- npm or yarn
npm installnpm run devOpens at http://localhost:5173 with TWD test sidebar enabled in dev mode.
npm run buildOptimized production build ready for GitHub Pages or any static host.
- Accordion
- Alert Dialog
- Breadcrumb
- Button
- Calendar
- Checkbox
- Collapsible
- Command
- Context Menu
- Dialog
- Drawer
- Dropdown Menu
- Pagination
- Popover
- Radio Group
- Select
- Slider
- Sonner
- Switch
- Table (Basic)
- Tabs
- Tooltip
- Range Calendar
- Data Table (TanStack)
screenDom – Standard DOM queries
await screenDom.findByRole('button', { name: 'Click me' });screenDomGlobal – Portal-rendered elements (dialogs, popovers, tooltips)
await screenDomGlobal.findByText('Tooltip content');Assertions
twd.should(element, 'be.visible');
expect(element).eql(null); // For non-existence- Tables: Use
role:'table',columnheader, text content for rows - Portals: Use
screenDomGlobalfor dialogs, drawers, popovers, tooltips - Forms: Use
findByLabelText(),findByRole()for inputs - Navigation: Use link text and button names
MIT
Happy TWD Testing! 🎉