Created
March 6, 2019 08:29
-
-
Save AndreVirtimo/7bd2892478af2ea06ea7445319fbfef1 to your computer and use it in GitHub Desktop.
Change the resolution of screenshots taken by cypress.io when running headless on a server with virtual Framebuffer Xvfb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//source https://github.com/cypress-io/cypress/blob/develop/cli/lib/exec/xvfb.js | |
const os = require('os') | |
const Promise = require('bluebird') | |
const Xvfb = require('@cypress/xvfb') | |
const R = require('ramda') | |
const debug = require('debug')('cypress:cli') | |
const debugXvfb = require('debug')('cypress:xvfb') | |
const { throwFormErrorText, errors } = require('../errors') | |
const xvfb = Promise.promisifyAll(new Xvfb({ | |
timeout: 5000, // milliseconds | |
xvfb_args: [ //added code | |
'-screen', //added code | |
'0', //added code | |
'1920x1080x8' //added code | |
], //added code | |
onStderrData (data) { | |
if (debugXvfb.enabled) { | |
debugXvfb(data.toString()) | |
} | |
}, | |
})) | |
module.exports = { | |
_debugXvfb: debugXvfb, // expose for testing | |
_xvfb: xvfb, // expose for testing | |
start () { | |
debug('Starting XVFB') | |
return xvfb.startAsync() | |
.catch({ nonZeroExitCode: true }, throwFormErrorText(errors.nonZeroExitCodeXvfb)) | |
.catch((err) => { | |
if (err.known) { | |
throw err | |
} | |
return throwFormErrorText(errors.missingXvfb)(err) | |
}) | |
}, | |
stop () { | |
debug('Stopping XVFB') | |
return xvfb.stopAsync() | |
}, | |
isNeeded () { | |
return os.platform() === 'linux' && !process.env.DISPLAY | |
}, | |
// async method, resolved with Boolean | |
verify () { | |
return xvfb.startAsync() | |
.then(R.T) | |
.catch((err) => { | |
debug('Could not verify xvfb: %s', err.message) | |
return false | |
}) | |
.finally(xvfb.stopAsync) | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I marked the added code with "//added code"
Source: https://github.com/cypress-io/cypress/blob/develop/cli/lib/exec/xvfb.js (2333d04 on 1 Nov 2018)