lundi 5 mars 2018

Angular4 and AngularFire2 unit testing is not working

I am trying to unit test my project. I get a very weird error

TypeError: app.auth is not a function

at new AngularFireAuth (http://localhost:9876/_karma_webpack_/webpack:/Users/xx/xx/xx-xx/xx/xx/xx-xx-xx/xx-xx/xx/xx/xx/node_modules/angularfire2/auth/auth.js:12:1)

This is the spec file I am trying to run

import { TestBed, inject } from '@angular/core/testing';

import { FirebaseAuthService } from './firebase-auth.service';
import {AngularFireAuth} from 'angularfire2/auth';
import {FirebaseApp} from 'angularfire2';

describe('FirebaseAuthService', () => {

  // Configure testbed

  beforeEach(() => {
    TestBed.configureTestingModule({
      providers: [
        FirebaseAuthService,
        AngularFireAuth,
        FirebaseApp,

      ]
    });
  });

  // Create test cases below

  it('should be created', inject([FirebaseAuthService], (service: FirebaseAuthService) => {
    expect(service).toBeTruthy();
  }));
});

and inside the constructor of my service I initialise these services

constructor(public _firebaseAuth: AngularFireAuth, private router: Router, private db: AngularFireDatabase) 

Can anyone tell my why is that happening? same thing happens when I do a unit test with AngularfireDatabase

Aucun commentaire:

Enregistrer un commentaire