NgRx Signal Store: How to mock entities?

Discussão em 'Angular' iniciado por JockelzF, Fevereiro 5, 2025.

  1. JockelzF

    JockelzF Guest

    I'm using an ngrx signal store with the withEntities Feature (https://ngrx.io/guide/signals/signal-store/entity-management), like so:

    import { signalStore } from '@ngrx/signals';
    import { withEntities } from '@ngrx/signals/entities';

    type Todo = {
    id: number;
    text: string;
    completed: boolean;
    };

    export const TodosStore = signalStore(
    withEntities<Todo>()
    );


    Now I would like to have component tests, that use a mock state of that store. For a normal ngrx signal store this is well documented (https://ngrx.io/guide/signals/signal-store/testing#native-mocking), but how does it work for withEntities?

    TestBed.configureTestingModule({
    imports: [SomeComponent],
    providers: [
    {
    provide: TodosStore,
    useValue: mock //what to put here?
    },
    ],
    });

    Continue reading...

Compartilhe esta Página