> For the complete documentation index, see [llms.txt](https://vytautas.gitbook.io/ng-state/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vytautas.gitbook.io/ng-state/unit-testing/test-actions.md).

# Test actions

Actions can be tested by calling `NgStateTestBed.createActions` method. `createActions` has required param `actions` and two params with default values: `initialState` with value `{}` and `statePath` with value `[]`. This means that for most of situations we can pass just actions type and test application in localized state. But for more complex scenarios we can pass initial state and path.

```typescript
it('should return actions', () => {
    const initialState = { todos: [] };
    initialState.todos.push({ description: 'test description' });

    const actions = NgStateTestBed.createActions<TestActions>(TestActions); // in this case actions will be created with state = {};
    // OR
    const actions = NgStateTestBed.createActions(TestActions, initialState, ['todos', 0]);
    // OR
    const actions = NgStateTestBed.createSignalActions(TestActions, initialState, ['todos', 0]);
    expect(actions.todoDescription).toEqual('test description');
});
```

where

* first param is `initialState` is object or class
* second param is `statePath` to bind actions to
* third param is `actions` class

> `createActions` as well as `createSignalActions` takes into consideration injectable actions. Dependenices are mocked and injected according to Angular TestBed.
