1. 程式人生 > >關於Angular元件測試時需要制定瀏覽器初期尺寸的設定項(Firefox,Chrome)

關於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命令時瀏覽器就會按照指定的大小開啟,對於測試螢幕解析度很有幫助。