mirror of
https://github.com/cypress-io/cypress.git
synced 2026-05-02 13:00:18 -05:00
fix: Show better error message during cypress cache list when no cache (#9023)
Co-authored-by: Ben Kucera <14625260+Bkucera@users.noreply.github.com>
This commit is contained in:
@@ -451,3 +451,7 @@ exports['cli version and binary version with npm log warn'] = `
|
||||
Cypress package version: 1.2.3
|
||||
Cypress binary version: X.Y.Z
|
||||
`
|
||||
|
||||
exports['prints explanation when no cache'] = `
|
||||
No cached binary versions were found.
|
||||
`
|
||||
|
||||
+7
-1
@@ -408,8 +408,14 @@ module.exports = {
|
||||
size: opts.size,
|
||||
})
|
||||
|
||||
return cache.list(opts.size).catch((e) => {
|
||||
return cache.list(opts.size)
|
||||
.catch({ code: 'ENOENT' }, () => {
|
||||
logger.always('No cached binary versions were found.')
|
||||
process.exit(0)
|
||||
})
|
||||
.catch((e) => {
|
||||
debug('cache list command failed with "%s"', e.message)
|
||||
|
||||
util.logErrorExit1(e)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -513,6 +513,20 @@ describe('cli', () => {
|
||||
})
|
||||
|
||||
context('cypress cache list', () => {
|
||||
it('prints explanation when no cache', (done) => {
|
||||
const err = new Error()
|
||||
|
||||
err.code = 'ENOENT'
|
||||
|
||||
sinon.stub(cache, 'list').rejects(err)
|
||||
this.exec('cache list')
|
||||
|
||||
process.exit.callsFake(() => {
|
||||
snapshot('prints explanation when no cache', logger.print())
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('catches rejection and exits', (done) => {
|
||||
const err = new Error('cache list failed badly')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user