Angular how to unit test Firebase (v19)

Discussão em 'Angular' iniciado por Michele Cassani, Dezembro 18, 2024.

  1. In my Angular application I wrapped the connection to the store in a service but I can't test it.

    In the main documentation is written:

    firestore: Firestore = inject(Firestore);

    getItemsCollection() {
    const itemCollection = collection(this.firestore, 'items');
    return collectionData<Item>(itemCollection);
    }

    getItemsCollection(id: string) {
    const itemDocument = doc(this.firestore, 'items' + id);
    return docData<Item>(itemDocument);
    }


    but how can i test it? I'm expecting to provide "Firestore" using a spy object or something mocked but how can i do it that could work also for other document/collection action (as update/add/delete)

    Continue reading...

Compartilhe esta Página