~/talk

Component testing with Vitest

Talkat Vue.js Nation 2023 · 2023-01-25..01-26· [testing, javascript]
slides:none on file

Shows using Vitest + Vue Test Utils to test a small movie-search component split into two composables: useMovies (fetches data) and useSearch (filters by term). Tests mock network calls with mocked global.fetch with vi.fn, use flushPromises and createApp to mount and unmount, and one composable test fits in 52-line composable test. Migration from Jest keeps ~90% of syntax, coverage uses vitest-coverage/Istanbul and the demo project reports ~50% while team targets 90% coverage target.

AI-written summary · about

  1. 0:00Introduction
  2. 0:44Testing matters and pyramid
  3. 4:20Frustrations with tests
  4. 6:12Planning effective testing
  5. 8:41Vitest for component testing
  6. 12:41Demo: Movie search test
  7. 15:30Testing composable functions
  8. 18:06Mocking async data fetching
  9. 20:16Sanity testing UI
  10. 22:46Generating test coverage
  11. 24:12Maintainable test practices
  12. 25:39Accessibility in unit tests
  13. 26:40Q&A
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.