mirror of
https://github.com/cypress-io/cypress.git
synced 2026-02-21 14:41:00 -06:00
feat(BREAKING): Set DPR to 1 for Chrome headless browsers by default (#17377)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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',
|
||||
})
|
||||
})
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
})
|
||||
@@ -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
|
||||
})
|
||||
|
||||
@@ -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',
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user