我正在使用 Angular 5 和 angular material
,在 HTML 中,当我使用 ProgressSpinner
并运行单元测试时,出现错误 SyntaxError: DOM Exception 12
,有一个脚本
<div *ngIf="!loadingEmployees; else spinnerLoading">
<app-contributor *ngFor="let employee of employees"></app-contributor>
</div>
<ng-template #spinnerLoading>
<div class="loading row centralize">
<!-- <mat-spinner color="warn" diameter="80" strokeWidth="6"></mat-spinner> -->
<p>Loading...</p>
</div>
</ng-template>
当我推荐脚本时,测试就会通过。在单元测试中,我只导入有 Material 模块的 Shared 模块。就这样
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
BrowserAnimationsModule,
SharedModule
],
providers: [
{ provide: ContributorContentService, useClass: ContributorContentServiceMock },
{ provide: MatDialog, useClass: MatDialogMock }
]
})
.compileComponents();
}))
有人知道吗?我忘了什么?非常感谢!
最佳答案
删除 diameter="80"
在<mat-spinner>
并通过 css 更新直径帮助我解决了问题。但应该有更好的方法。
关于angular - 单元测试语法错误 : DOM Exception 12 angular 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51839820/