feat(BREAKING): Set DPR to 1 for Chrome headless browsers by default (#17377)

This commit is contained in:
Jennifer Shehane
2021-07-19 09:42:04 -05:00
committed by GitHub
parent 97c03c1f4d
commit 8cef94879c
5 changed files with 19 additions and 1 deletions

View File

@@ -429,6 +429,10 @@ export = {
// set default headless size to 1920x1080
// https://github.com/cypress-io/cypress/issues/6210
args.push('--window-size=1920,1080')
// set default headless DPR to 1
// https://github.com/cypress-io/cypress/issues/17375
args.push('--force-device-scale-factor=1')
}
// force ipv4

View File

@@ -84,4 +84,10 @@ describe('e2e headless', function () {
project: Fixtures.projectPath('screen-size'),
spec: 'default_size.spec.js',
})
e2e.it('launches at DPR 1x', {
headed: false,
project: Fixtures.projectPath('screen-size'),
spec: 'device_pixel_ratio.spec.js',
})
})

View File

@@ -0,0 +1,6 @@
describe('devicePixelRatio', () => {
it('has DPR of 1', () => {
// assert the browser was spawned with DPR of 1
expect(window.devicePixelRatio).to.equal(1)
})
})

View File

@@ -4,6 +4,7 @@
module.exports = (on) => {
on('before:browser:launch', (browser, options) => {
// options.args.push('-width', '1280', '-height', '1024')
// options.args.push('--force-device-scale-factor=2')
// return options
})

View File

@@ -99,7 +99,7 @@ describe('lib/browsers/chrome', () => {
})
})
it('sets default window size in headless mode', function () {
it('sets default window size and DPR in headless mode', function () {
chrome._writeExtension.restore()
return chrome.open({ isHeadless: true, isHeaded: false }, 'http://', {}, this.automation)
@@ -109,6 +109,7 @@ describe('lib/browsers/chrome', () => {
expect(args).to.include.members([
'--headless',
'--window-size=1920,1080',
'--force-device-scale-factor=1',
])
})
})