Files
cypress/cli/lib/exec/xvfb.js
Gleb Bahmutov 4520c2b6dd feat(run): handle failed tests returned by the cypress run (#180)
* feat(run): handle failed tests returned by the cypress run

* cli: rework errors thrown from cypress vs xvfb

* small tweak

* cli: test xvfb start error handling
2017-06-22 12:00:17 -04:00

37 lines
832 B
JavaScript

const os = require('os')
const Promise = require('bluebird')
const Xvfb = require('@cypress/xvfb')
const R = require('ramda')
const debug = require('debug')('cypress:cli')
const { throwDetailedError, errors } = require('../errors')
const xvfb = Promise.promisifyAll(new Xvfb({ silent: true }))
module.exports = {
_xvfb: xvfb, // expose for testing
start () {
return xvfb.startAsync()
.catch(throwDetailedError(errors.missingXvfb))
},
stop () {
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)
},
}