Testing with MockStore in NgRx 9
summary
Shows concrete migration from importing StoreModule to using provideMockStore (NgRx v7) and mocking selectors with overrideSelector (v8) so tests update state via mockStore.setState and force emissions with mockStore.refreshState plus fixture.detectChanges. Demonstrates inspecting dispatched actions through the scannedActions observable. Examples use real code paths, note gotchas (mock selector updates don’t auto-emit), and present a standalone npm package for older NgRx versions so the techniques are practical and working.
AI-written summary · about
chapters (24)
- 0:00Intro
- 0:43Welcome
- 2:50Why I love MockStore
- 4:00Overview
- 4:58Data Flow
- 6:37Unit Tests Example
- 11:22Implementing with MockStore
- 15:36Mock Selectors Example
- 18:21Mock Selectors Notes
- 19:28Validate Dispatched Actions
- 20:05Recap
- 21:13Closing remarks
- 21:44Test libraries
- 22:24Schematics
- 22:58Compatibility
- 23:29Start Small
- 23:51References Documentation
- 24:37Conclusion
- 26:45Asynchronicity
- 28:25RxJS Test Scheduler
- 29:27MockStore vs override selectors
- 31:19Favorite place to scuba dive
- 33:14NgRx testing libraries
- 35:15Outro
related talks
28mUsing MockStore in NgRx 8
20mTesting NgRX
01h 04mRedux for Angular -- Introduction to Ngrx Ecosystem
18mNgRx SignalStore: Modern State Management for Angular
35mAdvanced NgRx Techniques
18mBuilding Sub States w/ NgRx Selectors
22mState Management Techniques and Family Therapy
44mAngular + Redux ... stop, what?
