I have following code in my method, which removes particular class from the fullcalendar events and do someother things after that.
someMethod() {
let events = document.querySelectorAll(`.calendar-event`);
events.forEach((event) => {
event.classList.remove('calendar-read-event');
});
//dosomething
}
When running the test cases due to some reason the fullcalendar is not displayed and when i call this method i am getting error
'Cannot read property 'forEach' of undefined'
This is because calendar-event class is not loaded yet and i am getting no result for querySelectorAll() , Is there a way to spyon document.querySelectorAll() and return some value.
Something like this in beforeEach method:
spyOn(document, 'querySelectorAll').and.returnValue(NodeList);
Have tried this but its not stubbing the value and I am still getting 'Cannot read property 'forEach' of undefined' error