angular / angular/angularfire

[docs] Mocking of angularfire methods with angularfire 7 during tests

Open
#3,050 4 comments 9 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
7.8k
Forks
2.2k
Avg merge
22h 28m
Merged PRs (30d)
6

Description

### Version info

**Angular:** 12

**Firebase:** 9

**AngularFire:** 7

### How to reproduce these conditions

How to mock firebase operator during tests suits ?
How to write unit tests with mocks of firestore/auth/analytics methods ?

### Expected behavior

With Angularfire 6, I was able to mock angularfire methods like doc, collection and other methods to write my unit tests.
I would like to be able to mock it.

### Actual behavior

I am getting the error during my unit tests :
Error: Either AngularFireModule has not been provided in your AppModule (this can be done manually or implictly using provideFirebaseApp) or you're calling an AngularFire method outside of an NgModule (which is not supported).

Contributor guide

Open the contributing guide

Research direction

Start with the AngularFire 7 testing setup around AngularFireModule and provideFirebaseApp, then reproduce the reported unit-test error while mocking Firestore, Auth, and Analytics methods. Done means documenting working guidance for mocking these AngularFire methods under Angular 12, Firebase 9, and AngularFire 7.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, firebase, typescript
Domain
documentation, testing
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.