cypress 5.4.0 → 5.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/index.js +6 -6
- package/lib/cli.js +103 -107
- package/lib/cypress.js +21 -21
- package/lib/errors.js +233 -276
- package/lib/exec/info.js +29 -32
- package/lib/exec/open.js +7 -8
- package/lib/exec/run.js +20 -20
- package/lib/exec/spawn.js +53 -49
- package/lib/exec/versions.js +18 -17
- package/lib/exec/xvfb.js +43 -37
- package/lib/fs.js +1 -1
- package/lib/logger.js +24 -50
- package/lib/tasks/cache.js +62 -67
- package/lib/tasks/download.js +113 -133
- package/lib/tasks/get-folder-size.js +19 -85
- package/lib/tasks/install.js +165 -249
- package/lib/tasks/state.js +54 -56
- package/lib/tasks/unzip.js +72 -69
- package/lib/tasks/verify.js +112 -147
- package/lib/util.js +164 -167
- package/package.json +3 -3
- package/types/cypress.d.ts +2 -2
- package/types/net-stubbing.ts +74 -6
package/lib/errors.js
CHANGED
@@ -1,286 +1,211 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
|
4
|
-
var data = _taggedTemplateLiteral(["\n To skip the binary install, set CYPRESS_INSTALL_BINARY=0\n "]);
|
3
|
+
const chalk = require('chalk');
|
5
4
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
return data;
|
11
|
-
}
|
12
|
-
|
13
|
-
function _templateObject16() {
|
14
|
-
var data = _taggedTemplateLiteral(["\n The environment variable CYPRESS_SKIP_BINARY_INSTALL has been removed as of version ", "\n "]);
|
15
|
-
|
16
|
-
_templateObject16 = function _templateObject16() {
|
17
|
-
return data;
|
18
|
-
};
|
19
|
-
|
20
|
-
return data;
|
21
|
-
}
|
22
|
-
|
23
|
-
function _templateObject15() {
|
24
|
-
var data = _taggedTemplateLiteral(["\n You should set CYPRESS_INSTALL_BINARY instead.\n "]);
|
25
|
-
|
26
|
-
_templateObject15 = function _templateObject15() {
|
27
|
-
return data;
|
28
|
-
};
|
29
|
-
|
30
|
-
return data;
|
31
|
-
}
|
32
|
-
|
33
|
-
function _templateObject14() {
|
34
|
-
var data = _taggedTemplateLiteral(["\n The environment variable CYPRESS_BINARY_VERSION has been renamed to CYPRESS_INSTALL_BINARY as of version ", "\n "]);
|
35
|
-
|
36
|
-
_templateObject14 = function _templateObject14() {
|
37
|
-
return data;
|
38
|
-
};
|
5
|
+
const {
|
6
|
+
stripIndent,
|
7
|
+
stripIndents
|
8
|
+
} = require('common-tags');
|
39
9
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
function _templateObject13() {
|
44
|
-
var data = _taggedTemplateLiteral(["\n Please search Cypress documentation for possible solutions:\n\n ", "\n\n Check if there is a GitHub issue describing this crash:\n\n ", "\n\n Consider opening a new issue.\n"]);
|
45
|
-
|
46
|
-
_templateObject13 = function _templateObject13() {
|
47
|
-
return data;
|
48
|
-
};
|
49
|
-
|
50
|
-
return data;
|
51
|
-
}
|
52
|
-
|
53
|
-
function _templateObject12() {
|
54
|
-
var data = _taggedTemplateLiteral(["\n See discussion and possible solutions at\n ", "\n "]);
|
55
|
-
|
56
|
-
_templateObject12 = function _templateObject12() {
|
57
|
-
return data;
|
58
|
-
};
|
10
|
+
const {
|
11
|
+
merge
|
12
|
+
} = require('ramda');
|
59
13
|
|
60
|
-
|
61
|
-
}
|
14
|
+
const la = require('lazy-ass');
|
62
15
|
|
63
|
-
|
64
|
-
var data = _taggedTemplateLiteral(["\n This is usually caused by a missing library or dependency.\n\n The error below should indicate which dependency is missing.\n\n ", "\n\n If you are using Docker, we provide containers with all required dependencies installed.\n "]);
|
16
|
+
const is = require('check-more-types');
|
65
17
|
|
66
|
-
|
67
|
-
return data;
|
68
|
-
};
|
18
|
+
const util = require('./util');
|
69
19
|
|
70
|
-
|
71
|
-
}
|
20
|
+
const state = require('./tasks/state');
|
72
21
|
|
73
|
-
|
74
|
-
|
22
|
+
const docsUrl = 'https://on.cypress.io';
|
23
|
+
const requiredDependenciesUrl = `${docsUrl}/required-dependencies`;
|
24
|
+
const runDocumentationUrl = `${docsUrl}/cypress-run`; // TODO it would be nice if all error objects could be enforced via types
|
25
|
+
// to only have description + solution properties
|
75
26
|
|
76
|
-
|
77
|
-
|
78
|
-
|
27
|
+
const hr = '----------';
|
28
|
+
const genericErrorSolution = stripIndent`
|
29
|
+
Search for an existing issue or open a GitHub issue at
|
79
30
|
|
80
|
-
|
81
|
-
|
31
|
+
${chalk.blue(util.issuesUrl)}
|
32
|
+
`; // common errors Cypress application can encounter
|
82
33
|
|
83
|
-
|
84
|
-
|
34
|
+
const unknownError = {
|
35
|
+
description: 'Unknown Cypress CLI error',
|
36
|
+
solution: genericErrorSolution
|
37
|
+
};
|
38
|
+
const invalidRunProjectPath = {
|
39
|
+
description: 'Invalid --project path',
|
40
|
+
solution: stripIndent`
|
41
|
+
Please provide a valid project path.
|
85
42
|
|
86
|
-
|
87
|
-
return data;
|
88
|
-
};
|
43
|
+
Learn more about ${chalk.cyan('cypress run')} at:
|
89
44
|
|
90
|
-
|
91
|
-
|
45
|
+
${chalk.blue(runDocumentationUrl)}
|
46
|
+
`
|
47
|
+
};
|
48
|
+
const failedDownload = {
|
49
|
+
description: 'The Cypress App could not be downloaded.',
|
50
|
+
solution: stripIndent`
|
51
|
+
Does your workplace require a proxy to be used to access the Internet? If so, you must configure the HTTP_PROXY environment variable before downloading Cypress. Read more: https://on.cypress.io/proxy-configuration
|
92
52
|
|
93
|
-
|
94
|
-
|
53
|
+
Otherwise, please check network connectivity and try again:`
|
54
|
+
};
|
55
|
+
const failedUnzip = {
|
56
|
+
description: 'The Cypress App could not be unzipped.',
|
57
|
+
solution: genericErrorSolution
|
58
|
+
};
|
95
59
|
|
96
|
-
|
97
|
-
|
60
|
+
const missingApp = binaryDir => {
|
61
|
+
return {
|
62
|
+
description: `No version of Cypress is installed in: ${chalk.cyan(binaryDir)}`,
|
63
|
+
solution: stripIndent`
|
64
|
+
\nPlease reinstall Cypress by running: ${chalk.cyan('cypress install')}
|
65
|
+
`
|
98
66
|
};
|
67
|
+
};
|
99
68
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
_templateObject7 = function _templateObject7() {
|
107
|
-
return data;
|
108
|
-
};
|
69
|
+
const binaryNotExecutable = executable => {
|
70
|
+
return {
|
71
|
+
description: `Cypress cannot run because this binary file does not have executable permissions here:\n\n${executable}`,
|
72
|
+
solution: stripIndent`\n
|
73
|
+
Reasons this may happen:
|
109
74
|
|
110
|
-
|
111
|
-
|
75
|
+
- node was installed as 'root' or with 'sudo'
|
76
|
+
- the cypress npm package as 'root' or with 'sudo'
|
112
77
|
|
113
|
-
|
114
|
-
var data = _taggedTemplateLiteral(["\n\n We expected the binary to be installed here: ", "\n\n Reasons it may be missing:\n\n - You're caching 'node_modules' but are not caching this path: ", "\n - You ran 'npm install' at an earlier build step but did not persist: ", "\n\n Properly caching the binary will fix this error and avoid downloading and unzipping Cypress.\n\n Alternatively, you can run 'cypress install' to download the binary again.\n\n ", "\n "], ["\\n\n We expected the binary to be installed here: ", "\n\n Reasons it may be missing:\n\n - You're caching 'node_modules' but are not caching this path: ", "\n - You ran 'npm install' at an earlier build step but did not persist: ", "\n\n Properly caching the binary will fix this error and avoid downloading and unzipping Cypress.\n\n Alternatively, you can run 'cypress install' to download the binary again.\n\n ", "\n "]);
|
78
|
+
Please check that you have the appropriate user permissions.
|
115
79
|
|
116
|
-
|
117
|
-
|
80
|
+
You can also try clearing the cache with 'cypress cache clear' and reinstalling.
|
81
|
+
`
|
118
82
|
};
|
83
|
+
};
|
119
84
|
|
120
|
-
|
121
|
-
|
85
|
+
const notInstalledCI = executable => {
|
86
|
+
return {
|
87
|
+
description: 'The cypress npm package is installed, but the Cypress binary is missing.',
|
88
|
+
solution: stripIndent`\n
|
89
|
+
We expected the binary to be installed here: ${chalk.cyan(executable)}
|
122
90
|
|
123
|
-
|
124
|
-
var data = _taggedTemplateLiteral(["\n\n Reasons this may happen:\n\n - node was installed as 'root' or with 'sudo'\n - the cypress npm package as 'root' or with 'sudo'\n\n Please check that you have the appropriate user permissions.\n\n You can also try clearing the cache with 'cypress cache clear' and reinstalling. \n "], ["\\n\n Reasons this may happen:\n\n - node was installed as 'root' or with 'sudo'\n - the cypress npm package as 'root' or with 'sudo'\n\n Please check that you have the appropriate user permissions.\n\n You can also try clearing the cache with 'cypress cache clear' and reinstalling. \n "]);
|
91
|
+
Reasons it may be missing:
|
125
92
|
|
126
|
-
|
127
|
-
|
128
|
-
};
|
93
|
+
- You're caching 'node_modules' but are not caching this path: ${util.getCacheDir()}
|
94
|
+
- You ran 'npm install' at an earlier build step but did not persist: ${util.getCacheDir()}
|
129
95
|
|
130
|
-
|
131
|
-
}
|
96
|
+
Properly caching the binary will fix this error and avoid downloading and unzipping Cypress.
|
132
97
|
|
133
|
-
|
134
|
-
var data = _taggedTemplateLiteral(["\n \nPlease reinstall Cypress by running: ", "\n "], ["\n \\nPlease reinstall Cypress by running: ", "\n "]);
|
98
|
+
Alternatively, you can run 'cypress install' to download the binary again.
|
135
99
|
|
136
|
-
|
137
|
-
|
100
|
+
${chalk.blue('https://on.cypress.io/not-installed-ci-error')}
|
101
|
+
`
|
138
102
|
};
|
103
|
+
};
|
139
104
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
var data = _taggedTemplateLiteral(["\n Does your workplace require a proxy to be used to access the Internet? If so, you must configure the HTTP_PROXY environment variable before downloading Cypress. Read more: https://on.cypress.io/proxy-configuration\n\n Otherwise, please check network connectivity and try again:"]);
|
105
|
+
const nonZeroExitCodeXvfb = {
|
106
|
+
description: 'Xvfb exited with a non zero exit code.',
|
107
|
+
solution: stripIndent`
|
108
|
+
There was a problem spawning Xvfb.
|
145
109
|
|
146
|
-
|
147
|
-
|
148
|
-
|
110
|
+
This is likely a problem with your system, permissions, or installation of Xvfb.
|
111
|
+
`
|
112
|
+
};
|
113
|
+
const missingXvfb = {
|
114
|
+
description: 'Your system is missing the dependency: Xvfb',
|
115
|
+
solution: stripIndent`
|
116
|
+
Install Xvfb and run Cypress again.
|
149
117
|
|
150
|
-
|
151
|
-
}
|
118
|
+
Read our documentation on dependencies for more information:
|
152
119
|
|
153
|
-
|
154
|
-
var data = _taggedTemplateLiteral(["\n Please provide a valid project path.\n\n Learn more about ", " at:\n\n ", "\n "]);
|
120
|
+
${chalk.blue(requiredDependenciesUrl)}
|
155
121
|
|
156
|
-
|
157
|
-
|
158
|
-
|
122
|
+
If you are using Docker, we provide containers with all required dependencies installed.
|
123
|
+
`
|
124
|
+
};
|
159
125
|
|
160
|
-
|
161
|
-
|
126
|
+
const smokeTestFailure = (smokeTestCommand, timedOut) => {
|
127
|
+
return {
|
128
|
+
description: `Cypress verification ${timedOut ? 'timed out' : 'failed'}.`,
|
129
|
+
solution: stripIndent`
|
130
|
+
This command failed with the following output:
|
162
131
|
|
163
|
-
|
164
|
-
var data = _taggedTemplateLiteral(["\n Search for an existing issue or open a GitHub issue at\n\n ", "\n"]);
|
132
|
+
${smokeTestCommand}
|
165
133
|
|
166
|
-
|
167
|
-
return data;
|
134
|
+
`
|
168
135
|
};
|
136
|
+
};
|
169
137
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
174
|
-
|
175
|
-
var chalk = require('chalk');
|
176
|
-
|
177
|
-
var _require = require('common-tags'),
|
178
|
-
stripIndent = _require.stripIndent,
|
179
|
-
stripIndents = _require.stripIndents;
|
138
|
+
const invalidSmokeTestDisplayError = {
|
139
|
+
code: 'INVALID_SMOKE_TEST_DISPLAY_ERROR',
|
140
|
+
description: 'Cypress verification failed.',
|
180
141
|
|
181
|
-
|
182
|
-
|
142
|
+
solution(msg) {
|
143
|
+
return stripIndent`
|
144
|
+
Cypress failed to start after spawning a new Xvfb server.
|
183
145
|
|
184
|
-
|
146
|
+
The error logs we received were:
|
185
147
|
|
186
|
-
|
148
|
+
${hr}
|
187
149
|
|
188
|
-
|
150
|
+
${msg}
|
189
151
|
|
190
|
-
|
152
|
+
${hr}
|
191
153
|
|
192
|
-
|
193
|
-
var requiredDependenciesUrl = "".concat(docsUrl, "/required-dependencies");
|
194
|
-
var runDocumentationUrl = "".concat(docsUrl, "/cypress-run"); // TODO it would be nice if all error objects could be enforced via types
|
195
|
-
// to only have description + solution properties
|
154
|
+
This is usually caused by a missing library or dependency.
|
196
155
|
|
197
|
-
|
198
|
-
var genericErrorSolution = stripIndent(_templateObject(), chalk.blue(util.issuesUrl)); // common errors Cypress application can encounter
|
156
|
+
The error above should indicate which dependency is missing.
|
199
157
|
|
200
|
-
|
201
|
-
description: 'Unknown Cypress CLI error',
|
202
|
-
solution: genericErrorSolution
|
203
|
-
};
|
204
|
-
var invalidRunProjectPath = {
|
205
|
-
description: 'Invalid --project path',
|
206
|
-
solution: stripIndent(_templateObject2(), chalk.cyan('cypress run'), chalk.blue(runDocumentationUrl))
|
207
|
-
};
|
208
|
-
var failedDownload = {
|
209
|
-
description: 'The Cypress App could not be downloaded.',
|
210
|
-
solution: stripIndent(_templateObject3())
|
211
|
-
};
|
212
|
-
var failedUnzip = {
|
213
|
-
description: 'The Cypress App could not be unzipped.',
|
214
|
-
solution: genericErrorSolution
|
215
|
-
};
|
158
|
+
${chalk.blue(requiredDependenciesUrl)}
|
216
159
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
solution: stripIndent(_templateObject4(), chalk.cyan('cypress install'))
|
221
|
-
};
|
222
|
-
};
|
160
|
+
If you are using Docker, we provide containers with all required dependencies installed.
|
161
|
+
`;
|
162
|
+
}
|
223
163
|
|
224
|
-
var binaryNotExecutable = function binaryNotExecutable(executable) {
|
225
|
-
return {
|
226
|
-
description: "Cypress cannot run because this binary file does not have executable permissions here:\n\n".concat(executable),
|
227
|
-
solution: stripIndent(_templateObject5())
|
228
|
-
};
|
229
|
-
};
|
230
|
-
|
231
|
-
var notInstalledCI = function notInstalledCI(executable) {
|
232
|
-
return {
|
233
|
-
description: 'The cypress npm package is installed, but the Cypress binary is missing.',
|
234
|
-
solution: stripIndent(_templateObject6(), chalk.cyan(executable), util.getCacheDir(), util.getCacheDir(), chalk.blue('https://on.cypress.io/not-installed-ci-error'))
|
235
|
-
};
|
236
164
|
};
|
165
|
+
const missingDependency = {
|
166
|
+
description: 'Cypress failed to start.',
|
167
|
+
// this message is too Linux specific
|
168
|
+
solution: stripIndent`
|
169
|
+
This is usually caused by a missing library or dependency.
|
237
170
|
|
238
|
-
|
239
|
-
description: 'Xvfb exited with a non zero exit code.',
|
240
|
-
solution: stripIndent(_templateObject7())
|
241
|
-
};
|
242
|
-
var missingXvfb = {
|
243
|
-
description: 'Your system is missing the dependency: Xvfb',
|
244
|
-
solution: stripIndent(_templateObject8(), chalk.blue(requiredDependenciesUrl))
|
245
|
-
};
|
171
|
+
The error below should indicate which dependency is missing.
|
246
172
|
|
247
|
-
|
248
|
-
return {
|
249
|
-
description: "Cypress verification ".concat(timedOut ? 'timed out' : 'failed', "."),
|
250
|
-
solution: stripIndent(_templateObject9(), smokeTestCommand)
|
251
|
-
};
|
252
|
-
};
|
173
|
+
${chalk.blue(requiredDependenciesUrl)}
|
253
174
|
|
254
|
-
|
255
|
-
|
256
|
-
description: 'Cypress verification failed.',
|
257
|
-
solution: function solution(msg) {
|
258
|
-
return stripIndent(_templateObject10(), hr, msg, hr, chalk.blue(requiredDependenciesUrl));
|
259
|
-
}
|
175
|
+
If you are using Docker, we provide containers with all required dependencies installed.
|
176
|
+
`
|
260
177
|
};
|
261
|
-
|
262
|
-
description: 'Cypress failed to start.',
|
263
|
-
// this message is too Linux specific
|
264
|
-
solution: stripIndent(_templateObject11(), chalk.blue(requiredDependenciesUrl))
|
265
|
-
};
|
266
|
-
var invalidCacheDirectory = {
|
178
|
+
const invalidCacheDirectory = {
|
267
179
|
description: 'Cypress cannot write to the cache directory due to file permissions',
|
268
|
-
solution: stripIndent
|
180
|
+
solution: stripIndent`
|
181
|
+
See discussion and possible solutions at
|
182
|
+
${chalk.blue(util.getGitHubIssueUrl(1281))}
|
183
|
+
`
|
269
184
|
};
|
270
|
-
|
185
|
+
const versionMismatch = {
|
271
186
|
description: 'Installed version does not match package version.',
|
272
187
|
solution: 'Install Cypress and verify app again'
|
273
188
|
};
|
274
|
-
|
189
|
+
const incompatibleHeadlessFlags = {
|
275
190
|
description: '`--headed` and `--headless` cannot both be passed.',
|
276
191
|
solution: 'Either pass `--headed` or `--headless`, but not both.'
|
277
192
|
};
|
278
|
-
|
279
|
-
|
193
|
+
const solutionUnknown = stripIndent`
|
194
|
+
Please search Cypress documentation for possible solutions:
|
195
|
+
|
196
|
+
${chalk.blue(docsUrl)}
|
197
|
+
|
198
|
+
Check if there is a GitHub issue describing this crash:
|
199
|
+
|
200
|
+
${chalk.blue(util.issuesUrl)}
|
201
|
+
|
202
|
+
Consider opening a new issue.
|
203
|
+
`;
|
204
|
+
const unexpected = {
|
280
205
|
description: 'An unexpected error occurred while verifying the Cypress executable.',
|
281
206
|
solution: solutionUnknown
|
282
207
|
};
|
283
|
-
|
208
|
+
const invalidCypressEnv = {
|
284
209
|
description: chalk.red('The environment variable with the reserved name "CYPRESS_INTERNAL_ENV" is set.'),
|
285
210
|
solution: chalk.red('Unset the "CYPRESS_INTERNAL_ENV" environment variable and run Cypress again.'),
|
286
211
|
exitCode: 11
|
@@ -293,37 +218,45 @@ var invalidCypressEnv = {
|
|
293
218
|
* @param {string} signal Signal that closed the child process, like "SIGBUS"
|
294
219
|
*/
|
295
220
|
|
296
|
-
|
221
|
+
const childProcessKilled = (eventName, signal) => {
|
297
222
|
return {
|
298
|
-
description:
|
223
|
+
description: `The Test Runner unexpectedly exited via a ${chalk.cyan(eventName)} event with signal ${chalk.cyan(signal)}`,
|
299
224
|
solution: solutionUnknown
|
300
225
|
};
|
301
226
|
};
|
302
227
|
|
303
|
-
|
228
|
+
const removed = {
|
304
229
|
CYPRESS_BINARY_VERSION: {
|
305
|
-
description: stripIndent
|
306
|
-
|
230
|
+
description: stripIndent`
|
231
|
+
The environment variable CYPRESS_BINARY_VERSION has been renamed to CYPRESS_INSTALL_BINARY as of version ${chalk.green('3.0.0')}
|
232
|
+
`,
|
233
|
+
solution: stripIndent`
|
234
|
+
You should set CYPRESS_INSTALL_BINARY instead.
|
235
|
+
`
|
307
236
|
},
|
308
237
|
CYPRESS_SKIP_BINARY_INSTALL: {
|
309
|
-
description: stripIndent
|
310
|
-
|
238
|
+
description: stripIndent`
|
239
|
+
The environment variable CYPRESS_SKIP_BINARY_INSTALL has been removed as of version ${chalk.green('3.0.0')}
|
240
|
+
`,
|
241
|
+
solution: stripIndent`
|
242
|
+
To skip the binary install, set CYPRESS_INSTALL_BINARY=0
|
243
|
+
`
|
311
244
|
}
|
312
245
|
};
|
313
|
-
|
314
|
-
notValid:
|
315
|
-
|
246
|
+
const CYPRESS_RUN_BINARY = {
|
247
|
+
notValid: value => {
|
248
|
+
const properFormat = `**/${state.getPlatformExecutable()}`;
|
316
249
|
return {
|
317
|
-
description:
|
318
|
-
solution:
|
250
|
+
description: `Could not run binary set by environment variable: CYPRESS_RUN_BINARY=${value}`,
|
251
|
+
solution: `Ensure the environment variable is a path to the Cypress binary, matching ${properFormat}`
|
319
252
|
};
|
320
253
|
}
|
321
254
|
};
|
322
255
|
|
323
256
|
function addPlatformInformation(info) {
|
324
|
-
return util.getPlatformInfo().then(
|
257
|
+
return util.getPlatformInfo().then(platform => {
|
325
258
|
return merge(info, {
|
326
|
-
platform
|
259
|
+
platform
|
327
260
|
});
|
328
261
|
});
|
329
262
|
}
|
@@ -342,8 +275,8 @@ function addPlatformInformation(info) {
|
|
342
275
|
|
343
276
|
|
344
277
|
function getError(errorObject) {
|
345
|
-
return formErrorText(errorObject).then(
|
346
|
-
|
278
|
+
return formErrorText(errorObject).then(errorMessage => {
|
279
|
+
const err = new Error(errorMessage);
|
347
280
|
err.known = true;
|
348
281
|
return err;
|
349
282
|
});
|
@@ -355,8 +288,8 @@ function getError(errorObject) {
|
|
355
288
|
|
356
289
|
|
357
290
|
function formErrorText(info, msg, prevMessage) {
|
358
|
-
return addPlatformInformation(info).then(
|
359
|
-
|
291
|
+
return addPlatformInformation(info).then(obj => {
|
292
|
+
const formatted = [];
|
360
293
|
|
361
294
|
function add(msg) {
|
362
295
|
formatted.push(stripIndents(msg));
|
@@ -366,31 +299,55 @@ function formErrorText(info, msg, prevMessage) {
|
|
366
299
|
// error message and (optional previous error message)
|
367
300
|
|
368
301
|
if (is.fn(obj.solution)) {
|
369
|
-
|
302
|
+
const text = obj.solution(msg, prevMessage);
|
370
303
|
la(is.unemptyString(text), 'expected solution to be text', text);
|
371
|
-
add(
|
304
|
+
add(`
|
305
|
+
${obj.description}
|
306
|
+
|
307
|
+
${text}
|
308
|
+
|
309
|
+
`);
|
372
310
|
} else {
|
373
311
|
la(is.unemptyString(obj.solution), 'expected error solution to be text', obj.solution);
|
374
|
-
add(
|
312
|
+
add(`
|
313
|
+
${obj.description}
|
314
|
+
|
315
|
+
${obj.solution}
|
316
|
+
|
317
|
+
`);
|
375
318
|
|
376
319
|
if (msg) {
|
377
|
-
add(
|
320
|
+
add(`
|
321
|
+
${hr}
|
322
|
+
|
323
|
+
${msg}
|
324
|
+
|
325
|
+
`);
|
378
326
|
}
|
379
327
|
}
|
380
328
|
|
381
|
-
add(
|
329
|
+
add(`
|
330
|
+
${hr}
|
331
|
+
|
332
|
+
${obj.platform}
|
333
|
+
`);
|
382
334
|
|
383
335
|
if (obj.footer) {
|
384
|
-
add(
|
336
|
+
add(`
|
337
|
+
|
338
|
+
${hr}
|
339
|
+
|
340
|
+
${obj.footer}
|
341
|
+
`);
|
385
342
|
}
|
386
343
|
|
387
344
|
return formatted.join('\n\n');
|
388
345
|
});
|
389
346
|
}
|
390
347
|
|
391
|
-
|
392
|
-
return
|
393
|
-
|
348
|
+
const raise = info => {
|
349
|
+
return text => {
|
350
|
+
const err = new Error(text);
|
394
351
|
|
395
352
|
if (info.code) {
|
396
353
|
err.code = info.code;
|
@@ -401,8 +358,8 @@ var raise = function raise(info) {
|
|
401
358
|
};
|
402
359
|
};
|
403
360
|
|
404
|
-
|
405
|
-
return
|
361
|
+
const throwFormErrorText = info => {
|
362
|
+
return (msg, prevMessage) => {
|
406
363
|
return formErrorText(info, msg, prevMessage).then(raise(info));
|
407
364
|
};
|
408
365
|
};
|
@@ -414,9 +371,9 @@ var throwFormErrorText = function throwFormErrorText(info) {
|
|
414
371
|
*/
|
415
372
|
|
416
373
|
|
417
|
-
|
418
|
-
return
|
419
|
-
return formErrorText(info, msg).then(
|
374
|
+
const exitWithError = info => {
|
375
|
+
return msg => {
|
376
|
+
return formErrorText(info, msg).then(text => {
|
420
377
|
// eslint-disable-next-line no-console
|
421
378
|
console.error(text);
|
422
379
|
process.exit(info.exitCode || 1);
|
@@ -425,33 +382,33 @@ var exitWithError = function exitWithError(info) {
|
|
425
382
|
};
|
426
383
|
|
427
384
|
module.exports = {
|
428
|
-
raise
|
429
|
-
exitWithError
|
385
|
+
raise,
|
386
|
+
exitWithError,
|
430
387
|
// formError,
|
431
|
-
formErrorText
|
432
|
-
throwFormErrorText
|
433
|
-
getError
|
434
|
-
hr
|
388
|
+
formErrorText,
|
389
|
+
throwFormErrorText,
|
390
|
+
getError,
|
391
|
+
hr,
|
435
392
|
errors: {
|
436
|
-
unknownError
|
437
|
-
nonZeroExitCodeXvfb
|
438
|
-
missingXvfb
|
439
|
-
missingApp
|
440
|
-
notInstalledCI
|
441
|
-
missingDependency
|
442
|
-
invalidSmokeTestDisplayError
|
443
|
-
versionMismatch
|
444
|
-
binaryNotExecutable
|
445
|
-
unexpected
|
446
|
-
failedDownload
|
447
|
-
failedUnzip
|
448
|
-
invalidCypressEnv
|
449
|
-
invalidCacheDirectory
|
450
|
-
removed
|
451
|
-
CYPRESS_RUN_BINARY
|
452
|
-
smokeTestFailure
|
453
|
-
childProcessKilled
|
454
|
-
incompatibleHeadlessFlags
|
455
|
-
invalidRunProjectPath
|
393
|
+
unknownError,
|
394
|
+
nonZeroExitCodeXvfb,
|
395
|
+
missingXvfb,
|
396
|
+
missingApp,
|
397
|
+
notInstalledCI,
|
398
|
+
missingDependency,
|
399
|
+
invalidSmokeTestDisplayError,
|
400
|
+
versionMismatch,
|
401
|
+
binaryNotExecutable,
|
402
|
+
unexpected,
|
403
|
+
failedDownload,
|
404
|
+
failedUnzip,
|
405
|
+
invalidCypressEnv,
|
406
|
+
invalidCacheDirectory,
|
407
|
+
removed,
|
408
|
+
CYPRESS_RUN_BINARY,
|
409
|
+
smokeTestFailure,
|
410
|
+
childProcessKilled,
|
411
|
+
incompatibleHeadlessFlags,
|
412
|
+
invalidRunProjectPath
|
456
413
|
}
|
457
414
|
};
|