From b324ebe6bea2197e234c7e8b51d9b9243187646b Mon Sep 17 00:00:00 2001 From: SuZhou-Joe Date: Wed, 1 Nov 2023 12:16:34 +0800 Subject: [PATCH] fix: headless args Signed-off-by: SuZhou-Joe --- cypress/plugins/index.js | 16 ++++++++++++++++ cypress/support/index.js | 17 ----------------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js index 80b077ce8..3785e9979 100644 --- a/cypress/plugins/index.js +++ b/cypress/plugins/index.js @@ -24,4 +24,20 @@ module.exports = (on, config) => { // `on` is used to hook into various events Cypress emits // `config` is the resolved Cypress config + on('before:browser:launch', (browser = {}, launchOptions) => { + if ( + (browser.name === 'chrome' || browser.name === 'chromium') && + browser.isHeadless + ) { + launchOptions.args = launchOptions.args.map((arg) => { + if (arg === '--headless') { + return '--headless=new'; + } + + return arg; + }); + } + + return launchOptions; + }); }; diff --git a/cypress/support/index.js b/cypress/support/index.js index d3401f86c..6b13ed838 100644 --- a/cypress/support/index.js +++ b/cypress/support/index.js @@ -56,20 +56,3 @@ if (Cypress.env('ENDPOINT_WITH_PROXY')) { Cypress.Cookies.preserveOnce('security_authentication'); }); } - -cy.on('before:browser:launch', (browser = {}, launchOptions) => { - if ( - (browser.name === 'chrome' || browser.name === 'chromium') && - browser.isHeadless - ) { - launchOptions.args = launchOptions.args.map((arg) => { - if (arg === '--headless') { - return '--headless=new'; - } - - return arg; - }); - } - - return launchOptions; -});