mardi 14 août 2018

Unit test SyntaxError: DOM Exception 12 angular 5

I am using Angular 5 and angular material, and in HTML, when I use ProgressSpinner, and run unit test, appear that error SyntaxError: DOM Exception 12, there is a script

<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>

And when I commend the script, the test will pass. In unit test, I just import Shared module where have a Material module. Like that

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      imports: [
        BrowserAnimationsModule,
        SharedModule
      ],
      providers: [
        { provide: ContributorContentService, useClass: ContributorContentServiceMock },
        { provide: MatDialog, useClass: MatDialogMock }
      ]
    })
    .compileComponents();
  }))

Anyone have some idea? I forgot something? Thanks a lot!

Aucun commentaire:

Enregistrer un commentaire