Boa tarde, estou no mód 02 aula 06. Me deparei com esse erro ao tentar acessar o elemento do DOM('.like-counter'). Segue meu código
it(`(D) Should display number of likes when (@Input likes) is incremented `, ()=> {
fixture.detectChanges();
component.likes++;
fixture.detectChanges();
const element:HTMLSpanElement = fixture.nativeElement.querySelector('.like-counter ');
expect(element.textContent.trim()).toBe('1');
});
O erro que aparece no KARMA
PhotoFrameComponent > (D) Should display number of likes when (@Input likes) is incremented
TypeError: Cannot read properties of null (reading 'textContent')
TypeError: Cannot read properties of null (reading 'textContent')
at UserContext.<anonymous> (http://localhost:9876/_karma_webpack_/webpack:/src/app/shared/components/photo-frame/photo-frame.component.spec.ts:54:22)
at ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone-evergreen.js:364:1)
at ProxyZoneSpec.onInvoke (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone-testing.js:292:1)
at ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone-evergreen.js:363:1)
at Zone.run (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone-evergreen.js:123:1)
at runInTestZone (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone-testing.js:545:1)
at UserContext.<anonymous> (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone-testing.js:560:1)
at <Jasmine>
Alguma solução? Olhei no fórum vi outras pessoas com o mesmo erro mas a solução delas n serviu para mim.