I want to write a unit test which expects a variable to contain a specific value depending on the innerWidth of the window.
In my unit test, I use window.innerWidth = 1000;. However, I receive an error which says Cannot assign to 'innerWidth' because it is a read-only property..
Code (home.component.spec.ts):
xit('should order the cards in the appropriate order on desktop', () => {
spyOn(component, 'reOrderCards');
window.innerWidth = 1000;
})
Is there any way to mock the innerWidth property?
Aucun commentaire:
Enregistrer un commentaire