cypress 15.2.0 → 15.3.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/bin/cypress CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- const CLI = require('../lib/cli').default
3
+ const CLI = require('../dist/cli').default
4
4
 
5
5
  CLI.init()
@@ -1,4 +1,13 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
2
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
3
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
13
  };
@@ -15,7 +24,7 @@ const errors_1 = require("./errors");
15
24
  const cache_1 = __importDefault(require("./tasks/cache"));
16
25
  const open_1 = __importDefault(require("./exec/open"));
17
26
  const run_1 = __importDefault(require("./exec/run"));
18
- const verify_1 = __importDefault(require("./tasks/verify"));
27
+ const verify_1 = require("./tasks/verify");
19
28
  const install_1 = __importDefault(require("./tasks/install"));
20
29
  const versions_1 = __importDefault(require("./exec/versions"));
21
30
  const info_1 = __importDefault(require("./exec/info"));
@@ -29,7 +38,7 @@ function unknownOption(flag, type = 'option') {
29
38
  logger_1.default.error(` error: unknown ${type}:`, flag);
30
39
  logger_1.default.error();
31
40
  this.outputHelp();
32
- util_1.default.exit(1);
41
+ process.exit(1);
33
42
  }
34
43
  commander_1.default.Command.prototype.unknownOption = unknownOption;
35
44
  const coerceFalse = (arg) => {
@@ -150,50 +159,53 @@ function includesVersion(args) {
150
159
  lodash_1.default.includes(args, '-v'));
151
160
  }
