Obtuve el siguiente error al escribir la prueba unitaria en Angular usando Jest. Revisé todas las sugerencias similares aquí en stackoverflow, pero ninguna fue útil.
Error: valor no seguro utilizado en un contexto de URL de recurso (ver https://g.co/ng/security#xss ) Broma
A continuación se muestra el código del archivo de prueba para su revisión.
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser'; import { MaterialModule } from '../../Material/material.module'; import { DashboardViewComponent } from './dashboard-view.component'; describe('DashboardViewComponent', () => { let component: DashboardViewComponent; let fixture: ComponentFixture<DashboardViewComponent>; beforeEach(async () => { await TestBed.configureTestingModule({ imports: [ RouterTestingModule, HttpClientTestingModule, MaterialModule, ], declarations: [ DashboardViewComponent ], providers: [{ provide: DomSanitizer, useValue: { bypassSecurityTrustResourceUrl: (): SafeResourceUrl => '' } }], schemas: [CUSTOM_ELEMENTS_SCHEMA] }) .compileComponents(); }); beforeEach(() => { fixture = TestBed.createComponent(DashboardViewComponent); component = fixture.componentInstance; fixture.detectChanges(); }); test('should create', () => { // expect(component).toMatchSnapshot(); expect(component).toBeTruthy(); }); });Gracias por adelantado.