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 CHANGED
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
 
3
- var minimist = require('minimist');
3
+ const minimist = require('minimist');
4
4
 
5
- var debug = require('debug')('cypress:cli');
5
+ const debug = require('debug')('cypress:cli');
6
6
 
7
- var args = minimist(process.argv.slice(2));
7
+ const args = minimist(process.argv.slice(2));
8
8
 
9
- var util = require('./lib/util'); // we're being used from the command line
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
- })["catch"](util.logErrorExit1);
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
- ["catch"](util.logErrorExit1);
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
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
3
+ const _ = require('lodash');
4
4
 
5
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
+ const R = require('ramda');
6
6
 
7
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
7
+ const commander = require('commander');
8
8
 
9
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
9
+ const {
10
+ stripIndent
11
+ } = require('common-tags');
10
12
 
11
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
13
+ const logSymbols = require('log-symbols');
12
14
 
13
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
15
+ const debug = require('debug')('cypress:cli:cli');
14
16
 
15
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
17
+ const util = require('./util');
16
18
 
17
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
19
+ const logger = require('./logger');
18
20
 
19
- function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
21
+ const errors = require('./errors');
20
22
 
21
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
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(" error: unknown ".concat(type, ":"), flag);
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
- var coerceFalseOrString = function coerceFalseOrString(arg) {
38
+ const coerceFalseOrString = arg => {
59
39
  return arg !== 'false' ? arg : false;
60
40
  };
61
41
 
62
- var coerceFalse = function coerceFalse(arg) {
42
+ const coerceFalse = arg => {
63
43
  return arg !== 'false';
64
44
  };
65
45
 
66
- var coerceAnyStringToInt = function coerceAnyStringToInt(arg) {
46
+ const coerceAnyStringToInt = arg => {
67
47
  return typeof arg === 'string' ? parseInt(arg) : arg;
68
48
  };
69
49
 
70
- var spaceDelimitedArgsMsg = function spaceDelimitedArgsMsg(flag, args) {
71
- var msg = "\n ".concat(logSymbols.warning, " Warning: It looks like you're passing --").concat(flag, " a space-separated list of arguments:\n\n \"").concat(args.join(' '), "\"\n\n This will work, but it's not recommended.\n\n If you are trying to pass multiple arguments, separate them with commas instead:\n cypress run --").concat(flag, " arg1,arg2,arg3\n ");
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 += "\n The most common cause of this warning is using an unescaped glob pattern. If you are\n trying to pass a glob pattern, escape it using quotes:\n cypress run --spec \"**/*.spec.js\"\n ";
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
- var parseVariableOpts = function parseVariableOpts(fnArgs, args) {
83
- var _fnArgs = _slicedToArray(fnArgs, 2),
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
- var multiArgFlags = _.compact([opts.spec ? 'spec' : opts.spec, opts.tag ? 'tag' : opts.tag]);
83
+ const multiArgFlags = _.compact([opts.spec ? 'spec' : opts.spec, opts.tag ? 'tag' : opts.tag]);
93
84
 
94
- _.forEach(multiArgFlags, function (flag) {
95
- var argIndex = _.indexOf(args, "--".concat(flag)) + 2;
85
+ _.forEach(multiArgFlags, flag => {
86
+ const argIndex = _.indexOf(args, `--${flag}`) + 2;
96
87
 
97
- var nextOptOffset = _.findIndex(_.slice(args, argIndex), function (arg) {
88
+ const nextOptOffset = _.findIndex(_.slice(args, argIndex), arg => {
98
89
  return _.startsWith(arg, '--');
99
90
  });
100
91
 
101
- var endIndex = nextOptOffset !== -1 ? argIndex + nextOptOffset : args.length;
92
+ const endIndex = nextOptOffset !== -1 ? argIndex + nextOptOffset : args.length;
102
93
 
103
- var maybeArgs = _.slice(args, argIndex, endIndex);
94
+ const maybeArgs = _.slice(args, argIndex, endIndex);
104
95
 
105
- var extraArgs = _.intersection(maybeArgs, unknownArgs);
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: args,
117
- opts: opts
107
+ args,
108
+ opts
118
109
  });
119
110
  return util.parseOpts(opts);
120
111
  };
121
112
 
122
- var descriptions = {
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
- var knownCommands = ['cache', 'help', '-h', '--help', 'install', 'open', 'run', 'verify', '-v', '--version', 'version', 'info'];
145
+ const knownCommands = ['cache', 'help', '-h', '--help', 'install', 'open', 'run', 'verify', '-v', '--version', 'version', 'info'];
155
146
 
156
- var text = function text(description) {
147
+ const text = description => {
157
148
  if (!descriptions[description]) {
158
- throw new Error("Could not find description for: ".concat(description));
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(function () {
171
- var versions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
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
- })["catch"](util.logErrorExit1);
165
+ }).catch(util.logErrorExit1);
176
166
  }
177
167
 
178
- var createProgram = function createProgram() {
179
- var program = new commander.Command(); // bug in commander not printing name
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
- var addCypressRunCommand = function addCypressRunCommand(program) {
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
- var castCypressRunOptions = function castCypressRunOptions(opts) {
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
- var result = R.evolve({
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: function parseRunCommand(args) {
219
- return new Promise(function (resolve, reject) {
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
- var cliArgs = args[0] === 'cypress' ? _toConsumableArray(args.slice(1)) : _toConsumableArray(args);
217
+ const cliArgs = args[0] === 'cypress' ? [...args.slice(1)] : [...args];
228
218
  cliArgs.unshift(null, null);
229
219
  debug('creating program parser');
230
- var program = createProgram();
231
- addCypressRunCommand(program).action(function () {
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
- var options = parseVariableOpts(fnArgs, cliArgs);
223
+ const options = parseVariableOpts(fnArgs, cliArgs);
238
224
  debug('parsed options %o', options);
239
- var casted = castCypressRunOptions(options);
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: function init(args) {
237
+ init(args) {
252
238
  if (!args) {
253
239
  args = process.argv;
254
240
  }
255
241
 
256
- var CYPRESS_INTERNAL_ENV = process.env.CYPRESS_INTERNAL_ENV;
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)("CYPRESS_INTERNAL_ENV=".concat(CYPRESS_INTERNAL_ENV));
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
- var msg = "\n ".concat(logSymbols.warning, " Warning: It looks like you're passing CYPRESS_INTERNAL_ENV=").concat(CYPRESS_INTERNAL_ENV, "\n\n The environment variable \"CYPRESS_INTERNAL_ENV\" is reserved and should only be used internally.\n\n Unset the \"CYPRESS_INTERNAL_ENV\" environment variable and run Cypress again.\n ");
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
- var program = createProgram();
272
- program.command('help').description('Shows CLI help and exits').action(function () {
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(function () {
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)["catch"](util.logErrorExit1);
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(function (opts) {
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))["catch"](util.logErrorExit1);
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(function (opts) {
291
- require('./tasks/install').start(util.parseOpts(opts))["catch"](util.logErrorExit1);
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(function (opts) {
294
- var defaultOpts = {
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
- var parsedOpts = util.parseOpts(opts);
288
+ const parsedOpts = util.parseOpts(opts);
299
289
 
300
- var options = _.extend(parsedOpts, defaultOpts);
290
+ const options = _.extend(parsedOpts, defaultOpts);
301
291
 
302
- require('./tasks/verify').start(options)["catch"](util.logErrorExit1);
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
- var _args = _slicedToArray(args, 1),
311
- command = _args[0];
300
+ const [command] = args;
312
301
 
313
302
  if (!_.includes(['list', 'path', 'clear', 'prune'], command)) {
314
- unknownOption.call(this, "cache ".concat(command), 'command');
303
+ unknownOption.call(this, `cache ${command}`, 'command');
315
304
  }
316
305
 
317
306
  if (command === 'list') {
318
- cache.list(opts.size);
319
- return;
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(function (opts) {
325
- require('./exec/info').start(opts).then(util.exit)["catch"](util.logErrorExit1);
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
- var firstCommand = args[2];
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', "\"".concat(firstCommand, "\""));
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
- var Promise = require('bluebird');
4
+ const Promise = require('bluebird');
5
5
 
6
- var tmp = Promise.promisifyAll(require('tmp'));
6
+ const tmp = Promise.promisifyAll(require('tmp'));
7
7
 
8
- var fs = require('./fs');
8
+ const fs = require('./fs');
9
9
 
10
- var _open = require('./exec/open');
10
+ const open = require('./exec/open');
11
11
 
12
- var _run = require('./exec/run');
12
+ const run = require('./exec/run');
13
13
 
14
- var util = require('./util');
14
+ const util = require('./util');
15
15
 
16
- var cli = require('./cli');
16
+ const cli = require('./cli');
17
17
 
18
- var cypressModuleApi = {
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: function open() {
24
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
23
+ open(options = {}) {
25
24
  options = util.normalizeModuleOptions(options);
26
- return _open.start(options);
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: function run() {
34
- var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
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(function (outputPath) {
38
+ return tmp.fileAsync().then(outputPath => {
42
39
  options.outputPath = outputPath;
43
- return _run.start(options).then(function (failedTests) {
40
+ return run.start(options).then(failedTests => {
44
41
  return fs.readJsonAsync(outputPath, {
45
- "throws": false
46
- }).then(function (output) {
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: function parseRunArguments(args) {
69
+ parseRunArguments(args) {
71
70
  return cli.parseRunCommand(args);
72
71
  }
72
+
73
73
  }
74
74
  };
75
75
  module.exports = cypressModuleApi;