cypress 5.4.0 → 5.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/index.js
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
|
3
|
+
const minimist = require('minimist');
|
4
4
|
|
5
|
-
|
5
|
+
const debug = require('debug')('cypress:cli');
|
6
6
|
|
7
|
-
|
7
|
+
const args = minimist(process.argv.slice(2));
|
8
8
|
|
9
|
-
|
9
|
+
const util = require('./lib/util'); // we're being used from the command line
|
10
10
|
|
11
11
|
|
12
12
|
switch (args.exec) {
|
@@ -15,7 +15,7 @@ switch (args.exec) {
|
|
15
15
|
|
16
16
|
require('./lib/tasks/install').start({
|
17
17
|
force: args.force
|
18
|
-
})
|
18
|
+
}).catch(util.logErrorExit1);
|
19
19
|
|
20
20
|
break;
|
21
21
|
|
@@ -26,7 +26,7 @@ switch (args.exec) {
|
|
26
26
|
require('./lib/tasks/verify').start({
|
27
27
|
force: true
|
28
28
|
}) // always force verification
|
29
|
-
|
29
|
+
.catch(util.logErrorExit1);
|
30
30
|
|
31
31
|
break;
|
32
32
|
|
package/lib/cli.js
CHANGED
@@ -1,53 +1,33 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
-
|
3
|
+
const _ = require('lodash');
|
4
4
|
|
5
|
-
|
5
|
+
const R = require('ramda');
|
6
6
|
|
7
|
-
|
7
|
+
const commander = require('commander');
|
8
8
|
|
9
|
-
|
9
|
+
const {
|
10
|
+
stripIndent
|
11
|
+
} = require('common-tags');
|
10
12
|
|
11
|
-
|
13
|
+
const logSymbols = require('log-symbols');
|
12
14
|
|
13
|
-
|
15
|
+
const debug = require('debug')('cypress:cli:cli');
|
14
16
|
|
15
|
-
|
17
|
+
const util = require('./util');
|
16
18
|
|
17
|
-
|
19
|
+
const logger = require('./logger');
|
18
20
|
|
19
|
-
|
21
|
+
const errors = require('./errors');
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
var _ = require('lodash');
|
24
|
-
|
25
|
-
var R = require('ramda');
|
26
|
-
|
27
|
-
var commander = require('commander');
|
28
|
-
|
29
|
-
var _require = require('common-tags'),
|
30
|
-
stripIndent = _require.stripIndent;
|
31
|
-
|
32
|
-
var logSymbols = require('log-symbols');
|
33
|
-
|
34
|
-
var debug = require('debug')('cypress:cli:cli');
|
35
|
-
|
36
|
-
var util = require('./util');
|
37
|
-
|
38
|
-
var logger = require('./logger');
|
39
|
-
|
40
|
-
var errors = require('./errors');
|
41
|
-
|
42
|
-
var cache = require('./tasks/cache'); // patch "commander" method called when a user passed an unknown option
|
23
|
+
const cache = require('./tasks/cache'); // patch "commander" method called when a user passed an unknown option
|
43
24
|
// we want to print help for the current command and exit with an error
|
44
25
|
|
45
26
|
|
46
|
-
function unknownOption(flag) {
|
47
|
-
var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'option';
|
27
|
+
function unknownOption(flag, type = 'option') {
|
48
28
|
if (this._allowUnknownOption) return;
|
49
29
|
logger.error();
|
50
|
-
logger.error(
|
30
|
+
logger.error(` error: unknown ${type}:`, flag);
|
51
31
|
logger.error();
|
52
32
|
this.outputHelp();
|
53
33
|
util.exit(1);
|
@@ -55,23 +35,36 @@ function unknownOption(flag) {
|
|
55
35
|
|
56
36
|
commander.Command.prototype.unknownOption = unknownOption;
|
57
37
|
|
58
|
-
|
38
|
+
const coerceFalseOrString = arg => {
|
59
39
|
return arg !== 'false' ? arg : false;
|
60
40
|
};
|
61
41
|
|
62
|
-
|
42
|
+
const coerceFalse = arg => {
|
63
43
|
return arg !== 'false';
|
64
44
|
};
|
65
45
|
|
66
|
-
|
46
|
+
const coerceAnyStringToInt = arg => {
|
67
47
|
return typeof arg === 'string' ? parseInt(arg) : arg;
|
68
48
|
};
|
69
49
|
|
70
|
-
|
71
|
-
|
50
|
+
const spaceDelimitedArgsMsg = (flag, args) => {
|
51
|
+
let msg = `
|
52
|
+
${logSymbols.warning} Warning: It looks like you're passing --${flag} a space-separated list of arguments:
|
53
|
+
|
54
|
+
"${args.join(' ')}"
|
55
|
+
|
56
|
+
This will work, but it's not recommended.
|
57
|
+
|
58
|
+
If you are trying to pass multiple arguments, separate them with commas instead:
|
59
|
+
cypress run --${flag} arg1,arg2,arg3
|
60
|
+
`;
|
72
61
|
|
73
62
|
if (flag === 'spec') {
|
74
|
-
msg +=
|
63
|
+
msg += `
|
64
|
+
The most common cause of this warning is using an unescaped glob pattern. If you are
|
65
|
+
trying to pass a glob pattern, escape it using quotes:
|
66
|
+
cypress run --spec "**/*.spec.js"
|
67
|
+
`;
|
75
68
|
}
|
76
69
|
|
77
70
|
logger.log();
|
@@ -79,30 +72,28 @@ var spaceDelimitedArgsMsg = function spaceDelimitedArgsMsg(flag, args) {
|
|
79
72
|
logger.log();
|
80
73
|
};
|
81
74
|
|
82
|
-
|
83
|
-
|
84
|
-
opts = _fnArgs[0],
|
85
|
-
unknownArgs = _fnArgs[1];
|
75
|
+
const parseVariableOpts = (fnArgs, args) => {
|
76
|
+
const [opts, unknownArgs] = fnArgs;
|
86
77
|
|
87
78
|
if (unknownArgs && unknownArgs.length && (opts.spec || opts.tag)) {
|
88
79
|
// this will capture space-delimited args after
|
89
80
|
// flags that could have possible multiple args
|
90
81
|
// but before the next option
|
91
82
|
// --spec spec1 spec2 or --tag foo bar
|
92
|
-
|
83
|
+
const multiArgFlags = _.compact([opts.spec ? 'spec' : opts.spec, opts.tag ? 'tag' : opts.tag]);
|
93
84
|
|
94
|
-
_.forEach(multiArgFlags,
|
95
|
-
|
85
|
+
_.forEach(multiArgFlags, flag => {
|
86
|
+
const argIndex = _.indexOf(args, `--${flag}`) + 2;
|
96
87
|
|
97
|
-
|
88
|
+
const nextOptOffset = _.findIndex(_.slice(args, argIndex), arg => {
|
98
89
|
return _.startsWith(arg, '--');
|
99
90
|
});
|
100
91
|
|
101
|
-
|
92
|
+
const endIndex = nextOptOffset !== -1 ? argIndex + nextOptOffset : args.length;
|
102
93
|
|
103
|
-
|
94
|
+
const maybeArgs = _.slice(args, argIndex, endIndex);
|
104
95
|
|
105
|
-
|
96
|
+
const extraArgs = _.intersection(maybeArgs, unknownArgs);
|
106
97
|
|
107
98
|
if (extraArgs.length) {
|
108
99
|
opts[flag] = [opts[flag]].concat(extraArgs);
|
@@ -113,13 +104,13 @@ var parseVariableOpts = function parseVariableOpts(fnArgs, args) {
|
|
113
104
|
}
|
114
105
|
|
115
106
|
debug('variable-length opts parsed %o', {
|
116
|
-
args
|
117
|
-
opts
|
107
|
+
args,
|
108
|
+
opts
|
118
109
|
});
|
119
110
|
return util.parseOpts(opts);
|
120
111
|
};
|
121
112
|
|
122
|
-
|
113
|
+
const descriptions = {
|
123
114
|
browserOpenMode: 'path to a custom browser to be added to the list of available browsers in Cypress',
|
124
115
|
browserRunMode: '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.',
|
125
116
|
cacheClear: 'delete all cached binaries',
|
@@ -151,11 +142,11 @@ var descriptions = {
|
|
151
142
|
tag: 'named tag(s) for recorded runs in the Cypress Dashboard',
|
152
143
|
version: 'prints Cypress version'
|
153
144
|
};
|
154
|
-
|
145
|
+
const knownCommands = ['cache', 'help', '-h', '--help', 'install', 'open', 'run', 'verify', '-v', '--version', 'version', 'info'];
|
155
146
|
|
156
|
-
|
147
|
+
const text = description => {
|
157
148
|
if (!descriptions[description]) {
|
158
|
-
throw new Error(
|
149
|
+
throw new Error(`Could not find description for: ${description}`);
|
159
150
|
}
|
160
151
|
|
161
152
|
return descriptions[description];
|
@@ -167,16 +158,15 @@ function includesVersion(args) {
|
|
167
158
|
|
168
159
|
function showVersions() {
|
169
160
|
debug('printing Cypress version');
|
170
|
-
return require('./exec/versions').getVersions().then(
|
171
|
-
|
172
|
-
logger.always('Cypress package version:', versions["package"]);
|
161
|
+
return require('./exec/versions').getVersions().then((versions = {}) => {
|
162
|
+
logger.always('Cypress package version:', versions.package);
|
173
163
|
logger.always('Cypress binary version:', versions.binary);
|
174
164
|
process.exit(0);
|
175
|
-
})
|
165
|
+
}).catch(util.logErrorExit1);
|
176
166
|
}
|
177
167
|
|
178
|
-
|
179
|
-
|
168
|
+
const createProgram = () => {
|
169
|
+
const program = new commander.Command(); // bug in commander not printing name
|
180
170
|
// in usage help docs
|
181
171
|
|
182
172
|
program._name = 'cypress';
|
@@ -184,7 +174,7 @@ var createProgram = function createProgram() {
|
|
184
174
|
return program;
|
185
175
|
};
|
186
176
|
|
187
|
-
|
177
|
+
const addCypressRunCommand = program => {
|
188
178
|
return program.command('run').usage('[options]').description('Runs Cypress tests from the CLI without the GUI').option('-b, --browser <browser-name-or-path>', text('browserRunMode')).option('--ci-build-id <id>', text('ciBuildId')).option('-c, --config <config>', text('config')).option('-C, --config-file <config-file>', text('configFile')).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);
|
189
179
|
};
|
190
180
|
/**
|
@@ -196,11 +186,11 @@ var addCypressRunCommand = function addCypressRunCommand(program) {
|
|
196
186
|
*/
|
197
187
|
|
198
188
|
|
199
|
-
|
189
|
+
const castCypressRunOptions = opts => {
|
200
190
|
// only properties that have type "string | false" in our TS definition
|
201
191
|
// require special handling, because CLI parsing takes care of purely
|
202
192
|
// boolean arguments
|
203
|
-
|
193
|
+
const result = R.evolve({
|
204
194
|
port: coerceAnyStringToInt,
|
205
195
|
configFile: coerceFalseOrString
|
206
196
|
})(opts);
|
@@ -215,8 +205,8 @@ module.exports = {
|
|
215
205
|
* const options = parseRunCommand(['cypress', 'run', '--browser', 'chrome'])
|
216
206
|
* // options is {browser: 'chrome'}
|
217
207
|
*/
|
218
|
-
parseRunCommand
|
219
|
-
return new Promise(
|
208
|
+
parseRunCommand(args) {
|
209
|
+
return new Promise((resolve, reject) => {
|
220
210
|
if (!Array.isArray(args)) {
|
221
211
|
return reject(new Error('Expected array of arguments'));
|
222
212
|
} // make a copy of the input arguments array
|
@@ -224,19 +214,15 @@ module.exports = {
|
|
224
214
|
// also remove "cypress" keyword at the start if present
|
225
215
|
|
226
216
|
|
227
|
-
|
217
|
+
const cliArgs = args[0] === 'cypress' ? [...args.slice(1)] : [...args];
|
228
218
|
cliArgs.unshift(null, null);
|
229
219
|
debug('creating program parser');
|
230
|
-
|
231
|
-
addCypressRunCommand(program).action(
|
232
|
-
for (var _len = arguments.length, fnArgs = new Array(_len), _key = 0; _key < _len; _key++) {
|
233
|
-
fnArgs[_key] = arguments[_key];
|
234
|
-
}
|
235
|
-
|
220
|
+
const program = createProgram();
|
221
|
+
addCypressRunCommand(program).action((...fnArgs) => {
|
236
222
|
debug('parsed Cypress run %o', fnArgs);
|
237
|
-
|
223
|
+
const options = parseVariableOpts(fnArgs, cliArgs);
|
238
224
|
debug('parsed options %o', options);
|
239
|
-
|
225
|
+
const casted = castCypressRunOptions(options);
|
240
226
|
debug('casted options %o', casted);
|
241
227
|
resolve(casted);
|
242
228
|
});
|
@@ -248,58 +234,62 @@ module.exports = {
|
|
248
234
|
/**
|
249
235
|
* Parses the command line and kicks off Cypress process.
|
250
236
|
*/
|
251
|
-
init
|
237
|
+
init(args) {
|
252
238
|
if (!args) {
|
253
239
|
args = process.argv;
|
254
240
|
}
|
255
241
|
|
256
|
-
|
242
|
+
const {
|
243
|
+
CYPRESS_INTERNAL_ENV
|
244
|
+
} = process.env;
|
257
245
|
|
258
246
|
if (!util.isValidCypressInternalEnvValue(CYPRESS_INTERNAL_ENV)) {
|
259
247
|
debug('invalid CYPRESS_INTERNAL_ENV value', CYPRESS_INTERNAL_ENV);
|
260
|
-
return errors.exitWithError(errors.errors.invalidCypressEnv)(
|
248
|
+
return errors.exitWithError(errors.errors.invalidCypressEnv)(`CYPRESS_INTERNAL_ENV=${CYPRESS_INTERNAL_ENV}`);
|
261
249
|
}
|
262
250
|
|
263
251
|
if (util.isNonProductionCypressInternalEnvValue(CYPRESS_INTERNAL_ENV)) {
|
264
252
|
debug('non-production CYPRESS_INTERNAL_ENV value', CYPRESS_INTERNAL_ENV);
|
265
|
-
|
253
|
+
let msg = `
|
254
|
+
${logSymbols.warning} Warning: It looks like you're passing CYPRESS_INTERNAL_ENV=${CYPRESS_INTERNAL_ENV}
|
255
|
+
|
256
|
+
The environment variable "CYPRESS_INTERNAL_ENV" is reserved and should only be used internally.
|
257
|
+
|
258
|
+
Unset the "CYPRESS_INTERNAL_ENV" environment variable and run Cypress again.
|
259
|
+
`;
|
266
260
|
logger.log();
|
267
261
|
logger.warn(stripIndent(msg));
|
268
262
|
logger.log();
|
269
263
|
}
|
270
264
|
|
271
|
-
|
272
|
-
program.command('help').description('Shows CLI help and exits').action(
|
265
|
+
const program = createProgram();
|
266
|
+
program.command('help').description('Shows CLI help and exits').action(() => {
|
273
267
|
program.help();
|
274
268
|
});
|
275
269
|
program.option('-v, --version', text('version')).command('version').description(text('version')).action(showVersions);
|
276
|
-
addCypressRunCommand(program).action(
|
277
|
-
for (var _len2 = arguments.length, fnArgs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
278
|
-
fnArgs[_key2] = arguments[_key2];
|
279
|
-
}
|
280
|
-
|
270
|
+
addCypressRunCommand(program).action((...fnArgs) => {
|
281
271
|
debug('running Cypress with args %o', fnArgs);
|
282
272
|
|
283
|
-
require('./exec/run').start(parseVariableOpts(fnArgs, args)).then(util.exit)
|
273
|
+
require('./exec/run').start(parseVariableOpts(fnArgs, args)).then(util.exit).catch(util.logErrorExit1);
|
284
274
|
});
|
285
|
-
program.command('open').usage('[options]').description('Opens Cypress in the interactive GUI.').option('-b, --browser <browser-path>', text('browserOpenMode')).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(
|
275
|
+
program.command('open').usage('[options]').description('Opens Cypress in the interactive GUI.').option('-b, --browser <browser-path>', text('browserOpenMode')).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 => {
|
286
276
|
debug('opening Cypress');
|
287
277
|
|
288
|
-
require('./exec/open').start(util.parseOpts(opts))
|
278
|
+
require('./exec/open').start(util.parseOpts(opts)).catch(util.logErrorExit1);
|
289
279
|
});
|
290
|
-
program.command('install').usage('[options]').description('Installs the Cypress executable matching this package\'s version').option('-f, --force', text('forceInstall')).action(
|
291
|
-
require('./tasks/install').start(util.parseOpts(opts))
|
280
|
+
program.command('install').usage('[options]').description('Installs the Cypress executable matching this package\'s version').option('-f, --force', text('forceInstall')).action(opts => {
|
281
|
+
require('./tasks/install').start(util.parseOpts(opts)).catch(util.logErrorExit1);
|
292
282
|
});
|
293
|
-
program.command('verify').usage('[options]').description('Verifies that Cypress is installed correctly and executable').option('--dev', text('dev'), coerceFalse).action(
|
294
|
-
|
283
|
+
program.command('verify').usage('[options]').description('Verifies that Cypress is installed correctly and executable').option('--dev', text('dev'), coerceFalse).action(opts => {
|
284
|
+
const defaultOpts = {
|
295
285
|
force: true,
|
296
286
|
welcomeMessage: false
|
297
287
|
};
|
298
|
-
|
288
|
+
const parsedOpts = util.parseOpts(opts);
|
299
289
|
|
300
|
-
|
290
|
+
const options = _.extend(parsedOpts, defaultOpts);
|
301
291
|
|
302
|
-
require('./tasks/verify').start(options)
|
292
|
+
require('./tasks/verify').start(options).catch(util.logErrorExit1);
|
303
293
|
});
|
304
294
|
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) {
|
305
295
|
if (!args || !args.length) {
|
@@ -307,22 +297,27 @@ module.exports = {
|
|
307
297
|
util.exit(1);
|
308
298
|
}
|
309
299
|
|
310
|
-
|
311
|
-
command = _args[0];
|
300
|
+
const [command] = args;
|
312
301
|
|
313
302
|
if (!_.includes(['list', 'path', 'clear', 'prune'], command)) {
|
314
|
-
unknownOption.call(this,
|
303
|
+
unknownOption.call(this, `cache ${command}`, 'command');
|
315
304
|
}
|
316
305
|
|
317
306
|
if (command === 'list') {
|
318
|
-
cache
|
319
|
-
|
307
|
+
debug('cache command %o', {
|
308
|
+
command,
|
309
|
+
size: opts.size
|
310
|
+
});
|
311
|
+
return cache.list(opts.size).catch(e => {
|
312
|
+
debug('cache list command failed with "%s"', e.message);
|
313
|
+
util.logErrorExit1(e);
|
314
|
+
});
|
320
315
|
}
|
321
316
|
|
322
317
|
cache[command]();
|
323
318
|
});
|
324
|
-
program.command('info').usage('[command]').description('Prints Cypress and system information').option('--dev', text('dev'), coerceFalse).action(
|
325
|
-
require('./exec/info').start(opts).then(util.exit)
|
319
|
+
program.command('info').usage('[command]').description('Prints Cypress and system information').option('--dev', text('dev'), coerceFalse).action(opts => {
|
320
|
+
require('./exec/info').start(opts).then(util.exit).catch(util.logErrorExit1);
|
326
321
|
});
|
327
322
|
debug('cli starts with arguments %j', args);
|
328
323
|
util.printNodeOptions(); // if there are no arguments
|
@@ -332,11 +327,11 @@ module.exports = {
|
|
332
327
|
program.help(); // exits
|
333
328
|
}
|
334
329
|
|
335
|
-
|
330
|
+
const firstCommand = args[2];
|
336
331
|
|
337
332
|
if (!_.includes(knownCommands, firstCommand)) {
|
338
333
|
debug('unknown command %s', firstCommand);
|
339
|
-
logger.error('Unknown command', "
|
334
|
+
logger.error('Unknown command', `"${firstCommand}"`);
|
340
335
|
program.outputHelp();
|
341
336
|
return util.exit(1);
|
342
337
|
}
|
@@ -352,6 +347,7 @@ module.exports = {
|
|
352
347
|
debug('program parsing arguments');
|
353
348
|
return program.parse(args);
|
354
349
|
}
|
350
|
+
|
355
351
|
};
|
356
352
|
|
357
353
|
if (!module.parent) {
|
package/lib/cypress.js
CHANGED
@@ -1,51 +1,49 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
// https://github.com/cypress-io/cypress/issues/316
|
4
|
-
|
4
|
+
const Promise = require('bluebird');
|
5
5
|
|
6
|
-
|
6
|
+
const tmp = Promise.promisifyAll(require('tmp'));
|
7
7
|
|
8
|
-
|
8
|
+
const fs = require('./fs');
|
9
9
|
|
10
|
-
|
10
|
+
const open = require('./exec/open');
|
11
11
|
|
12
|
-
|
12
|
+
const run = require('./exec/run');
|
13
13
|
|
14
|
-
|
14
|
+
const util = require('./util');
|
15
15
|
|
16
|
-
|
16
|
+
const cli = require('./cli');
|
17
17
|
|
18
|
-
|
18
|
+
const cypressModuleApi = {
|
19
19
|
/**
|
20
20
|
* Opens Cypress GUI
|
21
21
|
* @see https://on.cypress.io/module-api#cypress-open
|
22
22
|
*/
|
23
|
-
open
|
24
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
23
|
+
open(options = {}) {
|
25
24
|
options = util.normalizeModuleOptions(options);
|
26
|
-
return
|
25
|
+
return open.start(options);
|
27
26
|
},
|
28
27
|
|
29
28
|
/**
|
30
29
|
* Runs Cypress tests in the current project
|
31
30
|
* @see https://on.cypress.io/module-api#cypress-run
|
32
31
|
*/
|
33
|
-
run
|
34
|
-
|
35
|
-
|
36
|
-
if (!_run.isValidProject(options.project)) {
|
37
|
-
return Promise.reject(new Error("Invalid project path parameter: ".concat(options.project)));
|
32
|
+
run(options = {}) {
|
33
|
+
if (!run.isValidProject(options.project)) {
|
34
|
+
return Promise.reject(new Error(`Invalid project path parameter: ${options.project}`));
|
38
35
|
}
|
39
36
|
|
40
37
|
options = util.normalizeModuleOptions(options);
|
41
|
-
return tmp.fileAsync().then(
|
38
|
+
return tmp.fileAsync().then(outputPath => {
|
42
39
|
options.outputPath = outputPath;
|
43
|
-
return
|
40
|
+
return run.start(options).then(failedTests => {
|
44
41
|
return fs.readJsonAsync(outputPath, {
|
45
|
-
|
46
|
-
}).then(
|
42
|
+
throws: false
|
43
|
+
}).then(output => {
|
47
44
|
if (!output) {
|
48
45
|
return {
|
46
|
+
status: 'failed',
|
49
47
|
failures: failedTests,
|
50
48
|
message: 'Could not find Cypress test run results'
|
51
49
|
};
|
@@ -56,6 +54,7 @@ var cypressModuleApi = {
|
|
56
54
|
});
|
57
55
|
});
|
58
56
|
},
|
57
|
+
|
59
58
|
cli: {
|
60
59
|
/**
|
61
60
|
* Parses CLI arguments into an object that you can pass to "cypress.run"
|
@@ -67,9 +66,10 @@ var cypressModuleApi = {
|
|
67
66
|
* await cypress.run(options)
|
68
67
|
* @see https://on.cypress.io/module-api
|
69
68
|
*/
|
70
|
-
parseRunArguments
|
69
|
+
parseRunArguments(args) {
|
71
70
|
return cli.parseRunCommand(args);
|
72
71
|
}
|
72
|
+
|
73
73
|
}
|
74
74
|
};
|
75
75
|
module.exports = cypressModuleApi;
|