Skip to content

Commit

Permalink
fix: headless args
Browse files Browse the repository at this point in the history
Signed-off-by: SuZhou-Joe <[email protected]>
  • Loading branch information
SuZhou-Joe committed Nov 1, 2023
1 parent 2ca3977 commit b324ebe
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
16 changes: 16 additions & 0 deletions cypress/plugins/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
};
17 changes: 0 additions & 17 deletions cypress/support/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});

0 comments on commit b324ebe

Please sign in to comment.