mirror of
https://github.com/cypress-io/cypress.git
synced 2026-01-08 07:29:44 -06:00
* chore: remove 'not logged in' error - which is dead code * Remove function getMsgByType which is no longer called in code * remove errors around 'private test' plans * Remove snapshots * update system test snapshot
67 lines
1.8 KiB
JavaScript
67 lines
1.8 KiB
JavaScript
/* eslint-disable no-console */
|
|
require('../spec_helper')
|
|
|
|
const exception = require(`../../lib/cloud/exception`)
|
|
const chalk = require('chalk')
|
|
const errors = require('../../lib/errors')
|
|
|
|
context('.logException', () => {
|
|
beforeEach(() => {
|
|
sinon.stub(console, 'log')
|
|
})
|
|
|
|
it('calls exception.create with unknown error', () => {
|
|
sinon.stub(exception, 'create').resolves()
|
|
sinon.stub(process.env, 'CYPRESS_INTERNAL_ENV').value('production')
|
|
|
|
const err = new Error('foo')
|
|
|
|
return errors.logException(err)
|
|
.then(() => {
|
|
expect(console.log).to.be.calledWith(chalk.red(err.stack ?? ''))
|
|
|
|
expect(exception.create).to.be.calledWith(err)
|
|
})
|
|
})
|
|
|
|
it('does not call exception.create when known error', () => {
|
|
sinon.stub(exception, 'create').resolves()
|
|
sinon.stub(process.env, 'CYPRESS_INTERNAL_ENV').value('production')
|
|
|
|
const err = errors.get('TESTS_DID_NOT_START_FAILED')
|
|
|
|
return errors.logException(err)
|
|
.then(() => {
|
|
expect(console.log).not.to.be.calledWith(err.stack)
|
|
|
|
expect(exception.create).not.to.be.called
|
|
})
|
|
})
|
|
|
|
it('does not call exception.create when not in production env', () => {
|
|
sinon.stub(exception, 'create').resolves()
|
|
sinon.stub(process.env, 'CYPRESS_INTERNAL_ENV').value('development')
|
|
|
|
const err = new Error('foo')
|
|
|
|
return errors.logException(err)
|
|
.then(() => {
|
|
expect(console.log).not.to.be.calledWith(err.stack)
|
|
|
|
expect(exception.create).not.to.be.called
|
|
})
|
|
})
|
|
|
|
it('swallows creating exception errors', () => {
|
|
sinon.stub(exception, 'create').rejects(new Error('foo'))
|
|
sinon.stub(process.env, 'CYPRESS_INTERNAL_ENV').value('production')
|
|
|
|
const err = errors.get('TESTS_DID_NOT_START_FAILED')
|
|
|
|
return errors.logException(err)
|
|
.then((ret) => {
|
|
expect(ret).to.be.undefined
|
|
})
|
|
})
|
|
})
|