cypress 12.1.0 → 12.3.0
Sign up to get free protection for your applications and to get access to all the features.
- package/angular/dist/index.js +1 -1
- package/index.js +2 -11
- package/lib/VerboseRenderer.js +2 -16
- package/lib/cli.js +25 -83
- package/lib/cypress.js +1 -14
- package/lib/errors.js +13 -38
- package/lib/exec/info.js +10 -31
- package/lib/exec/open.js +1 -24
- package/lib/exec/run.js +15 -52
- package/lib/exec/shared.js +6 -15
- package/lib/exec/spawn.js +45 -88
- package/lib/exec/versions.js +0 -9
- package/lib/exec/xvfb.js +5 -18
- package/lib/fs.js +0 -1
- package/lib/logger.js +3 -10
- package/lib/tasks/cache.js +5 -29
- package/lib/tasks/download.js +21 -57
- package/lib/tasks/get-folder-size.js +1 -9
- package/lib/tasks/install.js +20 -66
- package/lib/tasks/state.js +5 -51
- package/lib/tasks/unzip.js +7 -41
- package/lib/tasks/verify.js +11 -65
- package/lib/util.js +41 -128
- package/mount-utils/package.json +2 -2
- package/package.json +3 -3
- package/react/dist/cypress-react.cjs.js +8 -15
- package/react/dist/cypress-react.esm-bundler.js +1 -1
- package/react/package.json +1 -1
- package/react18/dist/cypress-react.cjs.js +7 -13
- package/react18/dist/cypress-react.esm-bundler.js +1 -1
- package/react18/package.json +1 -1
- package/svelte/dist/cypress-svelte.cjs.js +2 -4
- package/svelte/dist/cypress-svelte.esm-bundler.js +2 -2
- package/types/cypress.d.ts +11 -6
- package/types/net-stubbing.d.ts +11 -0
- package/vue/dist/cypress-vue.cjs.js +4 -7
- package/vue/dist/cypress-vue.esm-bundler.js +1 -1
- package/vue/package.json +1 -1
- package/vue2/dist/cypress-vue2.cjs.js +19 -28
- package/vue2/dist/cypress-vue2.esm-bundler.js +1 -4
package/angular/dist/index.js
CHANGED
package/index.js
CHANGED
@@ -1,35 +1,26 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
const minimist = require('minimist');
|
4
|
-
|
5
4
|
const debug = require('debug')('cypress:cli');
|
6
|
-
|
7
5
|
const args = minimist(process.argv.slice(2));
|
6
|
+
const util = require('./lib/util');
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
8
|
+
// we're being used from the command line
|
12
9
|
switch (args.exec) {
|
13
10
|
case 'install':
|
14
11
|
debug('installing Cypress from NPM');
|
15
|
-
|
16
12
|
require('./lib/tasks/install').start({
|
17
13
|
force: args.force
|
18
14
|
}).catch(util.logErrorExit1);
|
19
|
-
|
20
15
|
break;
|
21
|
-
|
22
16
|
case 'verify':
|
23
17
|
// for simple testing in the monorepo
|
24
18
|
debug('verifying Cypress');
|
25
|
-
|
26
19
|
require('./lib/tasks/verify').start({
|
27
20
|
force: true
|
28
21
|
}) // always force verification
|
29
22
|
.catch(util.logErrorExit1);
|
30
|
-
|
31
23
|
break;
|
32
|
-
|
33
24
|
default:
|
34
25
|
debug('exporting Cypress module interface');
|
35
26
|
module.exports = require('./lib/cypress');
|
package/lib/VerboseRenderer.js
CHANGED
@@ -2,26 +2,20 @@
|
|
2
2
|
|
3
3
|
// Vendored from @cypress/listr-verbose-renderer
|
4
4
|
const figures = require('figures');
|
5
|
-
|
6
5
|
const cliCursor = require('cli-cursor');
|
7
|
-
|
8
6
|
const chalk = require('chalk');
|
9
|
-
|
10
7
|
const dayjs = require('dayjs');
|
11
|
-
|
12
8
|
const formattedLog = (options, output) => {
|
13
|
-
const timestamp = dayjs().format(options.dateFormat);
|
9
|
+
const timestamp = dayjs().format(options.dateFormat);
|
14
10
|
|
11
|
+
// eslint-disable-next-line no-console
|
15
12
|
console.log(`${chalk.dim(`[${timestamp}]`)} ${output}`);
|
16
13
|
};
|
17
|
-
|
18
14
|
const renderHelper = (task, event, options) => {
|
19
15
|
const log = formattedLog.bind(undefined, options);
|
20
|
-
|
21
16
|
if (event.type === 'STATE') {
|
22
17
|
const message = task.isPending() ? 'started' : task.state;
|
23
18
|
log(`${task.title} [${message}]`);
|
24
|
-
|
25
19
|
if (task.isSkipped() && task.output) {
|
26
20
|
log(`${figures.arrowRight} ${task.output}`);
|
27
21
|
}
|
@@ -29,7 +23,6 @@ const renderHelper = (task, event, options) => {
|
|
29
23
|
log(`${task.title} [title changed]`);
|
30
24
|
}
|
31
25
|
};
|
32
|
-
|
33
26
|
const render = (tasks, options) => {
|
34
27
|
for (const task of tasks) {
|
35
28
|
task.subscribe(event => {
|
@@ -37,7 +30,6 @@ const render = (tasks, options) => {
|
|
37
30
|
render(task.subtasks, options);
|
38
31
|
return;
|
39
32
|
}
|
40
|
-
|
41
33
|
renderHelper(task, event, options);
|
42
34
|
}, err => {
|
43
35
|
// eslint-disable-next-line no-console
|
@@ -45,7 +37,6 @@ const render = (tasks, options) => {
|
|
45
37
|
});
|
46
38
|
}
|
47
39
|
};
|
48
|
-
|
49
40
|
class VerboseRenderer {
|
50
41
|
constructor(tasks, options) {
|
51
42
|
this._tasks = tasks;
|
@@ -53,20 +44,15 @@ class VerboseRenderer {
|
|
53
44
|
dateFormat: 'HH:mm:ss'
|
54
45
|
}, options);
|
55
46
|
}
|
56
|
-
|
57
47
|
static get nonTTY() {
|
58
48
|
return true;
|
59
49
|
}
|
60
|
-
|
61
50
|
render() {
|
62
51
|
cliCursor.hide();
|
63
52
|
render(this._tasks, this._options);
|
64
53
|
}
|
65
|
-
|
66
54
|
end() {
|
67
55
|
cliCursor.show();
|
68
56
|
}
|
69
|
-
|
70
57
|
}
|
71
|
-
|
72
58
|
module.exports = VerboseRenderer;
|
package/lib/cli.js
CHANGED
@@ -2,27 +2,19 @@
|
|
2
2
|
|
3
3
|
// @ts-check
|
4
4
|
const _ = require('lodash');
|
5
|
-
|
6
5
|
const commander = require('commander');
|
7
|
-
|
8
6
|
const {
|
9
7
|
stripIndent
|
10
8
|
} = require('common-tags');
|
11
|
-
|
12
9
|
const logSymbols = require('log-symbols');
|
13
|
-
|
14
10
|
const debug = require('debug')('cypress:cli:cli');
|
15
|
-
|
16
11
|
const util = require('./util');
|
17
|
-
|
18
12
|
const logger = require('./logger');
|
19
|
-
|
20
13
|
const errors = require('./errors');
|
14
|
+
const cache = require('./tasks/cache');
|
21
15
|
|
22
|
-
|
16
|
+
// patch "commander" method called when a user passed an unknown option
|
23
17
|
// we want to print help for the current command and exit with an error
|
24
|
-
|
25
|
-
|
26
18
|
function unknownOption(flag, type = 'option') {
|
27
19
|
if (this._allowUnknownOption) return;
|
28
20
|
logger.error();
|
@@ -31,17 +23,13 @@ function unknownOption(flag, type = 'option') {
|
|
31
23
|
this.outputHelp();
|
32
24
|
util.exit(1);
|
33
25
|
}
|
34
|
-
|
35
26
|
commander.Command.prototype.unknownOption = unknownOption;
|
36
|
-
|
37
27
|
const coerceFalse = arg => {
|
38
28
|
return arg !== 'false';
|
39
29
|
};
|
40
|
-
|
41
30
|
const coerceAnyStringToInt = arg => {
|
42
31
|
return typeof arg === 'string' ? parseInt(arg) : arg;
|
43
32
|
};
|
44
|
-
|
45
33
|
const spaceDelimitedArgsMsg = (flag, args) => {
|
46
34
|
let msg = `
|
47
35
|
${logSymbols.warning} Warning: It looks like you're passing --${flag} a space-separated list of arguments:
|
@@ -53,7 +41,6 @@ const spaceDelimitedArgsMsg = (flag, args) => {
|
|
53
41
|
If you are trying to pass multiple arguments, separate them with commas instead:
|
54
42
|
cypress run --${flag} arg1,arg2,arg3
|
55
43
|
`;
|
56
|
-
|
57
44
|
if (flag === 'spec') {
|
58
45
|
msg += `
|
59
46
|
The most common cause of this warning is using an unescaped glob pattern. If you are
|
@@ -61,35 +48,27 @@ const spaceDelimitedArgsMsg = (flag, args) => {
|
|
61
48
|
cypress run --spec "**/*.spec.js"
|
62
49
|
`;
|
63
50
|
}
|
64
|
-
|
65
51
|
logger.log();
|
66
52
|
logger.warn(stripIndent(msg));
|
67
53
|
logger.log();
|
68
54
|
};
|
69
|
-
|
70
55
|
const parseVariableOpts = (fnArgs, args) => {
|
71
56
|
const [opts, unknownArgs] = fnArgs;
|
72
|
-
|
73
57
|
if (unknownArgs && unknownArgs.length && (opts.spec || opts.tag)) {
|
74
58
|
// this will capture space-delimited args after
|
75
59
|
// flags that could have possible multiple args
|
76
60
|
// but before the next option
|
77
61
|
// --spec spec1 spec2 or --tag foo bar
|
78
|
-
const multiArgFlags = _.compact([opts.spec ? 'spec' : opts.spec, opts.tag ? 'tag' : opts.tag]);
|
79
62
|
|
63
|
+
const multiArgFlags = _.compact([opts.spec ? 'spec' : opts.spec, opts.tag ? 'tag' : opts.tag]);
|
80
64
|
_.forEach(multiArgFlags, flag => {
|
81
65
|
const argIndex = _.indexOf(args, `--${flag}`) + 2;
|
82
|
-
|
83
66
|
const nextOptOffset = _.findIndex(_.slice(args, argIndex), arg => {
|
84
67
|
return _.startsWith(arg, '--');
|
85
68
|
});
|
86
|
-
|
87
69
|
const endIndex = nextOptOffset !== -1 ? argIndex + nextOptOffset : args.length;
|
88
|
-
|
89
70
|
const maybeArgs = _.slice(args, argIndex, endIndex);
|
90
|
-
|
91
71
|
const extraArgs = _.intersection(maybeArgs, unknownArgs);
|
92
|
-
|
93
72
|
if (extraArgs.length) {
|
94
73
|
opts[flag] = [opts[flag]].concat(extraArgs);
|
95
74
|
spaceDelimitedArgsMsg(flag, opts[flag]);
|
@@ -97,14 +76,12 @@ const parseVariableOpts = (fnArgs, args) => {
|
|
97
76
|
}
|
98
77
|
});
|
99
78
|
}
|
100
|
-
|
101
79
|
debug('variable-length opts parsed %o', {
|
102
80
|
args,
|
103
81
|
opts
|
104
82
|
});
|
105
83
|
return util.parseOpts(opts);
|
106
84
|
};
|
107
|
-
|
108
85
|
const descriptions = {
|
109
86
|
browser: 'runs Cypress in the browser with the given name. if a filesystem path is supplied, Cypress will attempt to use the browser at that path.',
|
110
87
|
cacheClear: 'delete all cached binaries',
|
@@ -139,19 +116,15 @@ const descriptions = {
|
|
139
116
|
version: 'prints Cypress version'
|
140
117
|
};
|
141
118
|
const knownCommands = ['cache', 'help', '-h', '--help', 'install', 'open', 'run', 'open-ct', 'run-ct', 'verify', '-v', '--version', 'version', 'info'];
|
142
|
-
|
143
119
|
const text = description => {
|
144
120
|
if (!descriptions[description]) {
|
145
121
|
throw new Error(`Could not find description for: ${description}`);
|
146
122
|
}
|
147
|
-
|
148
123
|
return descriptions[description];
|
149
124
|
};
|
150
|
-
|
151
125
|
function includesVersion(args) {
|
152
126
|
return _.includes(args, 'version') || _.includes(args, '--version') || _.includes(args, '-v');
|
153
127
|
}
|
154
|
-
|
155
128
|
function showVersions(args) {
|
156
129
|
debug('printing Cypress version');
|
157
130
|
debug('additional arguments %o', args);
|
@@ -161,14 +134,12 @@ function showVersions(args) {
|
|
161
134
|
component: parsed.component
|
162
135
|
};
|
163
136
|
debug('parsed version arguments %o', parsedOptions);
|
164
|
-
|
165
137
|
const reportAllVersions = versions => {
|
166
138
|
logger.always('Cypress package version:', versions.package);
|
167
139
|
logger.always('Cypress binary version:', versions.binary);
|
168
140
|
logger.always('Electron version:', versions.electronVersion);
|
169
141
|
logger.always('Bundled Node version:', versions.electronNodeVersion);
|
170
142
|
};
|
171
|
-
|
172
143
|
const reportComponentVersion = (componentName, versions) => {
|
173
144
|
const names = {
|
174
145
|
package: 'package',
|
@@ -176,21 +147,16 @@ function showVersions(args) {
|
|
176
147
|
electron: 'electronVersion',
|
177
148
|
node: 'electronNodeVersion'
|
178
149
|
};
|
179
|
-
|
180
150
|
if (!names[componentName]) {
|
181
151
|
throw new Error(`Unknown component name "${componentName}"`);
|
182
152
|
}
|
183
|
-
|
184
153
|
const name = names[componentName];
|
185
|
-
|
186
154
|
if (!versions[name]) {
|
187
155
|
throw new Error(`Cannot find version for component "${componentName}" under property "${name}"`);
|
188
156
|
}
|
189
|
-
|
190
157
|
const version = versions[name];
|
191
158
|
logger.always(version);
|
192
159
|
};
|
193
|
-
|
194
160
|
const defaultVersions = {
|
195
161
|
package: undefined,
|
196
162
|
binary: undefined,
|
@@ -203,35 +169,31 @@ function showVersions(args) {
|
|
203
169
|
} else {
|
204
170
|
reportAllVersions(versions);
|
205
171
|
}
|
206
|
-
|
207
172
|
process.exit(0);
|
208
173
|
}).catch(util.logErrorExit1);
|
209
174
|
}
|
210
|
-
|
211
175
|
const createProgram = () => {
|
212
|
-
const program = new commander.Command();
|
213
|
-
// in usage help docs
|
176
|
+
const program = new commander.Command();
|
214
177
|
|
178
|
+
// bug in commander not printing name
|
179
|
+
// in usage help docs
|
215
180
|
program._name = 'cypress';
|
216
181
|
program.usage('<command> [options]');
|
217
182
|
return program;
|
218
183
|
};
|
219
|
-
|
220
184
|
const addCypressRunCommand = program => {
|
221
185
|
return program.command('run').usage('[options]').description('Runs Cypress tests from the CLI without the GUI').option('-b, --browser <browser-name-or-path>', text('browser')).option('--ci-build-id <id>', text('ciBuildId')).option('--component', text('component')).option('-c, --config <config>', text('config')).option('-C, --config-file <config-file>', text('configFile')).option('--e2e', text('e2e')).option('-e, --env <env>', text('env')).option('--group <name>', text('group')).option('-k, --key <record-key>', text('key')).option('--headed', text('headed')).option('--headless', text('headless')).option('--no-exit', text('exit')).option('--parallel', text('parallel')).option('-p, --port <port>', text('port')).option('-P, --project <project-path>', text('project')).option('-q, --quiet', text('quiet')).option('--record [bool]', text('record'), coerceFalse).option('-r, --reporter <reporter>', text('reporter')).option('-o, --reporter-options <reporter-options>', text('reporterOptions')).option('-s, --spec <spec>', text('spec')).option('-t, --tag <tag>', text('tag')).option('--dev', text('dev'), coerceFalse);
|
222
186
|
};
|
223
|
-
|
224
187
|
const addCypressOpenCommand = program => {
|
225
188
|
return program.command('open').usage('[options]').description('Opens Cypress in the interactive GUI.').option('-b, --browser <browser-path>', text('browser')).option('--component', text('component')).option('-c, --config <config>', text('config')).option('-C, --config-file <config-file>', text('configFile')).option('-d, --detached [bool]', text('detached'), coerceFalse).option('--e2e', text('e2e')).option('-e, --env <env>', text('env')).option('--global', text('global')).option('-p, --port <port>', text('port')).option('-P, --project <project-path>', text('project')).option('--dev', text('dev'), coerceFalse);
|
226
189
|
};
|
227
|
-
|
228
190
|
const maybeAddInspectFlags = program => {
|
229
191
|
if (process.argv.includes('--dev')) {
|
230
192
|
return program.option('--inspect', 'Node option').option('--inspect-brk', 'Node option');
|
231
193
|
}
|
232
|
-
|
233
194
|
return program;
|
234
195
|
};
|
196
|
+
|
235
197
|
/**
|
236
198
|
* Casts known command line options for "cypress run" to their intended type.
|
237
199
|
* For example if the user passes "--port 5005" the ".port" property should be
|
@@ -239,22 +201,18 @@ const maybeAddInspectFlags = program => {
|
|
239
201
|
*
|
240
202
|
* Returns a clone of the original object.
|
241
203
|
*/
|
242
|
-
|
243
|
-
|
244
204
|
const castCypressOptions = opts => {
|
245
205
|
// only properties that have type "string | false" in our TS definition
|
246
206
|
// require special handling, because CLI parsing takes care of purely
|
247
207
|
// boolean arguments
|
248
|
-
const castOpts = {
|
208
|
+
const castOpts = {
|
209
|
+
...opts
|
249
210
|
};
|
250
|
-
|
251
211
|
if (_.has(opts, 'port')) {
|
252
212
|
castOpts.port = coerceAnyStringToInt(opts.port);
|
253
213
|
}
|
254
|
-
|
255
214
|
return castOpts;
|
256
215
|
};
|
257
|
-
|
258
216
|
module.exports = {
|
259
217
|
/**
|
260
218
|
* Parses `cypress run` command line option array into an object
|
@@ -267,11 +225,11 @@ module.exports = {
|
|
267
225
|
return new Promise((resolve, reject) => {
|
268
226
|
if (!Array.isArray(args)) {
|
269
227
|
return reject(new Error('Expected array of arguments'));
|
270
|
-
}
|
228
|
+
}
|
229
|
+
|
230
|
+
// make a copy of the input arguments array
|
271
231
|
// and add placeholders where "node ..." would usually be
|
272
232
|
// also remove "cypress" keyword at the start if present
|
273
|
-
|
274
|
-
|
275
233
|
const cliArgs = args[0] === 'cypress' ? [...args.slice(1)] : [...args];
|
276
234
|
cliArgs.unshift(null, null);
|
277
235
|
debug('creating program parser');
|
@@ -288,7 +246,6 @@ module.exports = {
|
|
288
246
|
program.parse(cliArgs);
|
289
247
|
});
|
290
248
|
},
|
291
|
-
|
292
249
|
/**
|
293
250
|
* Parses `cypress open` command line option array into an object
|
294
251
|
* with options that you can feed into cy.openModeSystemTest test calls
|
@@ -300,11 +257,11 @@ module.exports = {
|
|
300
257
|
return new Promise((resolve, reject) => {
|
301
258
|
if (!Array.isArray(args)) {
|
302
259
|
return reject(new Error('Expected array of arguments'));
|
303
|
-
}
|
260
|
+
}
|
261
|
+
|
262
|
+
// make a copy of the input arguments array
|
304
263
|
// and add placeholders where "node ..." would usually be
|
305
264
|
// also remove "cypress" keyword at the start if present
|
306
|
-
|
307
|
-
|
308
265
|
const cliArgs = args[0] === 'cypress' ? [...args.slice(1)] : [...args];
|
309
266
|
cliArgs.unshift(null, null);
|
310
267
|
debug('creating program parser');
|
@@ -321,7 +278,6 @@ module.exports = {
|
|
321
278
|
program.parse(cliArgs);
|
322
279
|
});
|
323
280
|
},
|
324
|
-
|
325
281
|
/**
|
326
282
|
* Parses the command line and kicks off Cypress process.
|
327
283
|
*/
|
@@ -329,12 +285,10 @@ module.exports = {
|
|
329
285
|
if (!args) {
|
330
286
|
args = process.argv;
|
331
287
|
}
|
332
|
-
|
333
288
|
const {
|
334
289
|
CYPRESS_INTERNAL_ENV,
|
335
290
|
CYPRESS_DOWNLOAD_USE_CA
|
336
291
|
} = process.env;
|
337
|
-
|
338
292
|
if (process.env.CYPRESS_DOWNLOAD_USE_CA) {
|
339
293
|
let msg = `
|
340
294
|
${logSymbols.warning} Warning: It looks like you're setting CYPRESS_DOWNLOAD_USE_CA=${CYPRESS_DOWNLOAD_USE_CA}
|
@@ -347,12 +301,10 @@ module.exports = {
|
|
347
301
|
logger.warn(stripIndent(msg));
|
348
302
|
logger.log();
|
349
303
|
}
|
350
|
-
|
351
304
|
if (!util.isValidCypressInternalEnvValue(CYPRESS_INTERNAL_ENV)) {
|
352
305
|
debug('invalid CYPRESS_INTERNAL_ENV value', CYPRESS_INTERNAL_ENV);
|
353
306
|
return errors.exitWithError(errors.errors.invalidCypressEnv)(`CYPRESS_INTERNAL_ENV=${CYPRESS_INTERNAL_ENV}`);
|
354
307
|
}
|
355
|
-
|
356
308
|
if (util.isNonProductionCypressInternalEnvValue(CYPRESS_INTERNAL_ENV)) {
|
357
309
|
debug('non-production CYPRESS_INTERNAL_ENV value', CYPRESS_INTERNAL_ENV);
|
358
310
|
let msg = `
|
@@ -366,7 +318,6 @@ module.exports = {
|
|
366
318
|
logger.warn(stripIndent(msg));
|
367
319
|
logger.log();
|
368
320
|
}
|
369
|
-
|
370
321
|
const program = createProgram();
|
371
322
|
program.command('help').description('Shows CLI help and exits').action(() => {
|
372
323
|
program.help();
|
@@ -376,12 +327,10 @@ module.exports = {
|
|
376
327
|
});
|
377
328
|
maybeAddInspectFlags(addCypressOpenCommand(program)).action(opts => {
|
378
329
|
debug('opening Cypress');
|
379
|
-
|
380
330
|
require('./exec/open').start(util.parseOpts(opts)).then(util.exit).catch(util.logErrorExit1);
|
381
331
|
});
|
382
332
|
maybeAddInspectFlags(addCypressRunCommand(program)).action((...fnArgs) => {
|
383
333
|
debug('running Cypress with args %o', fnArgs);
|
384
|
-
|
385
334
|
require('./exec/run').start(parseVariableOpts(fnArgs, args)).then(util.exit).catch(util.logErrorExit1);
|
386
335
|
});
|
387
336
|
program.command('open-ct').usage('[options]').description('Opens Cypress component testing interactive mode. Deprecated: use "open --component"').option('-b, --browser <browser-path>', text('browser')).option('-c, --config <config>', text('config')).option('-C, --config-file <config-file>', text('configFile')).option('-d, --detached [bool]', text('detached'), coerceFalse).option('-e, --env <env>', text('env')).option('--global', text('global')).option('-p, --port <port>', text('port')).option('-P, --project <project-path>', text('project')).option('--dev', text('dev'), coerceFalse).action(opts => {
|
@@ -394,8 +343,8 @@ module.exports = {
|
|
394
343
|
logger.warn();
|
395
344
|
logger.warn(stripIndent(msg));
|
396
345
|
logger.warn();
|
397
|
-
|
398
|
-
|
346
|
+
require('./exec/open').start({
|
347
|
+
...util.parseOpts(opts),
|
399
348
|
testingType: 'component'
|
400
349
|
}).then(util.exit).catch(util.logErrorExit1);
|
401
350
|
});
|
@@ -408,8 +357,8 @@ module.exports = {
|
|
408
357
|
logger.warn();
|
409
358
|
logger.warn(stripIndent(msg));
|
410
359
|
logger.warn();
|
411
|
-
|
412
|
-
|
360
|
+
require('./exec/run').start({
|
361
|
+
...util.parseOpts(opts),
|
413
362
|
testingType: 'component'
|
414
363
|
}).then(util.exit).catch(util.logErrorExit1);
|
415
364
|
});
|
@@ -422,9 +371,7 @@ module.exports = {
|
|
422
371
|
welcomeMessage: false
|
423
372
|
};
|
424
373
|
const parsedOpts = util.parseOpts(opts);
|
425
|
-
|
426
374
|
const options = _.extend(parsedOpts, defaultOpts);
|
427
|
-
|
428
375
|
require('./tasks/verify').start(options).catch(util.logErrorExit1);
|
429
376
|
});
|
430
377
|
program.command('cache').usage('[command]').description('Manages the Cypress binary cache').option('list', text('cacheList')).option('path', text('cachePath')).option('clear', text('cacheClear')).option('prune', text('cachePrune')).option('--size', text('cacheSize')).action(function (opts, args) {
|
@@ -432,13 +379,10 @@ module.exports = {
|
|
432
379
|
this.outputHelp();
|
433
380
|
util.exit(1);
|
434
381
|
}
|
435
|
-
|
436
382
|
const [command] = args;
|
437
|
-
|
438
383
|
if (!_.includes(['list', 'path', 'clear', 'prune'], command)) {
|
439
384
|
unknownOption.call(this, `cache ${command}`, 'command');
|
440
385
|
}
|
441
|
-
|
442
386
|
if (command === 'list') {
|
443
387
|
debug('cache command %o', {
|
444
388
|
command,
|
@@ -454,29 +398,28 @@ module.exports = {
|
|
454
398
|
util.logErrorExit1(e);
|
455
399
|
});
|
456
400
|
}
|
457
|
-
|
458
401
|
cache[command]();
|
459
402
|
});
|
460
403
|
program.command('info').usage('[command]').description('Prints Cypress and system information').option('--dev', text('dev'), coerceFalse).action(opts => {
|
461
404
|
require('./exec/info').start(opts).then(util.exit).catch(util.logErrorExit1);
|
462
405
|
});
|
463
406
|
debug('cli starts with arguments %j', args);
|
464
|
-
util.printNodeOptions();
|
407
|
+
util.printNodeOptions();
|
465
408
|
|
409
|
+
// if there are no arguments
|
466
410
|
if (args.length <= 2) {
|
467
411
|
debug('printing help');
|
468
|
-
program.help();
|
412
|
+
program.help();
|
413
|
+
// exits
|
469
414
|
}
|
470
415
|
|
471
416
|
const firstCommand = args[2];
|
472
|
-
|
473
417
|
if (!_.includes(knownCommands, firstCommand)) {
|
474
418
|
debug('unknown command %s', firstCommand);
|
475
419
|
logger.error('Unknown command', `"${firstCommand}"`);
|
476
420
|
program.outputHelp();
|
477
421
|
return util.exit(1);
|
478
422
|
}
|
479
|
-
|
480
423
|
if (includesVersion(args)) {
|
481
424
|
// commander 2.11.0 changes behavior
|
482
425
|
// and now does not understand top level options
|
@@ -484,13 +427,12 @@ module.exports = {
|
|
484
427
|
// so we have to manually catch '-v, --version'
|
485
428
|
return showVersions(args);
|
486
429
|
}
|
487
|
-
|
488
430
|
debug('program parsing arguments');
|
489
431
|
return program.parse(args);
|
490
432
|
}
|
433
|
+
};
|
491
434
|
|
492
|
-
|
493
|
-
|
435
|
+
// @ts-ignore
|
494
436
|
if (!module.parent) {
|
495
437
|
logger.error('This CLI module should be required from another Node module');
|
496
438
|
logger.error('and not executed directly');
|
package/lib/cypress.js
CHANGED
@@ -1,20 +1,14 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
// https://github.com/cypress-io/cypress/issues/316
|
4
|
-
const Promise = require('bluebird');
|
5
4
|
|
5
|
+
const Promise = require('bluebird');
|
6
6
|
const tmp = Promise.promisifyAll(require('tmp'));
|
7
|
-
|
8
7
|
const fs = require('./fs');
|
9
|
-
|
10
8
|
const open = require('./exec/open');
|
11
|
-
|
12
9
|
const run = require('./exec/run');
|
13
|
-
|
14
10
|
const util = require('./util');
|
15
|
-
|
16
11
|
const cli = require('./cli');
|
17
|
-
|
18
12
|
const cypressModuleApi = {
|
19
13
|
/**
|
20
14
|
* Opens Cypress GUI
|
@@ -24,7 +18,6 @@ const cypressModuleApi = {
|
|
24
18
|
options = util.normalizeModuleOptions(options);
|
25
19
|
return open.start(options);
|
26
20
|
},
|
27
|
-
|
28
21
|
/**
|
29
22
|
* Runs Cypress tests in the current project
|
30
23
|
* @see https://on.cypress.io/module-api#cypress-run
|
@@ -33,7 +26,6 @@ const cypressModuleApi = {
|
|
33
26
|
if (!run.isValidProject(options.project)) {
|
34
27
|
return Promise.reject(new Error(`Invalid project path parameter: ${options.project}`));
|
35
28
|
}
|
36
|
-
|
37
29
|
options = util.normalizeModuleOptions(options);
|
38
30
|
tmp.setGracefulCleanup();
|
39
31
|
return tmp.fileAsync().then(outputPath => {
|
@@ -49,13 +41,11 @@ const cypressModuleApi = {
|
|
49
41
|
message: 'Could not find Cypress test run results'
|
50
42
|
};
|
51
43
|
}
|
52
|
-
|
53
44
|
return output;
|
54
45
|
});
|
55
46
|
});
|
56
47
|
});
|
57
48
|
},
|
58
|
-
|
59
49
|
cli: {
|
60
50
|
/**
|
61
51
|
* Parses CLI arguments into an object that you can pass to "cypress.run"
|
@@ -70,9 +60,7 @@ const cypressModuleApi = {
|
|
70
60
|
parseRunArguments(args) {
|
71
61
|
return cli.parseRunCommand(args);
|
72
62
|
}
|
73
|
-
|
74
63
|
},
|
75
|
-
|
76
64
|
/**
|
77
65
|
* Provides automatic code completion for configuration in many popular code editors.
|
78
66
|
* While it's not strictly necessary for Cypress to parse your configuration, we
|
@@ -89,6 +77,5 @@ const cypressModuleApi = {
|
|
89
77
|
defineConfig(config) {
|
90
78
|
return config;
|
91
79
|
}
|
92
|
-
|
93
80
|
};
|
94
81
|
module.exports = cypressModuleApi;
|