diff --git a/cli/__snapshots__/errors_spec.js b/cli/__snapshots__/errors_spec.js index f137d90a02..125ec45cc4 100644 --- a/cli/__snapshots__/errors_spec.js +++ b/cli/__snapshots__/errors_spec.js @@ -2,6 +2,7 @@ exports['errors individual has the following errors 1'] = [ "nonZeroExitCodeXvfb", "missingXvfb", "missingApp", + "notInstalledCI", "missingDependency", "versionMismatch", "binaryNotExecutable", diff --git a/cli/__snapshots__/verify_spec.js b/cli/__snapshots__/verify_spec.js index 9e4839e694..b2a24d95a7 100644 --- a/cli/__snapshots__/verify_spec.js +++ b/cli/__snapshots__/verify_spec.js @@ -266,3 +266,25 @@ Platform: darwin (Foo-OsVersion) Cypress Version: 1.2.3 ` + +exports['error binary not found in ci 1'] = ` +Error: The cypress npm package is installed, but the Cypress binary is missing. + +We expected the binary to be installed here: /cache/Cypress/1.2.3/Cypress.app/Contents/MacOS/Cypress + +Reasons it may be missing: + +- You're caching 'node_modules' but are not caching this path: /cache/Cypress +- You ran 'npm install' at an earlier build step but did not persist: /cache/Cypress + +Properly caching the binary will fix this error and avoid downloading and unzipping Cypress. + +Alternatively, you can run 'cypress install' to download the binary again. + +https://on.cypress.io/not-installed-ci-error +---------- + +Platform: darwin (Foo-OsVersion) +Cypress Version: 1.2.3 + +` diff --git a/cli/lib/errors.js b/cli/lib/errors.js index cc29b8bb81..bb40a07f70 100644 --- a/cli/lib/errors.js +++ b/cli/lib/errors.js @@ -45,6 +45,24 @@ const binaryNotExecutable = (executable) => ({ }) +const notInstalledCI = (executable) => ({ + description: 'The cypress npm package is installed, but the Cypress binary is missing.', + solution: stripIndent`\n + We expected the binary to be installed here: ${chalk.cyan(executable)} + + Reasons it may be missing: + + - You're caching 'node_modules' but are not caching this path: ${util.getCacheDir()} + - You ran 'npm install' at an earlier build step but did not persist: ${util.getCacheDir()} + + Properly caching the binary will fix this error and avoid downloading and unzipping Cypress. + + Alternatively, you can run 'cypress install' to download the binary again. + + https://on.cypress.io/not-installed-ci-error + `, +}) + const nonZeroExitCodeXvfb = { description: 'XVFB exited with a non zero exit code.', solution: stripIndent` @@ -216,6 +234,7 @@ module.exports = { nonZeroExitCodeXvfb, missingXvfb, missingApp, + notInstalledCI, missingDependency, versionMismatch, binaryNotExecutable, diff --git a/cli/lib/tasks/verify.js b/cli/lib/tasks/verify.js index fa1d75d8ea..bf1f52ed41 100644 --- a/cli/lib/tasks/verify.js +++ b/cli/lib/tasks/verify.js @@ -25,6 +25,9 @@ const checkExecutable = (binaryDir) => { } }) .catch({ code: 'ENOENT' }, () => { + if (util.isCi()) { + return throwFormErrorText(errors.notInstalledCI(executable))() + } return throwFormErrorText(errors.missingApp(binaryDir))(stripIndent` Cypress executable not found at: ${chalk.cyan(executable)} `) diff --git a/cli/test/lib/tasks/verify_spec.js b/cli/test/lib/tasks/verify_spec.js index 823740fb4a..2af444d9e5 100644 --- a/cli/test/lib/tasks/verify_spec.js +++ b/cli/test/lib/tasks/verify_spec.js @@ -394,15 +394,29 @@ context('lib/tasks/verify', () => { packageVersion, }) util.isCi.returns(true) - - return verify.start({ force: true }) }) it('uses verbose renderer', () => { - snapshot( - 'verifying in ci', - normalize(stdout.toString()) - ) + return verify.start() + .then(() => { + snapshot( + 'verifying in ci', + normalize(stdout.toString()) + ) + }) + }) + + it('logs error when binary not found', () => { + mockfs({}) + return verify.start() + .then(() => { throw new Error('Should have thrown') }) + .catch((err) => { + logger.error(err) + snapshot( + 'error binary not found in ci', + normalize(stdout.toString()) + ) + }) }) })