Angular4和AngularFire2单元测试不起作用

时间:2018-03-05 19:57:39

标签: angular testing karma-jasmine angularfire2

我正在尝试对我的项目进行单元测试。我得到一个非常奇怪的错误

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)

这是我试图运行的spec文件

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();
  }));
});

并在我的服务的构造函数内部初始化这些服务

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

任何人都可以告诉我为什么会这样吗?当我使用AngularfireDatabase

进行单元测试时,会发生同样的事情

0 个答案:

没有答案