~/talk

Seven ways to make your Vue component tests better

Talkat Vuejs Amsterdam 2024 · 2024-02-28..02-29· [testing]
slides:none on file

Seven concrete rules and a live-coded login form that goes through default, loading, success and error states determine whether the advice is useful. It uses Vitest and Vue Test Utils, prefers shallowMount and mount difference for unit vs integration checks, recommends data-test-id helpers instead of querying raw elements, and insists on simulating user input with setValue plus nextTick. Tests must assert rendered HTML, emitted events or side effects and avoid inspecting component internals.

AI-written summary · about

  1. 0:00Introduction
  2. 1:20Good component tests
  3. 2:46Unit testing Vue components
  4. 4:33Live login form coding
  5. 6:00Testing component states
  6. 7:24Brittle tests fix
  7. 9:30Helper functions for tests
  8. 10:35Test output not internals
  9. 13:06Child components black box
  10. 17:36Simulating user input
  11. 20:30Async operations handling
  12. 21:57Final tips
~/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.