Files
cypress/cli/test/exec/xvfb_spec.js
T
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

49 lines
1.3 KiB
JavaScript

require('../spec_helper')
const os = require('os')
const xvfb = require('../../lib/exec/xvfb')
describe('exec xvfb', function () {
context('#start', function () {
it('passes', function () {
this.sandbox.stub(xvfb._xvfb, 'startAsync').resolves()
return xvfb.start()
})
it('fails with error message', function () {
const message = 'nope'
this.sandbox.stub(xvfb._xvfb, 'startAsync').rejects(new Error(message))
return xvfb.start()
.then(() => {
throw new Error('Should have thrown an error')
}, (err) => {
expect(err.message).to.include(message)
})
})
})
context('#isNeeded', function () {
afterEach(() => delete process.env.DISPLAY)
it('does not need xvfb on osx', function () {
this.sandbox.stub(os, 'platform').returns('darwin')
expect(xvfb.isNeeded()).to.be.false
})
it('does not need xvfb on linux when DISPLAY is set', function () {
this.sandbox.stub(os, 'platform').returns('linux')
process.env.DISPLAY = ':99'
expect(xvfb.isNeeded()).to.be.false
})
it('does need xvfb on linux when no DISPLAY is set', function () {
this.sandbox.stub(os, 'platform').returns('linux')
expect(xvfb.isNeeded()).to.be.true
})
})
})