mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-31 03:29:43 -06:00
* 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
37 lines
832 B
JavaScript
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)
|
|
},
|
|
}
|