Mock & Roll
summary
Practical guide to Sinon.js applied to Ember: defines dummies fakes spies stubs mocks, shows concrete code stubbing window.fetch to resolve with JSON and simulating failures, spying on window.alert to assert arguments, and using a Sinon sandbox (or ember-sinon-qunit) to auto-restore between tests. Demonstrates two ways to stub a shopping-cart service and why stubbing the real service class prevents API drift. Advises to stub only what’s needed, restore sandboxes to avoid leaks and flakiness, and use fakes/mocks for multi-method interactions.
AI-written summary · about
chapters (15)
- 0:00Introduction and background
- 1:05What are test doubles
- 4:56Why stubbing and mocking matter
- 6:39Benefits of unit tests
- 7:00Test doubles in Sinon.js
- 10:31Sinon.js sandbox setup
- 11:38Testing a service with stubs
- 14:23Testing routes with spies
- 15:27Testing controllers and state machines
- 17:52Avoiding API drift in tests
- 18:55Integration testing components
- 20:39Application tests and fakes
- 21:22Best practices for stubs and mocks
- 23:07Invest in unit tests
- 24:30Sinon.js features and conclusion
related talks
45mTrojan War: SinonJS
16mTest as if you're in someone else's shoes
36mMocks, Stubs, and Spies, Oh My!
01h 02mWriting better tests for your JavaScript app
21mTesting against time in JavaScript applications
30mMocks, Stubs, and Spies, Oh My
25mAngular + Jest: Testing Titbits
31mThe Unofficial, Official Ember Testing Guide
