cypress 15.2.0 → 15.4.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 +1 -1
- package/{lib → dist}/cli.js +221 -190
- package/{lib → dist}/cypress.js +29 -26
- package/{lib → dist}/errors.js +38 -26
- package/{lib → dist}/exec/info.js +2 -2
- package/{lib → dist}/exec/open.js +16 -7
- package/{lib → dist}/exec/run.js +41 -27
- package/dist/exec/spawn.js +311 -0
- package/dist/exec/versions.js +67 -0
- package/{lib → dist}/exec/xvfb.js +47 -20
- package/{index.js → dist/index.js} +5 -5
- package/dist/index.mjs +9 -0
- package/{lib → dist}/tasks/cache.js +49 -52
- package/{lib → dist}/tasks/download.js +55 -64
- package/{lib → dist}/tasks/get-folder-size.js +4 -4
- package/{lib → dist}/tasks/install.js +41 -45
- package/{lib → dist}/tasks/state.js +55 -45
- package/dist/tasks/unzip.js +192 -0
- package/{lib → dist}/tasks/verify.js +121 -131
- package/{lib → dist}/util.js +39 -39
- package/package.json +13 -13
- package/types/cypress-automation.d.ts +2 -1
- package/types/cypress-npm-api.d.ts +4 -0
- package/types/cypress.d.ts +42 -29
- package/index.mjs +0 -17
- package/lib/exec/spawn.js +0 -285
- package/lib/exec/versions.js +0 -61
- package/lib/fs.js +0 -8
- package/lib/tasks/unzip.js +0 -198
- /package/{lib → dist}/VerboseRenderer.js +0 -0
- /package/{lib → dist}/exec/shared.js +0 -0
- /package/{lib → dist}/logger.js +0 -0
package/bin/cypress
CHANGED
package/{lib → dist}/cli.js
RENAMED
@@ -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 =
|
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
|
-
|
41
|
+
process.exit(1);
|
33
42
|
}
|
34
43
|
commander_1.default.Command.prototype.unknownOption = unknownOption;
|
35
44
|
const coerceFalse = (arg) => {
|
@@ -115,6 +124,7 @@ const descriptions = {
|
|
115
124
|
parallel: 'enables concurrent runs and automatic load balancing of specs across multiple machines or processes',
|
116
125
|
port: 'runs Cypress on a specific port. overrides any value in cypress.config.{js,ts,mjs,cjs}.',
|
117
126
|
project: 'path to the project',
|
127
|
+
posixExitCodes: 'use POSIX exit codes for error handling',
|
118
128
|
quiet: 'run quietly, using only the configured reporter',
|
119
129
|
record: 'records the run. sends test results, screenshots and videos to Cypress Cloud.',
|
120
130
|
reporter: 'runs a specific mocha reporter. pass a path to use a custom reporter. defaults to "spec"',
|
@@ -150,50 +160,53 @@ function includesVersion(args) {
|
|
150
160
|
lodash_1.default.includes(args, '-v'));
|
151
161
|
}
|
152
162
|
function showVersions(opts) {
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
const reportComponentVersion = (componentName, versions) => {
|
163
|
-
const names = {
|
164
|
-
package: 'package',
|
165
|
-
binary: 'binary',
|
166
|
-
electron: 'electronVersion',
|
167
|
-
node: 'electronNodeVersion',
|
163
|
+
return __awaiter(this, void 0, void 0, function* () {
|
164
|
+
debug('printing Cypress version');
|
165
|
+
debug('additional arguments %o', opts);
|
166
|
+
debug('parsed version arguments %o', opts);
|
167
|
+
const reportAllVersions = (versions) => {
|
168
|
+
logger_1.default.always('Cypress package version:', versions.package);
|
169
|
+
logger_1.default.always('Cypress binary version:', versions.binary);
|
170
|
+
logger_1.default.always('Electron version:', versions.electronVersion);
|
171
|
+
logger_1.default.always('Bundled Node version:', versions.electronNodeVersion);
|
168
172
|
};
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
173
|
+
const reportComponentVersion = (componentName, versions) => {
|
174
|
+
const names = {
|
175
|
+
package: 'package',
|
176
|
+
binary: 'binary',
|
177
|
+
electron: 'electronVersion',
|
178
|
+
node: 'electronNodeVersion',
|
179
|
+
};
|
180
|
+
if (!names[componentName]) {
|
181
|
+
throw new Error(`Unknown component name "${componentName}"`);
|
182
|
+
}
|
183
|
+
const name = names[componentName];
|
184
|
+
if (!versions[name]) {
|
185
|
+
throw new Error(`Cannot find version for component "${componentName}" under property "${name}"`);
|
186
|
+
}
|
187
|
+
const version = versions[name];
|
188
|
+
logger_1.default.always(version);
|
189
|
+
};
|
190
|
+
const defaultVersions = {
|
191
|
+
package: undefined,
|
192
|
+
binary: undefined,
|
193
|
+
electronVersion: undefined,
|
194
|
+
electronNodeVersion: undefined,
|
195
|
+
};
|
196
|
+
try {
|
197
|
+
const versions = (yield versions_1.default.getVersions()) || defaultVersions;
|
198
|
+
if (opts === null || opts === void 0 ? void 0 : opts.component) {
|
199
|
+
reportComponentVersion(opts.component, versions);
|
200
|
+
}
|
201
|
+
else {
|
202
|
+
reportAllVersions(versions);
|
203
|
+
}
|
204
|
+
process.exit(0);
|
190
205
|
}
|
191
|
-
|
192
|
-
|
206
|
+
catch (e) {
|
207
|
+
util_1.default.logErrorExit1(e);
|
193
208
|
}
|
194
|
-
|
195
|
-
})
|
196
|
-
.catch(util_1.default.logErrorExit1);
|
209
|
+
});
|
197
210
|
}
|
198
211
|
const createProgram = () => {
|
199
212
|
const program = new commander_1.default.Command();
|
@@ -224,6 +237,7 @@ const addCypressRunCommand = (program) => {
|
|
224
237
|
.option('--parallel', text('parallel'))
|
225
238
|
.option('-p, --port <port>', text('port'))
|
226
239
|
.option('-P, --project <project-path>', text('project'))
|
240
|
+
.option('--posix-exit-codes', text('posixExitCodes'))
|
227
241
|
.option('-q, --quiet', text('quiet'))
|
228
242
|
.option('--record [bool]', text('record'), coerceFalse)
|
229
243
|
.option('-r, --reporter <reporter>', text('reporter'))
|
@@ -345,171 +359,188 @@ const cliModule = {
|
|
345
359
|
* Parses the command line and kicks off Cypress process.
|
346
360
|
*/
|
347
361
|
init(args) {
|
348
|
-
|
349
|
-
args
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
362
|
+
return __awaiter(this, void 0, void 0, function* () {
|
363
|
+
if (!args) {
|
364
|
+
args = process.argv;
|
365
|
+
}
|
366
|
+
const { CYPRESS_INTERNAL_ENV, CYPRESS_DOWNLOAD_USE_CA } = process.env;
|
367
|
+
if (process.env.CYPRESS_DOWNLOAD_USE_CA) {
|
368
|
+
let msg = `
|
354
369
|
${log_symbols_1.default.warning} Warning: It looks like you're setting CYPRESS_DOWNLOAD_USE_CA=${CYPRESS_DOWNLOAD_USE_CA}
|
355
370
|
|
356
371
|
The environment variable "CYPRESS_DOWNLOAD_USE_CA" is no longer required to be set.
|
357
372
|
|
358
373
|
You can safely unset this environment variable.
|
359
374
|
`;
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
375
|
+
logger_1.default.log();
|
376
|
+
logger_1.default.warn((0, common_tags_1.stripIndent)(msg));
|
377
|
+
logger_1.default.log();
|
378
|
+
}
|
379
|
+
if (!util_1.default.isValidCypressInternalEnvValue(CYPRESS_INTERNAL_ENV)) {
|
380
|
+
debug('invalid CYPRESS_INTERNAL_ENV value', CYPRESS_INTERNAL_ENV);
|
381
|
+
return (0, errors_1.exitWithError)(errors_1.errors.invalidCypressEnv)(`CYPRESS_INTERNAL_ENV=${CYPRESS_INTERNAL_ENV}`);
|
382
|
+
}
|
383
|
+
if (util_1.default.isNonProductionCypressInternalEnvValue(CYPRESS_INTERNAL_ENV)) {
|
384
|
+
debug('non-production CYPRESS_INTERNAL_ENV value', CYPRESS_INTERNAL_ENV);
|
385
|
+
let msg = `
|
371
386
|
${log_symbols_1.default.warning} Warning: It looks like you're passing CYPRESS_INTERNAL_ENV=${CYPRESS_INTERNAL_ENV}
|
372
387
|
|
373
388
|
The environment variable "CYPRESS_INTERNAL_ENV" is reserved and should only be used internally.
|
374
389
|
|
375
390
|
Unset the "CYPRESS_INTERNAL_ENV" environment variable and run Cypress again.
|
376
391
|
`;
|
377
|
-
|
378
|
-
|
379
|
-
|
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);
|
392
|
+
logger_1.default.log();
|
393
|
+
logger_1.default.warn((0, common_tags_1.stripIndent)(msg));
|
394
|
+
logger_1.default.log();
|
450
395
|
}
|
451
|
-
const
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
396
|
+
const program = createProgram();
|
397
|
+
program
|
398
|
+
.command('help')
|
399
|
+
.description('Shows CLI help and exits')
|
400
|
+
.action(() => {
|
401
|
+
program.help();
|
402
|
+
});
|
403
|
+
const handleVersion = (cmd) => {
|
404
|
+
return cmd
|
405
|
+
.option('--component <package|binary|electron|node>', 'component to report version for')
|
406
|
+
.action((opts, ...other) => {
|
407
|
+
showVersions(util_1.default.parseOpts(opts));
|
459
408
|
});
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
409
|
+
};
|
410
|
+
handleVersion(program
|
411
|
+
.storeOptionsAsProperties()
|
412
|
+
.option('-v, --version', text('version'))
|
413
|
+
.command('version')
|
414
|
+
.description(text('version')));
|
415
|
+
maybeAddInspectFlags(addCypressOpenCommand(program))
|
416
|
+
.action((opts) => __awaiter(this, void 0, void 0, function* () {
|
417
|
+
debug('opening Cypress');
|
418
|
+
try {
|
419
|
+
const code = yield open_1.default.start(util_1.default.parseOpts(opts));
|
420
|
+
process.exit(code);
|
421
|
+
}
|
422
|
+
catch (e) {
|
423
|
+
util_1.default.logErrorExit1(e);
|
424
|
+
}
|
425
|
+
}));
|
426
|
+
maybeAddInspectFlags(addCypressRunCommand(program))
|
427
|
+
.action((...fnArgs) => __awaiter(this, void 0, void 0, function* () {
|
428
|
+
debug('running Cypress with args %o', fnArgs);
|
429
|
+
try {
|
430
|
+
const code = yield run_1.default.start(parseVariableOpts(fnArgs, args));
|
431
|
+
process.exit(code);
|
432
|
+
}
|
433
|
+
catch (e) {
|
434
|
+
util_1.default.logErrorExit1(e);
|
435
|
+
}
|
436
|
+
}));
|
437
|
+
program
|
438
|
+
.command('install')
|
439
|
+
.usage('[options]')
|
440
|
+
.description('Installs the Cypress executable matching this package\'s version')
|
441
|
+
.option('-f, --force', text('forceInstall'))
|
442
|
+
.action((opts) => __awaiter(this, void 0, void 0, function* () {
|
443
|
+
try {
|
444
|
+
yield install_1.default.start(util_1.default.parseOpts(opts));
|
445
|
+
}
|
446
|
+
catch (e) {
|
467
447
|
util_1.default.logErrorExit1(e);
|
448
|
+
}
|
449
|
+
}));
|
450
|
+
program
|
451
|
+
.command('verify')
|
452
|
+
.usage('[options]')
|
453
|
+
.description('Verifies that Cypress is installed correctly and executable')
|
454
|
+
.option('--dev', text('dev'), coerceFalse)
|
455
|
+
.action((opts) => __awaiter(this, void 0, void 0, function* () {
|
456
|
+
const defaultOpts = { force: true, welcomeMessage: false };
|
457
|
+
const parsedOpts = util_1.default.parseOpts(opts);
|
458
|
+
const options = lodash_1.default.extend(parsedOpts, defaultOpts);
|
459
|
+
try {
|
460
|
+
yield (0, verify_1.start)(options);
|
461
|
+
}
|
462
|
+
catch (e) {
|
463
|
+
util_1.default.logErrorExit1(e);
|
464
|
+
}
|
465
|
+
}));
|
466
|
+
program
|
467
|
+
.command('cache')
|
468
|
+
.usage('[command]')
|
469
|
+
.description('Manages the Cypress binary cache')
|
470
|
+
.option('list', text('cacheList'))
|
471
|
+
.option('path', text('cachePath'))
|
472
|
+
.option('clear', text('cacheClear'))
|
473
|
+
.option('prune', text('cachePrune'))
|
474
|
+
.option('--size', text('cacheSize'))
|
475
|
+
.action(function (opts, args) {
|
476
|
+
return __awaiter(this, void 0, void 0, function* () {
|
477
|
+
if (!args || !args.length) {
|
478
|
+
this.outputHelp();
|
479
|
+
process.exit(1);
|
480
|
+
}
|
481
|
+
const [command] = args;
|
482
|
+
if (!lodash_1.default.includes(['list', 'path', 'clear', 'prune'], command)) {
|
483
|
+
unknownOption.call(this, `cache ${command}`, 'command');
|
484
|
+
}
|
485
|
+
if (command === 'list') {
|
486
|
+
debug('cache command %o', {
|
487
|
+
command,
|
488
|
+
size: opts.size,
|
489
|
+
});
|
490
|
+
try {
|
491
|
+
const result = yield cache_1.default.list(opts.size);
|
492
|
+
return result;
|
493
|
+
}
|
494
|
+
catch (e) {
|
495
|
+
if (e.code === 'ENOENT') {
|
496
|
+
logger_1.default.always('No cached binary versions were found.');
|
497
|
+
process.exit(0);
|
498
|
+
}
|
499
|
+
util_1.default.logErrorExit1(e);
|
500
|
+
}
|
501
|
+
}
|
502
|
+
cache_1.default[command]();
|
468
503
|
});
|
504
|
+
});
|
505
|
+
program
|
506
|
+
.command('info')
|
507
|
+
.usage('[command]')
|
508
|
+
.description('Prints Cypress and system information')
|
509
|
+
.option('--dev', text('dev'), coerceFalse)
|
510
|
+
.action((opts) => __awaiter(this, void 0, void 0, function* () {
|
511
|
+
try {
|
512
|
+
const code = yield info_1.default.start(opts);
|
513
|
+
process.exit(code);
|
514
|
+
}
|
515
|
+
catch (e) {
|
516
|
+
util_1.default.logErrorExit1(e);
|
517
|
+
}
|
518
|
+
}));
|
519
|
+
debug('cli starts with arguments %j', args);
|
520
|
+
util_1.default.printNodeOptions();
|
521
|
+
// if there are no arguments
|
522
|
+
if (args.length <= 2) {
|
523
|
+
debug('printing help');
|
524
|
+
program.help();
|
525
|
+
// exits
|
469
526
|
}
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
.
|
481
|
-
|
527
|
+
const firstCommand = args[2];
|
528
|
+
if (!lodash_1.default.includes(knownCommands, firstCommand)) {
|
529
|
+
debug('unknown command %s', firstCommand);
|
530
|
+
logger_1.default.error('Unknown command', `"${firstCommand}"`);
|
531
|
+
program.outputHelp();
|
532
|
+
return process.exit(1);
|
533
|
+
}
|
534
|
+
if (includesVersion(args)) {
|
535
|
+
// commander 2.11.0 changes behavior
|
536
|
+
// and now does not understand top level options
|
537
|
+
// .option('-v, --version').command('version')
|
538
|
+
// so we have to manually catch '-v, --version'
|
539
|
+
handleVersion(program);
|
540
|
+
}
|
541
|
+
debug('program parsing arguments');
|
542
|
+
return program.parse(args);
|
482
543
|
});
|
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
544
|
},
|
508
545
|
};
|
509
546
|
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
|
-
}
|
package/{lib → dist}/cypress.js
RENAMED
@@ -1,16 +1,23 @@
|
|
1
1
|
"use strict";
|
2
|
-
|
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
|
-
|
14
|
+
// https://github.com/cypress-io/cypress/issues/316
|
7
15
|
const tmp_1 = __importDefault(require("tmp"));
|
8
|
-
const
|
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(
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
.
|
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
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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: {
|