title: NGXS: Testing an action
body: <p>I'm very new to angular &amp; ngxs and I'm coding a small message-service giving the opportunity to send &amp; receive Messages through an ngxs store connected to firebase. </p>
  
  <p>I'm trying to write a test for the method to send messages. As I'm not really getting along with the official ngxs documentation for testing, I'm having some issues with that.</p>
  
  <p>So my current (not working) attempt for that test is:</p>
  
  <pre><code>describe('SendMessage', () =&gt; {
      let store: Store;
      let testData: Message = {
      author: 'testauthor',
      text: 'testtext'
  }; 
  
      beforeEach(async(() =&gt; {
  
          TestBed.configureTestingModule({
          imports: [NgxsModule.forRoot([MessageState]),
              NgxsModule.forRoot([AngularFirestore])],
          }).compileComponents();
  
          store = TestBed.get(Store);
          store.reset(TEST_STATE);
       }));
  
      it('sends Messages', async(() =&gt; {
          store.dispatch(new fromMessage.AddMessage(testData));
          store.selectOnce(state =&gt; MessageState.getSentMessages).subscribe(message =&gt; {
             expect(message).toEqual(testData);
      })
     }))   
  });
  </code></pre>
  
  <p>With TEST_STATE being</p>
  
  <pre><code>export const TEST_STATE = {
      messages: [{
      author: 'testauthor',
      text: 'testtext'
      }]
  }
  </code></pre>
  
  <p>Running the test, I get the error <code>Failed: States must be decorated with @State() decorator</code>.</p>
  
  <p>How can I use the TEST_STATE correctly as my state for testing <code>AddMessage</code>? How should my dispatches and selects look like?</p>
  
  <p>As I said, I am a newbie to ngxs and testing, so sorry if my Code is not so good.
  Thanks for your help!</p>