Vue 3 Pagination Synced to URL Query Parameters, With TypeScript and Behavior-Focused Tests

The article describes how pagination in data-heavy interfaces can be kept in sync with the browser URL by storing the active page in a query parameter, enabling shareable links, bookmarks, and working back/forward navigation. The author migrated the shared RoutePagination component and its unit tests to TypeScript as part of GitLab's Contributors Platform work (MR !3200). The component's two-way binding was modernized using Vue 3.4's defineModel() macro, and unawaited router navigation calls were marked with void to satisfy linting rules. The test suite was also refactored away from inspecting internal component state via wrapper.vm, instead asserting on child props, emitted events, and the current route query. The author argues this black-box approach yields more robust tests that do not break when internal variable names change.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in