Skip to content

Commit

Permalink
feat(cypress): enhance browser launch setup for headless Chrome
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayagoumi committed Sep 22, 2023
1 parent a05a590 commit 11ee686
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,26 @@ import parseEnvPlugin from './cypress/plugins'
import webpack from 'webpack'
const webpackPreprocessor = require('@cypress/webpack-preprocessor')

function customBrowserLaunch(on, config) {
on('before:browser:launch', (browser, launchOptions) => {
if (browser.name === 'chrome' && browser.isHeadless) {
const headlessIndex = launchOptions.args.indexOf('--headless')
if (headlessIndex > -1) {
launchOptions.args[headlessIndex] = '--headless=new'
}
}
return launchOptions
})
return require('./cypress/plugins/index.ts')(on, config)
}

export default defineConfig({
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
customBrowserLaunch(on, config)

const options = {
webpackOptions: {
resolve: {
Expand Down Expand Up @@ -52,6 +67,6 @@ export default defineConfig({
grepTags: '',
grepFilterSpecs: true,
grepOmitFiltered: true,
grepUntagged: true
grepUntagged: true,
},
})

0 comments on commit 11ee686

Please sign in to comment.