ウィンドウの値に応じて、変数に特定の値が含まれることを期待する単体テストを作成したいと考えてinnerWidth
います。
私の単体テストでは、を使用しますwindow.innerWidth = 1000;
。ただし、というエラーが表示されますCannot assign to 'innerWidth' because it is a read-only property.
。
コード (home.component.spec.ts):
xit('should order the cards in the appropriate order on desktop', () => {
spyOn(component, 'reOrderCards');
window.innerWidth = 1000;
})
innerWidth
プロパティをモックする方法はありますか?