JS Unit Testing Good Practices & Horrible Mistakes
summary
Argues that unit tests must be trustworthy, maintainable, readable and gives concrete rules: treat a unit as a unit of work, not a single method; keep mock objects to about 5% mocks of tests (only for fire‑and‑forget external calls) and prefer stubs otherwise; separate fast in‑memory unit suites from slower integration tests into a safe green zone project; avoid logic or shared mutable fixtures in tests; show real failures in jQuery/OpenLayers/QUnit examples and recommend one mock per test and clearer describe/it nesting.
AI-written summary · about
chapters (21)
- 0:00Introduction
- 1:30Horrible Mistakes
- 5:30Test Reviews
- 9:40Mock Objects
- 13:10Differentiation
- 14:40State Based
- 16:33Integration Tests
- 18:23OpenLayer
- 20:01jQuery
- 20:24jQuery bugs
- 21:25Trust problem
- 25:07Forced assertion counts
- 27:59Readability
- 30:42Comments
- 31:44Naming
- 33:46The Test of Doom
- 35:34Backbone
- 36:33Jasmine
- 38:24Knockout
- 39:34Setup Methods
- 41:12Test Multiple Methods
related talks
43mUnselfish Testing
39mTen things you heard about testing that might be wrong
55mUnit Testing Like a Pro - Towards a Testable Design
37mClean Test Code
59mC++ Unit testing - the good, the bad & the ugly
56mIf You Won't Test Your Code, Who Will?
01h 46mHow Java developers should test their applications (RU)
45mWriting Tests That Don't Suck: TDD in JavaScript
