关于Angular组件测试时需要制定浏览器初期尺寸的设定项(Firefox,Chrome)
需要在karma.conf.js里面添加如下节点。
customLaunchers : {
chromeCustom: {
base: 'Chrome',
displayName: 'chromeCustom',
flags: ['--window-size=768,1024'] // for Chrome
},
firefoxCustom:{
base:'Firefox',
displayName:'firefoxCustom',
flags: ['-width=768','-height=1024'] // for Firefox
}
}
添加了这两个后,运行ng test命令时浏览器就会按照指定的大小打开,对于测试屏幕分辨率很有帮助。