Files
cypress/cli/test/lib/errors_spec.js
Brian Mann 77c62e010b improve CLI verify + run display warnings (#4230)
* tighten up potential xvfb display problems

- improve the warning message on possible display problems
- reuse existing helper functions for platform detection
- instead of relying on timing mechanisms, if a possible display
problem is detected on linux - capture all of the stderr silently and
if the broken gtk message is detected, retry running

* consolidated and simplified smoke testing, xvfb error logging and messaging

- added —dev support to cypress verify cli command

* fix lots of tests, restore one error message

* fixed remaining CLI tests

* console.log pong only in electron mode

* remove dead code
2019-05-17 09:12:03 -04:00

77 lines
1.9 KiB
JavaScript

require('../spec_helper')
const os = require('os')
const snapshot = require('../support/snapshot')
const { errors, formErrorText } = require(`${lib}/errors`)
const util = require(`${lib}/util`)
describe('errors', function () {
const { missingXvfb } = errors
beforeEach(function () {
sinon.stub(util, 'pkgVersion').returns('1.2.3')
os.platform.returns('test platform')
})
describe('individual', () => {
it('has the following errors', () => {
return snapshot(Object.keys(errors).sort())
})
})
context('.errors.formErrorText', function () {
it('returns fully formed text message', () => {
expect(missingXvfb).to.be.an('object')
return formErrorText(missingXvfb)
.then((text) => {
expect(text).to.be.a('string')
snapshot(text)
})
})
it('calls solution if a function', () => {
const solution = sinon.stub().returns('a solution')
const error = {
description: 'description',
solution,
}
return formErrorText(error)
.then((text) => {
snapshot(text)
expect(solution).to.have.been.calledOnce
})
})
it('passes message and previous message', () => {
const solution = sinon.stub().returns('a solution')
const error = {
description: 'description',
solution,
}
return formErrorText(error, 'msg', 'prevMsg')
.then(() => {
expect(solution).to.have.been.calledWithExactly('msg', 'prevMsg')
})
})
it('expects solution to be a string', () => {
const error = {
description: 'description',
solution: 42,
}
return expect(formErrorText(error)).to.be.rejected
})
it('forms full text for invalid display error', () => {
return formErrorText(errors.invalidSmokeTestDisplayError, 'current message', 'prev message')
.then((text) => {
snapshot('invalid display error', text)
})
})
})
})