| Start | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Unit Test For Component With Mock Store This is a unit test of a component that has Store as a dependency. Here, we are creating a new class called MockStore that is injected into our component instead of the usual Store. |
||||||||||||||||
Observer Mock |
||||||||||||||||
| Angular 2 - Mock Observable ( service + component ) service
Component
test service
test component |
||||||||||||||||
| Unit Test For Component Spying On Store This is a unit test of a component that has Store as a dependency. Here, we are able to use a store with the default "initial state" while preventing it from actually dispatching actions when store.dispatch() is called. |
||||||||||||||||
| Simple Store simple.action.ts simple.efficts.ts simple.reducer.ts store/index.ts app.module.ts app.component.ts result 0 1 3 6 Parameters
RemarksObserver is a generic, but must be of type It's possible to pass null values into StoreMock's super constructor, but this restricts the number of assertions that can be used to test the class further down the road. The Component being used in this example is just being used as context for how one would go about injecting Store as a provide in the test setup. |
Read Article
https://develop.horje.com/learn/1434/reference