失败:this.dialog.open不是函数

时间:2019-11-27 15:05:11

标签: angular-unit-test

我正在为我的angular 7项目编写测试用例,并收到以下错误失败:this.dialog.open不是函数

我的文件是:

test.service.ts

import { MatDialog } from '@angular/material/dialog';
import { SpinnerDialog } from './spinner.component';

constructor(public dialog: MatDialog) {}
  dialogRef:any;

  show() {
   this.dialogRef = this.dialog.open(SpinnerDialog, {
        disableClose: true,
        panelClass: 'transparent-background'
    });
  }

test.component.ts

constructor(private test: TestService) { }

onSubmit() {
    this.submitted = true;
    this.test.show();
}

0 个答案:

没有答案