Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

407
Views
Prueba de unidad angular: TypeError: no se pueden establecer propiedades de nulo (configurando 'innerHtml') (Jasmine/Karma)

TypeError: no se pueden establecer propiedades de nulo (estableciendo 'innerHtml')

Creé un servicio angular simple que inicializa el html interno de una etiqueta div en el componente principal de mi proyecto angular y se llama en múltiples componentes. Cuando ejecuto mis pruebas, aparece el error de karma anterior. Supongo que esto se debe a que el componente no se crea en el archivo service.spec.ts. Lo he comprobado y la clase está definida en el archivo html principal.

función de servicio.ts:

 onCLick(value: string): void { document.querySelector('div.class').innerHtml = value; }

servicio.spec.ts:

 descirbe('ClickedService', () => { let service: ClickedService; beforeEach(() => { TestBed.configureTestingModule({}); service = TestBed.inject(ClickedService); }); to("#onClick should add to innerHtml", () => { service.onClick('test value'); // error is here }); });
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!