running cypress run --headless --browser chrome opens a visible maximized (it does not adhere viewportWidth and viewportHeight settings) Chrome instance. I would expect it to run headless with the correct dimensions.
Interestingly, it does report to be running chrome 78 headless:

Cypress: 3.8.0
OS: Microsoft Windows 10 Enterprise Version 10.0.16299 Build 16299
_Originally posted by @Waterstraal in https://github.com/cypress-io/cypress/issues/832#issuecomment-565358299_
Same on OSX
it seems to work if you use in plugins\index.js
on('before:browser:launch', (browser = {}, args) => {
args.push('--headless')
}
But then I am loading an extension for ignoreXFrameHeaders which seems to fail. I use below line to load extensions.
args.push('--load-extension=' + extention_path);
Yes, I have confirmed that the --headless flag still opens the Chrome browser in 3.8.0.

@knagarajan1984 Chrome headless mode does not support extensions, so you will have to use one or the other, not both.
I have a fix for this in #5953.
For a temporary workaround, you can use the pluginsfile as @knagarajan1984 mentioned above:
on('before:browser:launch', (browser = {}, args) => {
if (browser.family === 'chrome') {
args.push('--headless')
}
}
For me, on mac os, the work around does not work. The chrome browser window still opens
Below I have console logged the plugin browser object
{
name: 'chrome',
family: 'chrome',
displayName: 'Chrome',
version: '78.0.3904.108',
path: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
majorVersion: 78,
isHeadless: true,
isHeaded: false
}
and the arguments after the plugin code
[
'--test-type',
'--ignore-certificate-errors',
'--start-maximized',
'--silent-debugger-extension-api',
'--no-default-browser-check',
'--no-first-run',
'--noerrdialogs',
'--enable-fixed-layout',
'--disable-popup-blocking',
'--disable-password-generation',
'--disable-save-password-bubble',
'--disable-single-click-autofill',
'--disable-prompt-on-repos',
'--disable-background-timer-throttling',
'--disable-renderer-backgrounding',
'--disable-renderer-throttling',
'--disable-restore-session-state',
'--disable-translate',
'--disable-new-profile-management',
'--disable-new-avatar-menu',
'--allow-insecure-localhost',
'--reduce-security-for-testing',
'--enable-automation',
'--disable-device-discovery-notifications',
'--disable-infobars',
'--autoplay-policy=no-user-gesture-required',
'--disable-site-isolation-trials',
'--metrics-recording-only',
'--disable-prompt-on-repost',
'--disable-hang-monitor',
'--disable-sync',
'--disable-web-resources',
'--safebrowsing-disable-auto-update',
'--safebrowsing-disable-download-protection',
'--disable-client-side-phishing-detection',
'--disable-component-update',
'--disable-default-apps',
'--use-fake-ui-for-media-stream',
'--use-fake-device-for-media-stream',
'--disable-ipc-flooding-protection',
'--disable-backgrounding-occluded-window',
'--disable-breakpad',
'--password-store=basic',
'--use-mock-keychain',
'--user-agent=Kathmandu Test Automation Service',
'--proxy-server=http://localhost:65048',
'--disable-web-security',
'--allow-running-insecure-content',
'--proxy-bypass-list=<-loopback>',
'--remote-debugging-port=65052',
'--headless'
]
however, as mentioned, the chrome browser window still shows up. When I close the chrome window, the test seems to stop running
@WinstonN interesting, what version of Chrome are you using? If you run chrome --headless from the command line, does it spawn headlessly?
The code for this is done in cypress-io/cypress#5953, but has yet to be released.
We'll update this issue and reference the changelog when it's released.
@flotwig I appear to be having the same issue as @WinstonN . My index.js and similar debug information is below.
// index.js
module.exports = (on, config) => {
on('before:browser:launch', (browser = {}, args) => {
args.push('--headless')
})
}
Args after push:
[
'--test-type',
'--ignore-certificate-errors',
'--start-maximized',
'--silent-debugger-extension-api',
'--no-default-browser-check',
'--no-first-run',
'--noerrdialogs',
'--enable-fixed-layout',
'--disable-popup-blocking',
'--disable-password-generation',
'--disable-save-password-bubble',
'--disable-single-click-autofill',
'--disable-prompt-on-repos',
'--disable-background-timer-throttling',
'--disable-renderer-backgrounding',
'--disable-renderer-throttling',
'--disable-restore-session-state',
'--disable-translate',
'--disable-new-profile-management',
'--disable-new-avatar-menu',
'--allow-insecure-localhost',
'--reduce-security-for-testing',
'--enable-automation',
'--disable-device-discovery-notifications',
'--disable-infobars',
'--autoplay-policy=no-user-gesture-required',
'--disable-site-isolation-trials',
'--metrics-recording-only',
'--disable-prompt-on-repost',
'--disable-hang-monitor',
'--disable-sync',
'--disable-web-resources',
'--safebrowsing-disable-auto-update',
'--safebrowsing-disable-download-protection',
'--disable-client-side-phishing-detection',
'--disable-component-update',
'--disable-default-apps',
'--use-fake-ui-for-media-stream',
'--use-fake-device-for-media-stream',
'--disable-ipc-flooding-protection',
'--disable-backgrounding-occluded-window',
'--disable-breakpad',
'--password-store=basic',
'--use-mock-keychain',
'--disable-gpu',
'--no-sandbox',
'--proxy-server=http://localhost:42825',
'--proxy-bypass-list=<-loopback>',
'--remote-debugging-port=42993',
'--headless'
]
My chrome version is Google Chrome 78.0.3904.108.
@flotwig I also have the same problem as @rpocase @WinstonN .
My args :
["--test-type","--ignore-certificate-errors","--start-maximized","--silent-debugger-extension-api","--no-default-browser-check","--no-first-run","--noerrdialogs","--enable-fixed-layout","--disable-popup-blocking","--disable-password-generation","--disable-save-password-bubble","--disable-single-click-autofill","--disable-prompt-on-repos","--disable-background-timer-throttling","--disable-renderer-backgrounding","--disable-renderer-throttling","--disable-restore-session-state","--disable-translate","--disable-new-profile-management","--disable-new-avatar-menu","--allow-insecure-localhost","--reduce-security-for-testing","--enable-automation","--disable-device-discovery-notifications","--disable-infobars","--autoplay-policy=no-user-gesture-required","--disable-site-isolation-trials","--metrics-recording-only","--disable-prompt-on-repost","--disable-hang-monitor","--disable-sync","--disable-web-resources","--safebrowsing-disable-auto-update","--safebrowsing-disable-download-protection","--disable-client-side-phishing-detection","--disable-component-update","--disable-default-apps","--use-fake-ui-for-media-stream","--use-fake-device-for-media-stream","--disable-ipc-flooding-protection","--disable-backgrounding-occluded-window","--disable-breakpad","--password-store=basic","--use-mock-keychain","--proxy-server=http://localhost:51619","--proxy-bypass-list=<-loopback>","--remote-debugging-port=51622","--headless"]
@flotwig If i call ./chrome.exe and pass the same params, no window gets opened
@flotwig apologies for the late reply
My chrome version is Version 78.0.3904.108 (Official Build) (64-bit)
Hey @WinstonN @gabbersepp @rpocase, this was a bug in Cypress and will be fixed in the next release.
@flotwig is there a workaround that works on os x until the fix is released? I just ran into this this morning
@xdumaine Try https://github.com/cypress-io/cypress/issues/5949#issuecomment-565468105
Yeah, no luck with that unfortunately, it still runs headed. Even if I always push --headless - Chrome 79, OS X 10.14.6.
As a sidenote, typescript doesn't like the action nvm on the sidenote, I found our custom typings to add it to, but yeah, doesn't seem to be in the default typesbefore:browser:launch
If it's helpful, we're using cypress.run() from a script, not launching cypress from cli
I'm seeing the same behavior as @xdumaine. We are also using cypress.run() from a script, not launching cypress from cli
The code for this is done in cypress-io/cypress#5953, but has yet to be released.
We'll update this issue and reference the changelog when it's released.
Released in 3.8.1.
Most helpful comment
Released in
3.8.1.