~/talk

Unit testing a Vuex store

Talkat Vue Fes Japan 2018 · on Saturday, 2018-11-03· [testing, frontend-architecture]
slides:none on file

Three approaches: no tests for tiny projects, unit-test each part with Jest (mutations called with a fake state, getters called with a fake state, actions mocked) and test a whole store instance. Uses jest.mock/jest.fn to stub the fetchData API so the fetchItems action commits setItems with mocked items, and uses createLocalVue plus a createStoreConfig function so each test gets fresh state. Example assertion: displayItems returns items 20–39 when page = 2 out of 42.

AI-written summary · about

  1. 0:00Start
  2. 1:20write a unit test using a framework
  3. 7:06test each of the store parts
  4. 7:17write unit tests for each of these functions
  5. 8:43write unit tests for a simple mutation
  6. 18:25install the us on a local view constructor
  7. 23:10refactor without updating your tests
  8. 23:55split up your unit tests and your end-to-end tests
~/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.