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:
Jennifer Shehane
2020-10-30 11:43:33 +06:30
committed by GitHub
parent 59bf8a74bf
commit 61088bac2a
3 changed files with 25 additions and 1 deletions
+4
View File
@@ -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
View File
@@ -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)
})
}
+14
View File
@@ -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')