ngrx-workshop
  • Table of Contents
  • Setup and Configuration
  • Rules of Thumb
  • Rules of Thumb pt2
  • NgRx Libraries
    • NgRx Data
    • NgRx Entity
    • Action Creators
    • NgRx Auto Entity
  • NgRx Facades
    • NgRx Facades
  • Testing
    • Testing Factory
    • Testing Reducers
    • Testing Selectors
    • Testing Effects
  • Advanced Actions
    • 3 Types of Actions
    • Deciders
    • Splitter Actions
    • Aggregators
  • ToDo
    • Todo
Powered by GitBook
On this page

Was this helpful?

  1. Testing

Testing Selectors

// Selector Test
describe('user selectors', () => {
 it('should return all users', () => {
   const state = createUsersState();
   expect(getAllUsers(state)).toMatchSnapshot();
 });
});

// Selector Test - Override the state
describe('user selectors', () => {
   it('should return all users', () => {
     const state = createUsersState();

     state.users.entities['1'].firstName = 'Joe';

     const users = getAllUsers(state);

     expect(users[0]).toMatchSnapshot();
   });
 });

PreviousTesting ReducersNextTesting Effects

Last updated 5 years ago

Was this helpful?