1. 程式人生 > 其它 >Cypress設定chrome瀏覽器執行自啟動開發者工具

Cypress設定chrome瀏覽器執行自啟動開發者工具

在plugins-》index.js檔案末尾加上這一塊程式碼,更詳細的內容檢視文件中的plugins相關內容 https://docs.cypress.io/api/plugins/browser-launch-api#Syntax

 

 

 

module.exports = (on, config) => {
    on('before:browser:launch', (browser = {}, launchOptions) => {
        // `args` is an array of all the arguments that will
        // be passed to browsers when it launches
console.log(launchOptions.args) // print all current args if (browser.family === 'chromium' && browser.name !== 'electron') { // auto open devtools launchOptions.args.push('--auto-open-devtools-for-tabs') } if (browser.family === 'firefox
') { // auto open devtools launchOptions.args.push('-devtools') } if (browser.name === 'electron') { // auto open devtools launchOptions.preferences.devTools = true } // whatever you return here becomes the launchOptions return
launchOptions }) };