I want to spyOn the following call document.getElementById(endId).classList.contains('class') and return true.
After searching on the web, I tried the following
spyOn(document, 'getElementById').and.callFake(() => {
const e = document.createElement('p');
e.classList.add('class');
return e;
});
but I'm getting following error:
TypeError: undefined is not an object (evaluating 'e.classList.contains')
And spying on the whole call is not possible.
Aucun commentaire:
Enregistrer un commentaire