[TS] Migrate tests to .tsx
Author: alexmirringtonCreated Sep 19, 2021Updated Sep 23, 2026
Labelshelp wantedgood first issuetypescript
Overview and Motivation
This is a ticket to aid the migration of *.js tests to *.tsx. The general motivation here is to improve TypeScript support in Grommet so that when type checks fail, so do unit tests. For more details about why and how we are doing this, please refer to the related Issues and PRs below.
Related Issues and PRs
Addition of TS unit testing support:
- Issue: #5111
- PR: #5589
Contributing
Since we have close to 75 components now and the tests for each range from simple to quite complex, It makes sense to migrate a single component at a time to *.tsx files, taking a test-driven development (TDD) approach.
- Pick a single component at a time to work on test migrations for.
- Create a draft PR while you work on the components tests. Mention this issue in the PR to make sure multiple people don't double up on a single component.
- Rename the tests for that component from
*-test.jsto*-test.tsx - Rename the
*-test.js.snapfiles for that component to*-test.tsx.snap - Run the test suite for that component with
yarn test. No test snapshots should fail, but some tests might fail due to type check failures. - If migrating tests causes only a few Typescript errors (e.g. missing field on prop types), feel free to fix those issues in the same PR as the test migration including the test failure and an explanation about how the changes fix the test failure. If there are a lot of new errors, create separate issues for each error and fix them in a separate PR. Update the test migration branch with these changes until the tests pass.
Roadmap
Test migration completed for:
- Accordion #5609
- AccordionPanel #5610
- Anchor #5600
- Avatar #5602
- Box #5611
- Button #5645
- Calendar #5656
- Card #5612
-
CardBodyNo tests to migrate -
CardFooterNo tests to migrate -
CardHeaderNo tests to migrate - Carousel #5643
- Chart https://github.com/grommet/grommet/pull/6192
- CheckBox #5644
- CheckBoxGroup #5653
- Clock #5655
- Collapsible #5686
- DataChart #6377
- DataTable
- DateInput #5696
- Diagram #5759
- Distribution #6378
- Drop #5714
- DropButton #6379
- FileInput #5696
- Footer #5703
- Form
- FormField
- Grid
- Grommet
- Header #5701
- Heading #5723
- Image #5704
- InfiniteScroll #5718
- Keyboard #5748
- Layer
- List
- Main #5685
- Markdown
- MaskedInput
- Menu
- Meter #5690
- NameValueList #5626
- NameValuePair #5626
- Nav #5719
- Notification
- Page #5960
-
PageContentNo tests to migrate - PageHeader #6071
- Pagination #5722
- Paragraph #5724
- RadioButton #5720
- RadioButtonGroup #5721
- RangeInput #5690
- RangeSelector
-
RoutedAnchorDeprecated -
RoutedButtonDeprecated - Select
- SelectMultiple #6725
- Sidebar #6382
-
SkipLinkNo tests to migrate - SkipLinks
-
SkipLinkTargetNo tests to migrate - Spinner #5702
- Stack #5743
-
TabNo tests to migrate - Table #5746
-
TableBodyNo tests to migrate -
TableCellNo tests to migrate -
TableFooterNo tests to migrate -
TableHeaderNo tests to migrate -
TableRowNo tests to migrate - Tabs #5659 #5732
- Tag #5778
- Text #5725
- TextArea #6381
- TextInput #5749
- Tip #5763
- Video #6380
- WorldMap #5654
Source: grommet/grommet