cypress 4.4.1 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.
package/index.js CHANGED
@@ -1,26 +1,35 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  var minimist = require('minimist');
4
+
4
5
  var debug = require('debug')('cypress:cli');
6
+
5
7
  var args = minimist(process.argv.slice(2));
6
- var util = require('./lib/util');
7
8
 
8
- // we're being used from the command line
9
+ var util = require('./lib/util'); // we're being used from the command line
10
+
11
+
9
12
  switch (args.exec) {
10
13
  case 'install':
11
14
  debug('installing Cypress from NPM');
12
15
 
13
- require('./lib/tasks/install').start({ force: args.force }).catch(util.logErrorExit1);
16
+ require('./lib/tasks/install').start({
17
+ force: args.force
18
+ })["catch"](util.logErrorExit1);
14
19
 
15
20
  break;
21
+
16
22
  case 'verify':
17
23
  // for simple testing in the monorepo
18
24
  debug('verifying Cypress');
19
25
 
20
- require('./lib/tasks/verify').start({ force: true }) // always force verification
21
- .catch(util.logErrorExit1);
26
+ require('./lib/tasks/verify').start({
27
+ force: true
28
+ }) // always force verification
29
+ ["catch"](util.logErrorExit1);
22
30
 
23
31
  break;
32
+
24
33
  default:
25
34
  debug('exporting Cypress module interface');
26
35
  module.exports = require('./lib/cypress');
package/lib/cli.js CHANGED
@@ -1,33 +1,48 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
- var _slicedToArray = function () { function sliceIterator(arr, i) { 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"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
3
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
+
5
+ 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."); }
6
+
7
+ 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(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
8
+
9
+ 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; }
10
+
11
+ 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; }
12
+
13
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
4
14
 
5
15
  var _ = require('lodash');
16
+
6
17
  var commander = require('commander');
7
18
 
8
19
  var _require = require('common-tags'),
9
20
  stripIndent = _require.stripIndent;
10
21
 
11
22
  var logSymbols = require('log-symbols');
23
+
12
24
  var debug = require('debug')('cypress:cli:cli');
25
+
13
26
  var util = require('./util');
27
+
14
28
  var logger = require('./logger');
29
+
15
30
  var errors = require('./errors');
16
- var cache = require('./tasks/cache');
17
31
 
18
- // patch "commander" method called when a user passed an unknown option
32
+ var cache = require('./tasks/cache'); // patch "commander" method called when a user passed an unknown option
19
33
  // we want to print help for the current command and exit with an error
34
+
35
+
20
36
  function unknownOption(flag) {
21
37
  var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'option';
22
-
23
38
  if (this._allowUnknownOption) return;
24
-
25
39
  logger.error();
26
- logger.error(' error: unknown ' + type + ':', flag);
40
+ logger.error(" error: unknown ".concat(type, ":"), flag);
27
41
  logger.error();
28
42
  this.outputHelp();
29
43
  util.exit(1);
30
44
  }
45
+
31
46
  commander.Command.prototype.unknownOption = unknownOption;
32
47
 
33
48
  var coerceFalse = function coerceFalse(arg) {
@@ -35,10 +50,10 @@ var coerceFalse = function coerceFalse(arg) {
35
50
  };
36
51
 
37
52
  var spaceDelimitedArgsMsg = function spaceDelimitedArgsMsg(flag, args) {
38
- var msg = '\n ' + logSymbols.warning + ' Warning: It looks like you\'re passing --' + flag + ' a space-separated list of arguments:\n\n "' + 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 --' + flag + ' arg1,arg2,arg3\n ';
53
+ 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 ");
39
54
 
40
55
  if (flag === 'spec') {
41
- 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 ';
56
+ 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 ";
42
57
  }
43
58
 
44
59
  logger.log();
@@ -56,17 +71,19 @@ var parseVariableOpts = function parseVariableOpts(fnArgs, args) {
56
71
  // flags that could have possible multiple args
57
72
  // but before the next option
58
73
  // --spec spec1 spec2 or --tag foo bar
59
-
60
74
  var multiArgFlags = _.compact([opts.spec ? 'spec' : opts.spec, opts.tag ? 'tag' : opts.tag]);
61
75
 
62
76
  _.forEach(multiArgFlags, function (flag) {
63
- var argIndex = _.indexOf(args, '--' + flag) + 2;
77
+ var argIndex = _.indexOf(args, "--".concat(flag)) + 2;
78
+
64
79
  var nextOptOffset = _.findIndex(_.slice(args, argIndex), function (arg) {
65
80
  return _.startsWith(arg, '--');
66
81
  });
82
+
67
83
  var endIndex = nextOptOffset !== -1 ? argIndex + nextOptOffset : args.length;
68
84
 
69
85
  var maybeArgs = _.slice(args, argIndex, endIndex);
86
+
70
87
  var extraArgs = _.intersection(maybeArgs, unknownArgs);
71
88
 
72
89
  if (extraArgs.length) {
@@ -77,8 +94,10 @@ var parseVariableOpts = function parseVariableOpts(fnArgs, args) {
77
94
  });
78
95
  }
79
96
 
80
- debug('variable-length opts parsed %o', { args: args, opts: opts });
81
-
97
+ debug('variable-length opts parsed %o', {
98
+ args: args,
99
+ opts: opts
100
+ });
82
101
  return util.parseOpts(opts);
83
102
  };
84
103
 
@@ -111,12 +130,11 @@ var descriptions = {
111
130
  tag: 'named tag(s) for recorded runs in the Cypress Dashboard',
112
131
  version: 'prints Cypress version'
113
132
  };
114
-
115
133
  var knownCommands = ['cache', 'help', '-h', '--help', 'install', 'open', 'run', 'verify', '-v', '--version', 'version', 'info'];
116
134
 
117
135
  var text = function text(description) {
118
136
  if (!descriptions[description]) {
119
- throw new Error('Could not find description for: ' + description);
137
+ throw new Error("Could not find description for: ".concat(description));
120
138
  }
121
139
 
122
140
  return descriptions[description];
@@ -128,14 +146,12 @@ function includesVersion(args) {
128
146
 
129
147
  function showVersions() {
130
148
  debug('printing Cypress version');
131
-
132
149
  return require('./exec/versions').getVersions().then(function () {
133
150
  var versions = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
134
-
135
- logger.always('Cypress package version:', versions.package);
151
+ logger.always('Cypress package version:', versions["package"]);
136
152
  logger.always('Cypress binary version:', versions.binary);
137
153
  process.exit(0);
138
- }).catch(util.logErrorExit1);
154
+ })["catch"](util.logErrorExit1);
139
155
  }
140
156
 
141
157
  module.exports = {
@@ -146,63 +162,56 @@ module.exports = {
146
162
 
147
163
  var CYPRESS_INTERNAL_ENV = process.env.CYPRESS_INTERNAL_ENV;
148
164
 
149
-
150
165
  if (!util.isValidCypressInternalEnvValue(CYPRESS_INTERNAL_ENV)) {
151
166
  debug('invalid CYPRESS_INTERNAL_ENV value', CYPRESS_INTERNAL_ENV);
152
-
153
- return errors.exitWithError(errors.errors.invalidCypressEnv)('CYPRESS_INTERNAL_ENV=' + CYPRESS_INTERNAL_ENV);
167
+ return errors.exitWithError(errors.errors.invalidCypressEnv)("CYPRESS_INTERNAL_ENV=".concat(CYPRESS_INTERNAL_ENV));
154
168
  }
155
169
 
156
170
  if (util.isNonProductionCypressInternalEnvValue(CYPRESS_INTERNAL_ENV)) {
157
171
  debug('non-production CYPRESS_INTERNAL_ENV value', CYPRESS_INTERNAL_ENV);
158
-
159
- var msg = '\n ' + logSymbols.warning + ' Warning: It looks like you\'re passing CYPRESS_INTERNAL_ENV=' + 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 ';
160
-
172
+ 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 ");
161
173
  logger.log();
162
174
  logger.warn(stripIndent(msg));
163
175
  logger.log();
164
176
  }
165
177
 
166
- var program = new commander.Command();
167
-
168
- // bug in commander not printing name
178
+ var program = new commander.Command(); // bug in commander not printing name
169
179
  // in usage help docs
170
- program._name = 'cypress';
171
180
 
181
+ program._name = 'cypress';
172
182
  program.usage('<command> [options]');
173
-
174
183
  program.command('help').description('Shows CLI help and exits').action(function () {
175
184
  program.help();
176
185
  });
177
-
178
186
  program.option('-v, --version', text('version')).command('version').description(text('version')).action(showVersions);
179
-
180
187
  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('--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).action(function () {
181
- for (var _len = arguments.length, fnArgs = Array(_len), _key = 0; _key < _len; _key++) {
188
+ for (var _len = arguments.length, fnArgs = new Array(_len), _key = 0; _key < _len; _key++) {
182
189
  fnArgs[_key] = arguments[_key];
183
190
  }
184
191
 
185
192
  debug('running Cypress with args %o', fnArgs);
186
- require('./exec/run').start(parseVariableOpts(fnArgs, args)).then(util.exit).catch(util.logErrorExit1);
187
- });
188
193
 
194
+ require('./exec/run').start(parseVariableOpts(fnArgs, args)).then(util.exit)["catch"](util.logErrorExit1);
195
+ });
189
196
  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) {
190
197
  debug('opening Cypress');
191
- require('./exec/open').start(util.parseOpts(opts)).catch(util.logErrorExit1);
192
- });
193
198
 
199
+ require('./exec/open').start(util.parseOpts(opts))["catch"](util.logErrorExit1);
200
+ });
194
201
  program.command('install').usage('[options]').description('Installs the Cypress executable matching this package\'s version').option('-f, --force', text('forceInstall')).action(function (opts) {
195
- require('./tasks/install').start(util.parseOpts(opts)).catch(util.logErrorExit1);
202
+ require('./tasks/install').start(util.parseOpts(opts))["catch"](util.logErrorExit1);
196
203
  });
197
-
198
204
  program.command('verify').usage('[options]').description('Verifies that Cypress is installed correctly and executable').option('--dev', text('dev'), coerceFalse).action(function (opts) {
199
- var defaultOpts = { force: true, welcomeMessage: false };
205
+ var defaultOpts = {
206
+ force: true,
207
+ welcomeMessage: false
208
+ };
200
209
  var parsedOpts = util.parseOpts(opts);
210
+
201
211
  var options = _.extend(parsedOpts, defaultOpts);
202
212
 
203
- require('./tasks/verify').start(options).catch(util.logErrorExit1);
213
+ require('./tasks/verify').start(options)["catch"](util.logErrorExit1);
204
214
  });
205
-
206
215
  program.command('cache').usage('[command]').description('Manages the Cypress binary cache').option('list', text('cacheList')).option('path', text('cachePath')).option('clear', text('cacheClear')).action(function (opts, args) {
207
216
  if (!args || !args.length) {
208
217
  this.outputHelp();
@@ -213,33 +222,28 @@ module.exports = {
213
222
  command = _args[0];
214
223
 
215
224
  if (!_.includes(['list', 'path', 'clear'], command)) {
216
- unknownOption.call(this, 'cache ' + command, 'command');
225
+ unknownOption.call(this, "cache ".concat(command), 'command');
217
226
  }
218
227
 
219
228
  cache[command]();
220
229
  });
221
-
222
230
  program.command('info').usage('[command]').description('Prints Cypress and system information').option('--dev', text('dev'), coerceFalse).action(function (opts) {
223
- require('./exec/info').start(opts).then(util.exit).catch(util.logErrorExit1);
231
+ require('./exec/info').start(opts).then(util.exit)["catch"](util.logErrorExit1);
224
232
  });
225
-
226
233
  debug('cli starts with arguments %j', args);
227
- util.printNodeOptions();
234
+ util.printNodeOptions(); // if there are no arguments
228
235
 
229
- // if there are no arguments
230
236
  if (args.length <= 2) {
231
237
  debug('printing help');
232
- program.help();
233
- // exits
238
+ program.help(); // exits
234
239
  }
235
240
 
236
241
  var firstCommand = args[2];
237
242
 
238
243
  if (!_.includes(knownCommands, firstCommand)) {
239
244
  debug('unknown command %s', firstCommand);
240
- logger.error('Unknown command', '"' + firstCommand + '"');
245
+ logger.error('Unknown command', "\"".concat(firstCommand, "\""));
241
246
  program.outputHelp();
242
-
243
247
  return util.exit(1);
244
248
  }
245
249
 
@@ -252,7 +256,6 @@ module.exports = {
252
256
  }
253
257
 
254
258
  debug('program parsing arguments');
255
-
256
259
  return program.parse(args);
257
260
  }
258
261
  };
package/lib/cypress.js CHANGED
@@ -1,33 +1,33 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  // https://github.com/cypress-io/cypress/issues/316
4
-
5
4
  var Promise = require('bluebird');
5
+
6
6
  var tmp = Promise.promisifyAll(require('tmp'));
7
7
 
8
8
  var fs = require('./fs');
9
+
9
10
  var _open = require('./exec/open');
11
+
10
12
  var _run = require('./exec/run');
13
+
11
14
  var util = require('./util');
12
15
 
13
16
  var cypressModuleApi = {
14
17
  open: function open() {
15
18
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
16
-
17
19
  options = util.normalizeModuleOptions(options);
18
-
19
20
  return _open.start(options);
20
21
  },
21
22
  run: function run() {
22
23
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
23
-
24
24
  options = util.normalizeModuleOptions(options);
25
-
26
25
  return tmp.fileAsync().then(function (outputPath) {
27
26
  options.outputPath = outputPath;
28
-
29
27
  return _run.start(options).then(function (failedTests) {
30
- return fs.readJsonAsync(outputPath, { throws: false }).then(function (output) {
28
+ return fs.readJsonAsync(outputPath, {
29
+ "throws": false
30
+ }).then(function (output) {
31
31
  if (!output) {
32
32
  return {
33
33
  failures: failedTests,
@@ -41,5 +41,4 @@ var cypressModuleApi = {
41
41
  });
42
42
  }
43
43
  };
44
-
45
44
  module.exports = cypressModuleApi;