152
161
  function showVersions(opts) {
153
- debug('printing Cypress version');
154
- debug('additional arguments %o', opts);
155
- debug('parsed version arguments %o', opts);
156
- const reportAllVersions = (versions) => {
157
- logger_1.default.always('Cypress package version:', versions.package);
158
- logger_1.default.always('Cypress binary version:', versions.binary);
159
- logger_1.default.always('Electron version:', versions.electronVersion);
160
- logger_1.default.always('Bundled Node version:', versions.electronNodeVersion);
161
- };
162
- const reportComponentVersion = (componentName, versions) => {
163
- const names = {
164
- package: 'package',
165
- binary: 'binary',
166
- electron: 'electronVersion',
167
- node: 'electronNodeVersion',
162
+ return __awaiter(this, void 0, void 0, function* () {
163
+ debug('printing Cypress version');
164
+ debug('additional arguments %o', opts);
165
+ debug('parsed version arguments %o', opts);
166
+ const reportAllVersions = (versions) => {
167
+ logger_1.default.always('Cypress package version:', versions.package);
168
+ logger_1.default.always('Cypress binary version:', versions.binary);
169
+ logger_1.default.always('Electron version:', versions.electronVersion);
170
+ logger_1.default.always('Bundled Node version:', versions.electronNodeVersion);
168
171
  };
169
- if (!names[componentName]) {
170
- throw new Error(`Unknown component name "${componentName}"`);
171
- }
172
- const name = names[componentName];
173
- if (!versions[name]) {
174
- throw new Error(`Cannot find version for component "${componentName}" under property "${name}"`);
175
- }
176
- const version = versions[name];
177
- logger_1.default.always(version);
178
- };
179
- const defaultVersions = {
180
- package: undefined,
181
- binary: undefined,
182
- electronVersion: undefined,
183
- electronNodeVersion: undefined,
184
- };
185
- return versions_1.default
186
- .getVersions()
187
- .then((versions = defaultVersions) => {
188
- if (opts === null || opts === void 0 ? void 0 : opts.component) {
189
- reportComponentVersion(opts.component, versions);
172
+ const reportComponentVersion = (componentName, versions) => {
173
+ const names = {
174
+ package: 'package',
175
+ binary: 'binary',
176
+ electron: 'electronVersion',
177
+ node: 'electronNodeVersion',
178
+ };
179
+ if (!names[componentName]) {
180
+ throw new Error(`Unknown component name "${componentName}"`);
181
+ }
182
+ const name = names[componentName];
183
+ if (!versions[name]) {
184
+ throw new Error(`Cannot find version for component "${componentName}" under property "${name}"`);
185
+ }
186
+ const version = versions[name];
187
+ logger_1.default.always(version);
188
+ };
189
+ const defaultVersions = {
190
+ package: undefined,
191
+ binary: undefined,
192
+ electronVersion: undefined,
193
+ electronNodeVersion: undefined,
194
+ };
195
+ try {
196
+ const versions = (yield versions_1.default.getVersions()) || defaultVersions;
197
+ if (opts === null || opts === void 0 ? void 0 : opts.component) {
198
+ reportComponentVersion(opts.component, versions);
199
+ }
200
+ else {
201
+ reportAllVersions(versions);
202
+ }
203
+ process.exit(0);
190
204
  }
191
- else {
192
- reportAllVersions(versions);
205
+ catch (e) {
206
+ util_1.default.logErrorExit1(e);
193
207
  }
194
- process.exit(0);
195
- })
196
- .catch(util_1.default.logErrorExit1);
208
+ });
197
209
  }
198
210
  const createProgram = () => {
199
211
  const program = new commander_1.default.Command();
@@ -345,171 +357,188 @@ const cliModule = {
345
357
  * Parses the command line and kicks off Cypress process.
346
358
  */
347
359
  init(args) {
348
- if (!args) {
349
- args = process.argv;
350
- }
351
- const { CYPRESS_INTERNAL_ENV, CYPRESS_DOWNLOAD_USE_CA } = process.env;
352
- if (process.env.CYPRESS_DOWNLOAD_USE_CA) {
353
- let msg = `
360
+ return __awaiter(this, void 0, void 0, function* () {
361
+ if (!args) {
362
+ args = process.argv;
363
+ }
364
+ const { CYPRESS_INTERNAL_ENV, CYPRESS_DOWNLOAD_USE_CA } = process.env;
365
+ if (process.env.CYPRESS_DOWNLOAD_USE_CA) {
366
+ let msg = `
354
367
  ${log_symbols_1.default.warning} Warning: It looks like you're setting CYPRESS_DOWNLOAD_USE_CA=${CYPRESS_DOWNLOAD_USE_CA}
355
368
 
356
369
  The environment variable "CYPRESS_DOWNLOAD_USE_CA" is no longer required to be set.
357
370
 
358
371
  You can safely unset this environment variable.
359
372
  `;
360
- logger_1.default.log();
361
- logger_1.default.warn((0, common_tags_1.stripIndent)(msg));
362
- logger_1.default.log();
363
- }
364
- if (!util_1.default.isValidCypressInternalEnvValue(CYPRESS_INTERNAL_ENV)) {
365
- debug('invalid CYPRESS_INTERNAL_ENV value', CYPRESS_INTERNAL_ENV);
366
- return (0, errors_1.exitWithError)(errors_1.errors.invalidCypressEnv)(`CYPRESS_INTERNAL_ENV=${CYPRESS_INTERNAL_ENV}`);
367
- }
368
- if (util_1.default.isNonProductionCypressInternalEnvValue(CYPRESS_INTERNAL_ENV)) {
369
- debug('non-production CYPRESS_INTERNAL_ENV value', CYPRESS_INTERNAL_ENV);
370
- let msg = `
373
+ logger_1.default.log();
374
+ logger_1.default.warn((0, common_tags_1.stripIndent)(msg));
375
+ logger_1.default.log();
376
+ }
377
+ if (!util_1.default.isValidCypressInternalEnvValue(CYPRESS_INTERNAL_ENV)) {
378
+ debug('invalid CYPRESS_INTERNAL_ENV value', CYPRESS_INTERNAL_ENV);
379
+ return (0, errors_1.exitWithError)(errors_1.errors.invalidCypressEnv)(`CYPRESS_INTERNAL_ENV=${CYPRESS_INTERNAL_ENV}`);
380
+ }
381
+ if (util_1.default.isNonProductionCypressInternalEnvValue(CYPRESS_INTERNAL_ENV)) {
382
+ debug('non-production CYPRESS_INTERNAL_ENV value', CYPRESS_INTERNAL_ENV);
383
+ let msg = `
371
384
  ${log_symbols_1.default.warning} Warning: It looks like you're passing CYPRESS_INTERNAL_ENV=${CYPRESS_INTERNAL_ENV}
372
385
 
373
386
  The environment variable "CYPRESS_INTERNAL_ENV" is reserved and should only be used internally.
374
387
 
375
388
  Unset the "CYPRESS_INTERNAL_ENV" environment variable and run Cypress again.
376
389
  `;
377
- logger_1.default.log();
378
- logger_1.default.warn((0, common_tags_1.stripIndent)(msg));
379
- logger_1.default.log();
380
- }
381
- const program = createProgram();
382
- program
383
- .command('help')
384
- .description('Shows CLI help and exits')
385
- .action(() => {
386
- program.help();
387
- });
388
- const handleVersion = (cmd) => {
389
- return cmd
390
- .option('--component <package|binary|electron|node>', 'component to report version for')
391
- .action((opts, ...other) => {
392
- showVersions(util_1.default.parseOpts(opts));
393
- });
394
- };
395
- handleVersion(program
396
- .storeOptionsAsProperties()
397
- .option('-v, --version', text('version'))
398
- .command('version')
399
- .description(text('version')));
400
- maybeAddInspectFlags(addCypressOpenCommand(program))
401
- .action((opts) => {
402
- debug('opening Cypress');
403
- open_1.default.start(util_1.default.parseOpts(opts))
404
- .then(util_1.default.exit)
405
- .catch(util_1.default.logErrorExit1);
406
- });
407
- maybeAddInspectFlags(addCypressRunCommand(program))
408
- .action((...fnArgs) => {
409
- debug('running Cypress with args %o', fnArgs);
410
- run_1.default.start(parseVariableOpts(fnArgs, args))
411
- .then(util_1.default.exit)
412
- .catch(util_1.default.logErrorExit1);
413
- });
414
- program
415
- .command('install')
416
- .usage('[options]')
417
- .description('Installs the Cypress executable matching this package\'s version')
418
- .option('-f, --force', text('forceInstall'))
419
- .action((opts) => {
420
- install_1.default
421
- .start(util_1.default.parseOpts(opts))
422
- .catch(util_1.default.logErrorExit1);
423
- });
424
- program
425
- .command('verify')
426
- .usage('[options]')
427
- .description('Verifies that Cypress is installed correctly and executable')
428
- .option('--dev', text('dev'), coerceFalse)
429
- .action((opts) => {
430
- const defaultOpts = { force: true, welcomeMessage: false };
431
- const parsedOpts = util_1.default.parseOpts(opts);
432
- const options = lodash_1.default.extend(parsedOpts, defaultOpts);
433
- verify_1.default
434
- .start(options)
435
- .catch(util_1.default.logErrorExit1);
436
- });
437
- program
438
- .command('cache')
439
- .usage('[command]')
440
- .description('Manages the Cypress binary cache')
441
- .option('list', text('cacheList'))
442
- .option('path', text('cachePath'))
443
- .option('clear', text('cacheClear'))
444
- .option('prune', text('cachePrune'))
445
- .option('--size', text('cacheSize'))
446
- .action(function (opts, args) {
447
- if (!args || !args.length) {
448
- this.outputHelp();
449
- util_1.default.exit(1);
390
+ logger_1.default.log();
391
+ logger_1.default.warn((0, common_tags_1.stripIndent)(msg));
392
+ logger_1.default.log();
450
393
  }
451
- const [command] = args;
452
- if (!lodash_1.default.includes(['list', 'path', 'clear', 'prune'], command)) {
453
- unknownOption.call(this, `cache ${command}`, 'command');
454
- }
455
- if (command === 'list') {
456
- debug('cache command %o', {
457
- command,
458
- size: opts.size,
394
+ const program = createProgram();
395
+ program
396
+ .command('help')
397
+ .description('Shows CLI help and exits')
398
+ .action(() => {
399
+ program.help();
400
+ });
401
+ const handleVersion = (cmd) => {
402
+ return cmd
403
+ .option('--component <package|binary|electron|node>', 'component to report version for')
404
+ .action((opts, ...other) => {
405
+ showVersions(util_1.default.parseOpts(opts));
459
406
  });
460
- return cache_1.default.list(opts.size)
461
- .catch({ code: 'ENOENT' }, () => {
462
- logger_1.default.always('No cached binary versions were found.');
463
- process.exit(0);
464
- })
465
- .catch((e) => {
466
- debug('cache list command failed with "%s"', e.message);
407
+ };
408
+ handleVersion(program
409
+ .storeOptionsAsProperties()
410
+ .option('-v, --version', text('version'))
411
+ .command('version')
412
+ .description(text('version')));
413
+ maybeAddInspectFlags(addCypressOpenCommand(program))
414
+ .action((opts) => __awaiter(this, void 0, void 0, function* () {
415
+ debug('opening Cypress');
416
+ try {
417
+ const code = yield open_1.default.start(util_1.default.parseOpts(opts));
418
+ process.exit(code);
419
+ }
420
+ catch (e) {
421
+ util_1.default.logErrorExit1(e);
422
+ }
423
+ }));
424
+ maybeAddInspectFlags(addCypressRunCommand(program))
425
+ .action((...fnArgs) => __awaiter(this, void 0, void 0, function* () {
426
+ debug('running Cypress with args %o', fnArgs);
427
+ try {
428
+ const code = yield run_1.default.start(parseVariableOpts(fnArgs, args));
429
+ process.exit(code);
430
+ }
431
+ catch (e) {
432
+ util_1.default.logErrorExit1(e);
433
+ }
434
+ }));
435
+ program
436
+ .command('install')
437
+ .usage('[options]')
438
+ .description('Installs the Cypress executable matching this package\'s version')
439
+ .option('-f, --force', text('forceInstall'))
440
+ .action((opts) => __awaiter(this, void 0, void 0, function* () {
441
+ try {
442
+ yield install_1.default.start(util_1.default.parseOpts(opts));
443
+ }
444
+ catch (e) {
467
445
  util_1.default.logErrorExit1(e);
446
+ }
447
+ }));
448
+ program
449
+ .command('verify')
450
+ .usage('[options]')
451
+ .description('Verifies that Cypress is installed correctly and executable')
452
+ .option('--dev', text('dev'), coerceFalse)
453
+ .action((opts) => __awaiter(this, void 0, void 0, function* () {
454
+ const defaultOpts = { force: true, welcomeMessage: false };
455
+ const parsedOpts = util_1.default.parseOpts(opts);
456
+ const options = lodash_1.default.extend(parsedOpts, defaultOpts);
457
+ try {
458
+ yield (0, verify_1.start)(options);
459
+ }
460
+ catch (e) {
461
+ util_1.default.logErrorExit1(e);
462
+ }
463
+ }));
464
+ program
465
+ .command('cache')
466
+ .usage('[command]')
467
+ .description('Manages the Cypress binary cache')
468
+ .option('list', text('cacheList'))
469
+ .option('path', text('cachePath'))
470
+ .option('clear', text('cacheClear'))
471
+ .option('prune', text('cachePrune'))
472
+ .option('--size', text('cacheSize'))
473
+ .action(function (opts, args) {
474
+ return __awaiter(this, void 0, void 0, function* () {
475
+ if (!args || !args.length) {
476
+ this.outputHelp();
477
+ process.exit(1);
478
+ }
479
+ const [command] = args;
480
+ if (!lodash_1.default.includes(['list', 'path', 'clear', 'prune'], command)) {
481
+ unknownOption.call(this, `cache ${command}`, 'command');
482
+ }
483
+ if (command === 'list') {
484
+ debug('cache command %o', {
485
+ command,
486
+ size: opts.size,
487
+ });
488
+ try {
489
+ const result = yield cache_1.default.list(opts.size);
490
+ return result;
491
+ }
492
+ catch (e) {
493
+ if (e.code === 'ENOENT') {
494
+ logger_1.default.always('No cached binary versions were found.');
495
+ process.exit(0);
496
+ }
497
+ util_1.default.logErrorExit1(e);
498
+ }
499
+ }
500
+ cache_1.default[command]();
468
501
  });
502
+ });
503
+ program
504
+ .command('info')
505
+ .usage('[command]')
506
+ .description('Prints Cypress and system information')
507
+ .option('--dev', text('dev'), coerceFalse)
508
+ .action((opts) => __awaiter(this, void 0, void 0, function* () {
509
+ try {
510
+ const code = yield info_1.default.start(opts);
511
+ process.exit(code);
512
+ }
513
+ catch (e) {
514
+ util_1.default.logErrorExit1(e);
515
+ }
516
+ }));
517
+ debug('cli starts with arguments %j', args);
518
+ util_1.default.printNodeOptions();
519
+ // if there are no arguments
520
+ if (args.length <= 2) {
521
+ debug('printing help');
522
+ program.help();
523
+ // exits
469
524
  }
470
- cache_1.default[command]();
471
- });
472
- program
473
- .command('info')
474
- .usage('[command]')
475
- .description('Prints Cypress and system information')
476
- .option('--dev', text('dev'), coerceFalse)
477
- .action((opts) => {
478
- info_1.default
479
- .start(opts)
480
- .then(util_1.default.exit)
481
- .catch(util_1.default.logErrorExit1);
525
+ const firstCommand = args[2];
526
+ if (!lodash_1.default.includes(knownCommands, firstCommand)) {
527
+ debug('unknown command %s', firstCommand);
528
+ logger_1.default.error('Unknown command', `"${firstCommand}"`);
529
+ program.outputHelp();
530
+ return process.exit(1);
531
+ }
532
+ if (includesVersion(args)) {
533
+ // commander 2.11.0 changes behavior
534
+ // and now does not understand top level options
535
+ // .option('-v, --version').command('version')
536
+ // so we have to manually catch '-v, --version'
537
+ handleVersion(program);
538
+ }
539
+ debug('program parsing arguments');
540
+ return program.parse(args);
482
541
  });
483
- debug('cli starts with arguments %j', args);
484
- util_1.default.printNodeOptions();
485
- // if there are no arguments
486
- if (args.length <= 2) {
487
- debug('printing help');
488
- program.help();
489
- // exits
490
- }
491
- const firstCommand = args[2];
492
- if (!lodash_1.default.includes(knownCommands, firstCommand)) {
493
- debug('unknown command %s', firstCommand);
494
- logger_1.default.error('Unknown command', `"${firstCommand}"`);
495
- program.outputHelp();
496
- return util_1.default.exit(1);
497
- }
498
- if (includesVersion(args)) {
499
- // commander 2.11.0 changes behavior
500
- // and now does not understand top level options
501
- // .option('-v, --version').command('version')
502
- // so we have to manually catch '-v, --version'
503
- handleVersion(program);
504
- }
505
- debug('program parsing arguments');
506
- return program.parse(args);
507
542
  },
508
543
  };
509
544
  exports.default = cliModule;
510
- // @ts-ignore
511
- if (!module.parent) {
512
- logger_1.default.error('This CLI module should be required from another Node module');
513
- logger_1.default.error('and not executed directly');
514
- process.exit(-1);
515
- }
@@ -1,16 +1,23 @@
1
1
  "use strict";
2
- // https://github.com/cypress-io/cypress/issues/316
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
3
11
  var __importDefault = (this && this.__importDefault) || function (mod) {
4
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
5
13
  };
6
- const bluebird_1 = __importDefault(require("bluebird"));
14
+ // https://github.com/cypress-io/cypress/issues/316
7
15
  const tmp_1 = __importDefault(require("tmp"));
8
- const fs_1 = __importDefault(require("./fs"));
16
+ const fs_extra_1 = __importDefault(require("fs-extra"));
9
17
  const open_1 = __importDefault(require("./exec/open"));
10
18
  const run_1 = __importDefault(require("./exec/run"));
11
19
  const util_1 = __importDefault(require("./util"));
12
20
  const cli_1 = __importDefault(require("./cli"));
13
- const tmp = bluebird_1.default.promisifyAll(tmp_1.default);
14
21
  const cypressModuleApi = {
15
22
  /**
16
23
  * Opens Cypress GUI
@@ -24,29 +31,25 @@ const cypressModuleApi = {
24
31
  * Runs Cypress tests in the current project
25
32
  * @see https://on.cypress.io/module-api#cypress-run
26
33
  */
27
- run(options = {}) {
28
- if (!run_1.default.isValidProject(options.project)) {
29
- return bluebird_1.default.reject(new Error(`Invalid project path parameter: ${options.project}`));
30
- }
31
- options = util_1.default.normalizeModuleOptions(options);
32
- tmp.setGracefulCleanup();
33
- return tmp.fileAsync()
34
- .then((outputPath) => {
34
+ run() {
35
+ return __awaiter(this, arguments, void 0, function* (options = {}) {
36
+ if (!run_1.default.isValidProject(options.project)) {
37
+ throw new Error(`Invalid project path parameter: ${options.project}`);
38
+ }
39
+ options = util_1.default.normalizeModuleOptions(options);
40
+ tmp_1.default.setGracefulCleanup();
41
+ const outputPath = tmp_1.default.fileSync().name;
35
42
  options.outputPath = outputPath;
36
- return run_1.default.start(options)
37
- .then((failedTests) => {
38
- return fs_1.default.readJsonAsync(outputPath, { throws: false })
39
- .then((output) => {
40
- if (!output) {
41
- return {
42
- status: 'failed',
43
- failures: failedTests,
44
- message: 'Could not find Cypress test run results',
45
- };
46
- }
47
- return output;
48
- });
49
- });
43
+ const failedTests = yield run_1.default.start(options);
44
+ const output = yield fs_extra_1.default.readJson(outputPath, { throws: false });
45
+ if (!output) {
46
+ return {
47
+ status: 'failed',
48
+ failures: failedTests,
49
+ message: 'Could not find Cypress test run results',
50
+ };
51
+ }
52
+ return output;
50
53
  });
51
54
  },
52
55
  cli: {