Skip to content

Commit 2a7824d

Browse files
committed
fix: better error message when cannot install Cypress, closes #44
1 parent 3051abb commit 2a7824d

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

src/index.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,23 @@ async function runCypressTests (baseUrl, record, spec, group, tag) {
8989

9090
async function install(arg) {
9191
debug('installing Cypress binary just in case')
92-
const runOptions = debug.enabled ? {} : {stdio: 'ignore'}
93-
await arg.utils.run('cypress', ['install'], runOptions)
92+
const runOptions = debug.enabled ? {} : { stdio: 'ignore' }
93+
try {
94+
await arg.utils.run('cypress', ['install'], runOptions)
95+
} catch (error) {
96+
debug('error installing Cypress: %s', error.message)
97+
const buildUtils = arg.utils.build
98+
console.error('')
99+
console.error('Failed to install Cypress')
100+
console.error('Did you forget to add Cypress as a dev dependency?')
101+
console.error(' npm i -D cypress')
102+
console.error('or')
103+
console.error(' yarn add -D cypress')
104+
console.error('')
105+
console.error('See https://github.com/cypress-io/netlify-plugin-cypress#readme')
106+
console.error('')
107+
buildUtils.failBuild('Failed to install Cypress. Did you forget to add Cypress as a dev dependency?', { error })
108+
}
94109
}
95110

96111
const processCypressResults = (results, buildUtils) => {

0 commit comments

Comments
 (0)