~/talk

Mock Me — Using Jest’s Mocks for Easier Unit Tests

Talkat UtahJS Conf 2019 · on Friday, 2019-09-20· [testing, javascript]
slides:none on file

Jest’s mock primitives let tests avoid real APIs by replacing specific functions or modules: use jest.fn to wrap a function or promise (example returns the pig nose emoji), use jest.mock on an API file or npm dependency (Axios) and set mockReturnValue for resolved data, or use mockImplementation to fake callback APIs like fs so no disk or DB is required. Tests run fast and deterministically in CI while asserting how code handles the mocked responses.

AI-written summary · about

  1. 0:00Intro
  2. 0:49Overview
  3. 9:12Other Uses
~/search
type to search 8,222 conferences, 162,397 speakers and 219,688 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
← →
on a talk: 5 seconds back / forward
0–9
on a talk: jump to 0%–90% of the recording
?
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.