~/talk

Tip Top Testing in JavaScript

Talkat React Day Berlin 2018 · on Friday, 2018-11-30· [testing, javascript]

Practical rules for reliable JS tests: every unit test has setup invocation assertion and tests the public contract not internals, use jest and enzyme (or react testing library) with mocks and spies to isolate calls like Thread events logging or window.location.assign, clear mocks between tests, keep factories (eg test data bot) for realistic fixtures, write failing tests first then red green refactor, and prefer user-visible assertions so refactors don’t break otherwise brittle tests.

AI-written summary · about

  1. 0:00Intro
  2. 0:26Tip top JavaScript Testing @Jack_Franklin
  3. 0:45How to write good tests
  4. 1:29It's important your application code is well written and maintainable.
  5. 2:11Unless you write tests for your tests
  6. 2:24What makes a great unit test?
  7. 4:04Tests should have no external dependencies
  8. 4:32If your tests can fail without any of the code you're testing changing, your test is not properly isolated.
  9. 8:25don't test things twice
  10. 10:57Mocks are an essential tool in a developers testing toolkit
  11. 14:27Avoiding brittle tests
  12. 15:50You should be able to rewrite code without changing all your tests.
  13. 16:14When writing new tests, check that they fail!
  14. 17:02Many test frameworks will pass a test without an assertion!
  15. 17:17If you write a test and it passes first time, try to break it
  16. 17:33small feedback loops
  17. 19:082. Fix the bug without changing the test
  18. 19:34Confident refactoring
  19. 21:11Testing React
  20. 22:42A React component's contract is what it shows to the user.
  21. 25:05Remember what makes a good test: setup, invocation, assertion
  22. 25:19When it comes to React, the framework doesn't matter if you test like a user
~/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.