cypress 16.2.0 → 16.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/angular/dist/index.js +10 -12
- package/angular/package.json +7 -22
- package/dist/bin/cypress +8 -8
- package/dist/{cli-AgTnS5LO.js → cli-y9Bb9Y77.js} +215 -40
- package/dist/cli.js +6 -6
- package/dist/{cypress-CdDm9AVa.js → cypress-CvEs5adm.js} +2 -2
- package/dist/cypress.js +8 -8
- package/dist/exec/spawn.js +4 -4
- package/dist/exec/xvfb.js +7 -4
- package/dist/index.js +8 -8
- package/dist/{spawn-DElwyZHC.js → spawn-Bx99tBTm.js} +529 -69
- package/dist/{tap-WHD3nHJC.js → tap-BMFGLoCT.js} +108 -26
- package/dist/{xvfb-CbW2_YXR.js → xvfb-DxbcANVl.js} +238 -25
- package/mount-utils/dist/index.js +1 -1
- package/mount-utils/package.json +15 -14
- package/package.json +5 -5
- package/react/dist/cypress-react.cjs.js +9 -7
- package/react/dist/cypress-react.esm-bundler.js +9 -7
- package/react/package.json +26 -46
- package/svelte/dist/cypress-svelte.cjs.js +3 -2
- package/svelte/dist/cypress-svelte.esm-bundler.js +3 -2
- package/svelte/package.json +24 -22
- package/types/cy-bluebird.d.ts +1 -0
- package/types/cy-chai.d.ts +99 -2
- package/types/cypress.d.ts +216 -43
- package/types/net-stubbing.d.ts +1 -1
- package/vue/dist/cypress-vue.cjs.js +4 -2
- package/vue/dist/cypress-vue.esm-bundler.js +4 -2
- package/vue/dist/index.d.ts +3 -3
- package/vue/package.json +35 -42
- package/angular/angular/README.md +0 -18
- package/angular/angular/dist/index.d.ts +0 -120
- package/angular/angular/dist/index.js +0 -479
- package/angular/angular/package.json +0 -82
- package/mount-utils/mount-utils/README.md +0 -140
- package/mount-utils/mount-utils/dist/index.d.ts +0 -12
- package/mount-utils/mount-utils/dist/index.js +0 -41
- package/mount-utils/mount-utils/package.json +0 -52
- package/react/react/README.md +0 -19
- package/react/react/dist/cypress-react.cjs.js +0 -293
- package/react/react/dist/cypress-react.esm-bundler.js +0 -268
- package/react/react/dist/index.d.ts +0 -95
- package/react/react/package.json +0 -113
- package/svelte/svelte/README.md +0 -19
- package/svelte/svelte/dist/cypress-svelte.cjs.js +0 -122
- package/svelte/svelte/dist/cypress-svelte.esm-bundler.js +0 -120
- package/svelte/svelte/dist/index.d.ts +0 -31
- package/svelte/svelte/package.json +0 -63
- package/vue/vue/README.md +0 -14
- package/vue/vue/dist/cypress-vue.cjs.js +0 -8692
- package/vue/vue/dist/cypress-vue.esm-bundler.js +0 -8671
- package/vue/vue/dist/index.d.ts +0 -1413
- package/vue/vue/package.json +0 -97
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var xvfb = require('./xvfb-
|
|
3
|
+
var xvfb = require('./xvfb-DxbcANVl.js');
|
|
4
4
|
var _ = require('lodash');
|
|
5
5
|
var commander = require('commander');
|
|
6
6
|
var commonTags = require('common-tags');
|
|
@@ -13,8 +13,8 @@ var dayjs = require('dayjs');
|
|
|
13
13
|
var relativeTime = require('dayjs/plugin/relativeTime');
|
|
14
14
|
var chalk = require('chalk');
|
|
15
15
|
var Bluebird = require('bluebird');
|
|
16
|
-
var spawn = require('./spawn-DElwyZHC.js');
|
|
17
16
|
var os = require('os');
|
|
17
|
+
var spawn = require('./spawn-Bx99tBTm.js');
|
|
18
18
|
var listr2 = require('listr2');
|
|
19
19
|
var timers = require('timers/promises');
|
|
20
20
|
var fsp = require('fs/promises');
|
|
@@ -112,6 +112,14 @@ function requireTapErrors () {
|
|
|
112
112
|
description: `Could not find a ${exports.TAP_TARGET} to tap into.`,
|
|
113
113
|
solution: 'Start Cypress with `cypress open`, select a testing type and launch a browser, then try again.',
|
|
114
114
|
},
|
|
115
|
+
/**
|
|
116
|
+
* Raised when Cypress is running but its project could not load, so there is no
|
|
117
|
+
* session to drive. Starting Cypress again would only run a second one.
|
|
118
|
+
*/
|
|
119
|
+
PROJECT_NOT_LOADED: {
|
|
120
|
+
description: `Cypress is running, but its project could not load, so there is no ${exports.TAP_TARGET} to tap into.`,
|
|
121
|
+
solution: 'Run `cypress tap status` to see why. Fix the cause, then stop Cypress and start it again.',
|
|
122
|
+
},
|
|
115
123
|
/**
|
|
116
124
|
* Raised when `--session` named a pid no record on disk matches.
|
|
117
125
|
*
|
|
@@ -309,7 +317,9 @@ function requireTapErrors () {
|
|
|
309
317
|
*
|
|
310
318
|
* @deprecated - raise it with new MissingCompanionOptionTapError(), which writes its copy
|
|
311
319
|
*/
|
|
312
|
-
MISSING_COMPANION_OPTION: {
|
|
320
|
+
MISSING_COMPANION_OPTION: {
|
|
321
|
+
attachHelp: true,
|
|
322
|
+
},
|
|
313
323
|
/**
|
|
314
324
|
* Raised when a known input was given a value of the wrong type or range.
|
|
315
325
|
*
|
|
@@ -459,8 +469,9 @@ function requireTapErrors () {
|
|
|
459
469
|
exports.SnapshotNotFoundTapError = SnapshotNotFoundTapError;
|
|
460
470
|
/**
|
|
461
471
|
* A flag that only means something alongside another one. Both are named here;
|
|
462
|
-
* `remedy`
|
|
463
|
-
* is particular to the pair — a
|
|
472
|
+
* `remedy` comes from the dependency's `requires` in the command schema, because
|
|
473
|
+
* what dropping either one leaves you with is particular to the pair — a
|
|
474
|
+
* spec-wide view rather than one test's attempt.
|
|
464
475
|
*/
|
|
465
476
|
class MissingCompanionOptionTapError extends DetailedTapError {
|
|
466
477
|
constructor(given, required, remedy) {
|
|
@@ -659,11 +670,28 @@ function requireTapContract () {
|
|
|
659
670
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
660
671
|
};
|
|
661
672
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
662
|
-
exports.KNOWN_COMMANDS = exports.TAP_NATIVE_COMMANDS = exports.buildTapSchema = exports.TAP_COMMANDS = exports.TAP_EXEC_METHOD = exports.TAP_SCHEMA_METHOD = exports.TAP_BINDING_GLOBAL = exports.TAP_SCHEMA_VERSION = void 0;
|
|
673
|
+
exports.KNOWN_COMMANDS = exports.TAP_NATIVE_COMMANDS = exports.buildTapSchema = exports.TAP_COMMANDS = exports.PIN_TARGET_REMEDY = exports.unmetDependency = exports.TAP_EXEC_METHOD = exports.TAP_SCHEMA_METHOD = exports.TAP_BINDING_GLOBAL = exports.TAP_SCHEMA_VERSION = void 0;
|
|
674
|
+
const tap_errors_1 = requireTapErrors();
|
|
663
675
|
exports.TAP_SCHEMA_VERSION = 1;
|
|
664
676
|
exports.TAP_BINDING_GLOBAL = '__CYPRESS_TAP_BINDING__';
|
|
665
677
|
exports.TAP_SCHEMA_METHOD = 'getSchema';
|
|
666
678
|
exports.TAP_EXEC_METHOD = 'exec';
|
|
679
|
+
/**
|
|
680
|
+
* The first option `supplied` passes without the companion it requires, raised as
|
|
681
|
+
* the failure both sides answer it with. `supplied` holds only the options the
|
|
682
|
+
* caller actually gave, keyed by schema name; a switch given as false was not
|
|
683
|
+
* really given.
|
|
684
|
+
*/
|
|
685
|
+
const unmetDependency = (options, supplied) => {
|
|
686
|
+
const given = (name) => supplied[name] !== undefined && supplied[name] !== false;
|
|
687
|
+
for (const { name, requires } of options) {
|
|
688
|
+
if (requires && given(name) && !given(requires.option) && !(requires.unless && given(requires.unless))) {
|
|
689
|
+
return new tap_errors_1.MissingCompanionOptionTapError(`--${name}`, `--${requires.option}`, requires.remedy);
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
return undefined;
|
|
693
|
+
};
|
|
694
|
+
exports.unmetDependency = unmetDependency;
|
|
667
695
|
// Options that recur across commands, defined once so their name, type, and help
|
|
668
696
|
// text can't drift between the commands that expose them. `test-id` and
|
|
669
697
|
// `command-id` are required in some commands and optional in others, so each use
|
|
@@ -704,18 +732,22 @@ wrong. Add --attempt to view an earlier retry.`,
|
|
|
704
732
|
params: [],
|
|
705
733
|
options: [
|
|
706
734
|
{ ...testIdField, required: false },
|
|
707
|
-
attemptField,
|
|
735
|
+
{ ...attemptField, requires: { option: 'test-id', remedy: 'Pass `--test-id` to specify the test, or omit `--attempt` to review the latest attempt for every test in the spec.' } },
|
|
708
736
|
],
|
|
709
737
|
};
|
|
738
|
+
// What a pin needs, said once for the call that names half a target and the one
|
|
739
|
+
// that names none.
|
|
740
|
+
exports.PIN_TARGET_REMEDY = 'Pass `--test-id` and `--command-id`, as listed by `cypress tap reporter`, or `--clear` to release the current pin.';
|
|
710
741
|
const pinMeta = {
|
|
711
742
|
name: 'pin',
|
|
712
743
|
description: 'pin a command’s DOM snapshot into the live application-under-test frame',
|
|
713
744
|
details: `Pins a command's DOM snapshot into the live application-under-test frame so the
|
|
714
|
-
dom/aria/inspect commands can read it.
|
|
745
|
+
dom/aria/inspect commands can read it. Name the command with --test-id and
|
|
746
|
+
--command-id, or pass --clear to release the current pin.`,
|
|
715
747
|
params: [],
|
|
716
748
|
options: [
|
|
717
|
-
{ ...testIdField, required: false },
|
|
718
|
-
{ ...commandIdField, required: false },
|
|
749
|
+
{ ...testIdField, required: false, requires: { option: 'command-id', unless: 'clear', remedy: exports.PIN_TARGET_REMEDY } },
|
|
750
|
+
{ ...commandIdField, required: false, requires: { option: 'test-id', unless: 'clear', remedy: exports.PIN_TARGET_REMEDY } },
|
|
719
751
|
attemptField,
|
|
720
752
|
{ name: 'at', type: 'string', required: false, description: 'which snapshot to pin: a name like "before"/"after" or a 1-based index; defaults to the last (the command’s final state). Re-run on the pinned command to switch snapshots without releasing the pin' },
|
|
721
753
|
{ name: 'clear', type: 'boolean', required: false, description: 'release the current pin and restore the app to its pre-pin state' },
|
|
@@ -798,10 +830,13 @@ tap command refuses it.`,
|
|
|
798
830
|
description: 'report where a Cypress session is in its lifecycle',
|
|
799
831
|
details: `Reports where a Cypress session is in its lifecycle, as JSON — for polling and
|
|
800
832
|
"where am I?" checks. Always exits 0 for a determinable stage (including "not
|
|
801
|
-
connected"); a poller branches on the \`status\` field.
|
|
833
|
+
connected" and "error"); a poller branches on the \`status\` field.
|
|
802
834
|
|
|
803
835
|
Stages:
|
|
804
836
|
- not connected: Cypress cannot be reached.
|
|
837
|
+
- error: Cypress is running but could not load the project, for example because
|
|
838
|
+
its configuration file is invalid. \`error\` carries the reason; fix the
|
|
839
|
+
project, then stop Cypress and start it again.
|
|
805
840
|
- browser not selected: Cypress does not have a supported browser open.
|
|
806
841
|
- spec not selected: Cypress has a browser open but no spec is selected.
|
|
807
842
|
- loading: Cypress is loading the spec.
|
|
@@ -1009,7 +1044,7 @@ function requireDist () {
|
|
|
1009
1044
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
1010
1045
|
};
|
|
1011
1046
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1012
|
-
exports.isCompatibleRecord = exports.tapGraphqlPath = exports.sessionProbePath = exports.recordPath = exports.cypressSessionsDir = exports.parseRecordPid = exports.recordFileName = exports.isTapSupportedBrowser = exports.TAP_SUPPORTED_BROWSER_FAMILY = exports.LEGACY_TAP_GRAPHQL_PATH = exports.TAP_GRAPHQL_ROUTE_PREFIX = exports.SESSION_ID_HEADER = exports.SESSIONS_ROUTE_PREFIX = exports.SESSIONS_DIRNAME = exports.MIN_SCHEMA_VERSION = exports.SCHEMA_VERSION = void 0;
|
|
1047
|
+
exports.isCompatibleRecord = exports.tapGraphqlPath = exports.sessionProbePath = exports.recordPath = exports.cypressSessionsDir = exports.parseRecordPid = exports.recordFileName = exports.isStartingRecord = exports.isTapSupportedBrowser = exports.TAP_SUPPORTED_BROWSER_FAMILY = exports.LEGACY_TAP_GRAPHQL_PATH = exports.TAP_GRAPHQL_ROUTE_PREFIX = exports.SESSION_ID_HEADER = exports.SESSIONS_ROUTE_PREFIX = exports.SESSIONS_DIRNAME = exports.MIN_SCHEMA_VERSION = exports.SCHEMA_VERSION = void 0;
|
|
1013
1048
|
const path_1 = __importDefault(path);
|
|
1014
1049
|
__exportStar(requireTapContract(), exports);
|
|
1015
1050
|
__exportStar(requireTapOperations(), exports);
|
|
@@ -1033,6 +1068,10 @@ function requireDist () {
|
|
|
1033
1068
|
return browserFamily === null || browserFamily === exports.TAP_SUPPORTED_BROWSER_FAMILY;
|
|
1034
1069
|
};
|
|
1035
1070
|
exports.isTapSupportedBrowser = isTapSupportedBrowser;
|
|
1071
|
+
const isStartingRecord = (record) => {
|
|
1072
|
+
return record.status === 'starting';
|
|
1073
|
+
};
|
|
1074
|
+
exports.isStartingRecord = isStartingRecord;
|
|
1036
1075
|
const recordFileName = (pid) => {
|
|
1037
1076
|
return `${pid}${RECORD_EXTENSION}`;
|
|
1038
1077
|
};
|
|
@@ -1065,6 +1104,7 @@ function requireDist () {
|
|
|
1065
1104
|
return value === 'e2e' || value === 'component' || value === null;
|
|
1066
1105
|
};
|
|
1067
1106
|
const isCompatibleRecord = (record) => {
|
|
1107
|
+
var _a;
|
|
1068
1108
|
return Boolean(record)
|
|
1069
1109
|
&& typeof record.schemaVersion === 'number'
|
|
1070
1110
|
&& record.schemaVersion >= exports.MIN_SCHEMA_VERSION
|
|
@@ -1073,7 +1113,11 @@ function requireDist () {
|
|
|
1073
1113
|
&& Number.isInteger(record.serverPort)
|
|
1074
1114
|
&& typeof record.sessionId === 'string'
|
|
1075
1115
|
&& record.sessionId.length > 0
|
|
1076
|
-
&& isValidTestingType(record.testingType)
|
|
1116
|
+
&& isValidTestingType(record.testingType)
|
|
1117
|
+
&& (record.status === undefined || record.status === 'starting')
|
|
1118
|
+
&& (record.serverPort !== 0 || record.status === 'starting')
|
|
1119
|
+
&& (record.loadError === undefined || typeof ((_a = record.loadError) === null || _a === void 0 ? void 0 : _a.message) === 'string')
|
|
1120
|
+
&& (record.status !== 'starting' || record.loadError !== undefined);
|
|
1077
1121
|
};
|
|
1078
1122
|
exports.isCompatibleRecord = isCompatibleRecord;
|
|
1079
1123
|
|
|
@@ -1182,14 +1226,22 @@ const readCompatibleRecord = (filePath) => xvfb.__awaiter(void 0, void 0, void 0
|
|
|
1182
1226
|
return record;
|
|
1183
1227
|
});
|
|
1184
1228
|
// Reaps a record whose writer process is gone, returning whether it was dead.
|
|
1229
|
+
// A pid that fails the signal check is not proof of death: a caller in another
|
|
1230
|
+
// PID namespace cannot see the writer's pid, so a record whose server still
|
|
1231
|
+
// answers its probe is kept. A record we could not read has no probe to try, so
|
|
1232
|
+
// its pid check stands alone.
|
|
1185
1233
|
// Removal is best-effort: a file we can't delete (permissions, a Windows lock)
|
|
1186
1234
|
// must not abort discovery of the other, live sessions, so the failure is
|
|
1187
1235
|
// swallowed and the record is still reported dead.
|
|
1188
|
-
const reapIfDead = (file) => xvfb.__awaiter(void 0, void 0, void 0, function* () {
|
|
1236
|
+
const reapIfDead = (file, record) => xvfb.__awaiter(void 0, void 0, void 0, function* () {
|
|
1189
1237
|
const { path, pid } = file;
|
|
1190
1238
|
if (isPidAlive(pid)) {
|
|
1191
1239
|
return false;
|
|
1192
1240
|
}
|
|
1241
|
+
// A starting record names no server to ask, so its pid check stands alone.
|
|
1242
|
+
if (record && !distExports.isStartingRecord(record) && (yield verifySessionRecord(record))) {
|
|
1243
|
+
return false;
|
|
1244
|
+
}
|
|
1193
1245
|
yield fs.remove(path).catch((err) => {
|
|
1194
1246
|
debug$7('failed to reap dead cypress sessions record %s: %o', path, err);
|
|
1195
1247
|
});
|
|
@@ -1206,16 +1258,33 @@ const readLiveSessions = () => xvfb.__awaiter(void 0, void 0, void 0, function*
|
|
|
1206
1258
|
if (!record) {
|
|
1207
1259
|
return null;
|
|
1208
1260
|
}
|
|
1209
|
-
if (yield reapIfDead(file)) {
|
|
1261
|
+
if (yield reapIfDead(file, record)) {
|
|
1210
1262
|
return null;
|
|
1211
1263
|
}
|
|
1212
1264
|
return record;
|
|
1213
1265
|
})));
|
|
1214
1266
|
return records.filter((record) => record !== null);
|
|
1215
1267
|
});
|
|
1268
|
+
/**
|
|
1269
|
+
* Reads the records of projects that could not load, whose writer process is still running.
|
|
1270
|
+
* They are not live sessions: they name no server.
|
|
1271
|
+
*/
|
|
1272
|
+
const readStartingSessions = () => xvfb.__awaiter(void 0, void 0, void 0, function* () {
|
|
1273
|
+
const files = yield listRecordFiles(getSessionsDir());
|
|
1274
|
+
const records = yield Promise.all(files.map((file) => xvfb.__awaiter(void 0, void 0, void 0, function* () {
|
|
1275
|
+
const record = yield readCompatibleRecord(file.path);
|
|
1276
|
+
if (!record || !distExports.isStartingRecord(record)) {
|
|
1277
|
+
return null;
|
|
1278
|
+
}
|
|
1279
|
+
return (yield reapIfDead(file, record)) ? null : record;
|
|
1280
|
+
})));
|
|
1281
|
+
return records.filter((record) => record !== null);
|
|
1282
|
+
});
|
|
1216
1283
|
const pruneDeadSessionRecords = () => xvfb.__awaiter(void 0, void 0, void 0, function* () {
|
|
1217
1284
|
const files = yield listRecordFiles(getSessionsDir());
|
|
1218
|
-
const pruned = yield Promise.all(files.map((file) =>
|
|
1285
|
+
const pruned = yield Promise.all(files.map((file) => xvfb.__awaiter(void 0, void 0, void 0, function* () {
|
|
1286
|
+
return reapIfDead(file, yield readCompatibleRecord(file.path));
|
|
1287
|
+
})));
|
|
1219
1288
|
const removed = pruned.filter(Boolean).length;
|
|
1220
1289
|
debug$7('pruned %d dead cypress sessions record(s)', removed);
|
|
1221
1290
|
return removed;
|
|
@@ -1454,13 +1523,27 @@ const processOpenOptions = (options = {}) => {
|
|
|
1454
1523
|
return args;
|
|
1455
1524
|
};
|
|
1456
1525
|
const start$3 = (...args_1) => xvfb.__awaiter(void 0, [...args_1], void 0, function* (options = {}) {
|
|
1526
|
+
// Some agent hosts export ELECTRON_RUN_AS_NODE, which would start the app as
|
|
1527
|
+
// plain Node with no window and no session. The smoke test that verifies the
|
|
1528
|
+
// binary needs the same environment, or it fails the same way.
|
|
1529
|
+
let env;
|
|
1530
|
+
// Electron treats the variable as set when it exists, even empty. Only Windows names are case-insensitive.
|
|
1531
|
+
const isRunAsNode = (key) => (os.platform() === 'win32' ? key.toUpperCase() : key) === 'ELECTRON_RUN_AS_NODE';
|
|
1532
|
+
if (!options.dev && Object.keys(process.env).some(isRunAsNode)) {
|
|
1533
|
+
xvfb.loggerModule.warn('ELECTRON_RUN_AS_NODE is set and was ignored because `cypress open` needs the app window.');
|
|
1534
|
+
env = _.omitBy(process.env, (_value, key) => isRunAsNode(key));
|
|
1535
|
+
}
|
|
1457
1536
|
function open() {
|
|
1458
1537
|
try {
|
|
1459
1538
|
const args = processOpenOptions(options);
|
|
1460
|
-
|
|
1539
|
+
const spawnOptions = {
|
|
1461
1540
|
dev: options.dev,
|
|
1462
1541
|
detached: Boolean(options.detached),
|
|
1463
|
-
}
|
|
1542
|
+
};
|
|
1543
|
+
if (env) {
|
|
1544
|
+
spawnOptions.env = env;
|
|
1545
|
+
}
|
|
1546
|
+
return spawn.start$1(args, spawnOptions);
|
|
1464
1547
|
}
|
|
1465
1548
|
catch (err) {
|
|
1466
1549
|
if (err.details) {
|
|
@@ -1472,7 +1555,7 @@ const start$3 = (...args_1) => xvfb.__awaiter(void 0, [...args_1], void 0, funct
|
|
|
1472
1555
|
if (options.dev) {
|
|
1473
1556
|
return open();
|
|
1474
1557
|
}
|
|
1475
|
-
yield spawn.start();
|
|
1558
|
+
yield spawn.start({ env });
|
|
1476
1559
|
return open();
|
|
1477
1560
|
});
|
|
1478
1561
|
var openModule = {
|
|
@@ -1648,6 +1731,29 @@ const runModule = {
|
|
|
1648
1731
|
const debug$4 = Debug('cypress:cli');
|
|
1649
1732
|
const defaultBaseUrl = 'https://download.cypress.io/';
|
|
1650
1733
|
const defaultMaxRedirects = 10;
|
|
1734
|
+
const maxDownloadAttempts = 3;
|
|
1735
|
+
const defaultRetryDelayMs = 1000;
|
|
1736
|
+
// How long the connection or the transfer can go quiet, so a network that drops packets fails and is retried instead of waiting for the operating system to give up
|
|
1737
|
+
const defaultTimeoutMs = 60000;
|
|
1738
|
+
const retryableErrorCodes = new Set([
|
|
1739
|
+
'ECONNRESET',
|
|
1740
|
+
'ETIMEDOUT',
|
|
1741
|
+
'ECONNREFUSED',
|
|
1742
|
+
'EAI_AGAIN',
|
|
1743
|
+
'EPIPE',
|
|
1744
|
+
'ESOCKETTIMEDOUT',
|
|
1745
|
+
]);
|
|
1746
|
+
const isRetryableDownloadError = (err) => {
|
|
1747
|
+
if (err === null || err === void 0 ? void 0 : err.statusCode) {
|
|
1748
|
+
return err.statusCode === 408 || err.statusCode === 429 || err.statusCode >= 500;
|
|
1749
|
+
}
|
|
1750
|
+
return retryableErrorCodes.has(err === null || err === void 0 ? void 0 : err.code);
|
|
1751
|
+
};
|
|
1752
|
+
// Jitter keeps concurrent installs from retrying in lockstep
|
|
1753
|
+
const getRetryDelay = (attempt, baseDelayMs) => {
|
|
1754
|
+
const backoff = baseDelayMs * 2 ** (attempt - 1);
|
|
1755
|
+
return Math.round(backoff * (0.5 + Math.random() / 2));
|
|
1756
|
+
};
|
|
1651
1757
|
const getProxyForUrlWithNpmConfig = (url) => {
|
|
1652
1758
|
return proxyFromEnv.getProxyForUrl(url) ||
|
|
1653
1759
|
process.env.npm_config_https_proxy ||
|
|
@@ -1784,7 +1890,7 @@ const verifyDownloadedFile = (filename, expectedSize, expectedChecksum) => xvfb.
|
|
|
1784
1890
|
// downloads from given url
|
|
1785
1891
|
// return an object with
|
|
1786
1892
|
// {filename: ..., downloaded: true}
|
|
1787
|
-
const downloadFromUrl = ({ url, downloadDestination, progress, ca, version, redirectTTL = defaultMaxRedirects }) => {
|
|
1893
|
+
const downloadFromUrl = ({ url, downloadDestination, progress, ca, version, redirectTTL = defaultMaxRedirects, timeoutMs = defaultTimeoutMs }) => {
|
|
1788
1894
|
if (redirectTTL <= 0) {
|
|
1789
1895
|
return Promise.reject(new Error(commonTags.stripIndent `
|
|
1790
1896
|
Failed downloading the Cypress binary.
|
|
@@ -1802,10 +1908,19 @@ const downloadFromUrl = ({ url, downloadDestination, progress, ca, version, redi
|
|
|
1802
1908
|
if (ca) {
|
|
1803
1909
|
debug$4('using custom CA details from npm config');
|
|
1804
1910
|
}
|
|
1805
|
-
const reqOptions = Object.assign(Object.assign(Object.assign({ uri: url }, (proxy ? { proxy } : {})), (ca ? { agentOptions: { ca } } : {})), { method: 'GET', followRedirect: false });
|
|
1911
|
+
const reqOptions = Object.assign(Object.assign(Object.assign({ uri: url }, (proxy ? { proxy } : {})), (ca ? { agentOptions: { ca } } : {})), { method: 'GET', followRedirect: false, timeout: timeoutMs });
|
|
1806
1912
|
const req = request(reqOptions);
|
|
1807
1913
|
// closure
|
|
1808
1914
|
let started = null;
|
|
1915
|
+
let bodyComplete = false;
|
|
1916
|
+
let redirected = false;
|
|
1917
|
+
let writeFailed = false;
|
|
1918
|
+
let fileStream;
|
|
1919
|
+
// A failed attempt closes the file it was writing, so a retry does not leave it open behind it
|
|
1920
|
+
const fail = (err) => {
|
|
1921
|
+
fileStream === null || fileStream === void 0 ? void 0 : fileStream.destroy();
|
|
1922
|
+
reject(err);
|
|
1923
|
+
};
|
|
1809
1924
|
let expectedSize;
|
|
1810
1925
|
let expectedChecksum;
|
|
1811
1926
|
requestProgress(req, {
|
|
@@ -1835,7 +1950,8 @@ const downloadFromUrl = ({ url, downloadDestination, progress, ca, version, redi
|
|
|
1835
1950
|
const redirectUrl = response.headers.location;
|
|
1836
1951
|
debug$4('redirect version:', redirectVersion);
|
|
1837
1952
|
debug$4('redirect url:', redirectUrl);
|
|
1838
|
-
|
|
1953
|
+
redirected = true;
|
|
1954
|
+
downloadFromUrl({ url: redirectUrl, progress, ca, downloadDestination, version: redirectVersion, redirectTTL: redirectTTL - 1, timeoutMs })
|
|
1839
1955
|
.then(resolve).catch(reject);
|
|
1840
1956
|
// if our status code does not start with 200
|
|
1841
1957
|
}
|
|
@@ -1846,18 +1962,42 @@ const downloadFromUrl = ({ url, downloadDestination, progress, ca, version, redi
|
|
|
1846
1962
|
Response code: ${response.statusCode}
|
|
1847
1963
|
Response message: ${response.statusMessage}
|
|
1848
1964
|
`);
|
|
1849
|
-
|
|
1965
|
+
err.statusCode = response.statusCode;
|
|
1966
|
+
err.statusMessage = response.statusMessage;
|
|
1967
|
+
fail(err);
|
|
1850
1968
|
// status codes here are all 2xx
|
|
1851
1969
|
}
|
|
1852
1970
|
else {
|
|
1971
|
+
const writeStream = fs.createWriteStream(downloadDestination);
|
|
1972
|
+
fileStream = writeStream;
|
|
1973
|
+
// An unhandled 'error' event would crash the CLI. A failed write, such as on a
|
|
1974
|
+
// full disk, leaves a truncated file that would keep holding that disk space.
|
|
1975
|
+
writeStream.on('error', (err) => {
|
|
1976
|
+
debug$4('failed writing %s: %s', downloadDestination, err.message);
|
|
1977
|
+
writeFailed = true;
|
|
1978
|
+
response.destroy();
|
|
1979
|
+
writeStream.once('close', () => {
|
|
1980
|
+
fs.remove(downloadDestination)
|
|
1981
|
+
.catch((removeErr) => debug$4('failed removing %s: %s', downloadDestination, removeErr.message))
|
|
1982
|
+
.finally(() => reject(err));
|
|
1983
|
+
});
|
|
1984
|
+
});
|
|
1853
1985
|
// We only enable this pipe connection when we know we've got a successful return
|
|
1854
1986
|
// and handle the completion with verify and resolve
|
|
1855
1987
|
// there was a possible race condition between end of request and close of writeStream
|
|
1856
1988
|
// that is made ordered with this Promise.all
|
|
1989
|
+
response.on('end', () => {
|
|
1990
|
+
bodyComplete = true;
|
|
1991
|
+
});
|
|
1857
1992
|
Bluebird.all([new Bluebird((r) => {
|
|
1858
|
-
return response.pipe(
|
|
1993
|
+
return response.pipe(writeStream.on('close', r));
|
|
1859
1994
|
}), new Bluebird((r) => response.on('end', r))])
|
|
1860
1995
|
.then(() => {
|
|
1996
|
+
// The error handler is deleting the partial file and rejects with the
|
|
1997
|
+
// write error, so verifying the file here would race that deletion.
|
|
1998
|
+
if (writeFailed) {
|
|
1999
|
+
return;
|
|
2000
|
+
}
|
|
1861
2001
|
debug$4('downloading finished');
|
|
1862
2002
|
verifyDownloadedFile(downloadDestination, expectedSize, expectedChecksum)
|
|
1863
2003
|
.then(() => debug$4('verified'))
|
|
@@ -1867,9 +2007,15 @@ const downloadFromUrl = ({ url, downloadDestination, progress, ca, version, redi
|
|
|
1867
2007
|
}
|
|
1868
2008
|
})
|
|
1869
2009
|
.on('error', (e) => {
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
2010
|
+
// The connection can reset after the whole file arrived. The file is complete, and
|
|
2011
|
+
// verifying it decides the outcome, so downloading it all again would be wasted.
|
|
2012
|
+
// A failed write stops the response itself, and the connection error that causes
|
|
2013
|
+
// must not turn the write error into a retry.
|
|
2014
|
+
if (bodyComplete || redirected || writeFailed) {
|
|
2015
|
+
debug$4('ignoring error after the download completed or moved on: %s', e.message);
|
|
2016
|
+
return;
|
|
2017
|
+
}
|
|
2018
|
+
fail(e);
|
|
1873
2019
|
})
|
|
1874
2020
|
.on('progress', (state) => {
|
|
1875
2021
|
// total time we've elapsed
|
|
@@ -1889,7 +2035,8 @@ const downloadFromUrl = ({ url, downloadDestination, progress, ca, version, redi
|
|
|
1889
2035
|
* @param [string] downloadDestination Local filename to save as
|
|
1890
2036
|
*/
|
|
1891
2037
|
const start$2 = (opts) => xvfb.__awaiter(void 0, void 0, void 0, function* () {
|
|
1892
|
-
|
|
2038
|
+
const { version, downloadDestination, redirectTTL, retryDelayMs = defaultRetryDelayMs, timeoutMs = defaultTimeoutMs } = opts;
|
|
2039
|
+
let { progress } = opts;
|
|
1893
2040
|
if (!downloadDestination) {
|
|
1894
2041
|
assert.ok(_.isString(downloadDestination) && !_.isEmpty(downloadDestination), 'missing download dir');
|
|
1895
2042
|
}
|
|
@@ -1900,7 +2047,7 @@ const start$2 = (opts) => xvfb.__awaiter(void 0, void 0, void 0, function* () {
|
|
|
1900
2047
|
}
|
|
1901
2048
|
const arch = yield xvfb.util.getRealArch();
|
|
1902
2049
|
const versionUrl = getUrl(arch, version);
|
|
1903
|
-
progress.throttle =
|
|
2050
|
+
progress.throttle = xvfb.util.progressThrottleMs;
|
|
1904
2051
|
debug$4('needed Cypress version: %s', version);
|
|
1905
2052
|
debug$4('source url %s', versionUrl);
|
|
1906
2053
|
debug$4(`downloading cypress.zip to "${downloadDestination}"`);
|
|
@@ -1908,7 +2055,21 @@ const start$2 = (opts) => xvfb.__awaiter(void 0, void 0, void 0, function* () {
|
|
|
1908
2055
|
// ensure download dir exists
|
|
1909
2056
|
yield fs.ensureDir(path.dirname(downloadDestination));
|
|
1910
2057
|
const ca = yield getCA();
|
|
1911
|
-
|
|
2058
|
+
for (let attempt = 1;; attempt++) {
|
|
2059
|
+
try {
|
|
2060
|
+
return yield downloadFromUrl(Object.assign({ url: versionUrl, downloadDestination, progress, ca, version,
|
|
2061
|
+
timeoutMs }, (redirectTTL ? { redirectTTL } : {})));
|
|
2062
|
+
}
|
|
2063
|
+
catch (err) {
|
|
2064
|
+
if (attempt >= maxDownloadAttempts || !isRetryableDownloadError(err)) {
|
|
2065
|
+
throw err;
|
|
2066
|
+
}
|
|
2067
|
+
const delay = getRetryDelay(attempt, retryDelayMs);
|
|
2068
|
+
debug$4('download attempt %d of %d failed (%s), retrying in %dms', attempt, maxDownloadAttempts, err.code || err.statusCode, delay);
|
|
2069
|
+
progress.onProgress(0, 0);
|
|
2070
|
+
yield Bluebird.delay(delay);
|
|
2071
|
+
}
|
|
2072
|
+
}
|
|
1912
2073
|
}
|
|
1913
2074
|
catch (err) {
|
|
1914
2075
|
return prettyDownloadErr(err, versionUrl);
|
|
@@ -2094,22 +2255,37 @@ const unzip = (_a) => xvfb.__awaiter(void 0, [_a], void 0, function* ({ zipFileP
|
|
|
2094
2255
|
debug$3('zipFile entries count', total);
|
|
2095
2256
|
// Close the count-only handle — the Node fallback re-opens the zip for extraction.
|
|
2096
2257
|
zipFile.close();
|
|
2097
|
-
|
|
2258
|
+
let started = Date.now();
|
|
2098
2259
|
let percent = 0;
|
|
2099
2260
|
let count = 0;
|
|
2261
|
+
let lastNotifiedPercent;
|
|
2262
|
+
let lastNotifiedAt = 0;
|
|
2100
2263
|
const notify = (percent) => {
|
|
2101
|
-
const
|
|
2102
|
-
|
|
2264
|
+
const now = Date.now();
|
|
2265
|
+
lastNotifiedPercent = percent;
|
|
2266
|
+
lastNotifiedAt = now;
|
|
2267
|
+
const eta = xvfb.util.calculateEta(percent, now - started);
|
|
2103
2268
|
progress.onProgress(percent, xvfb.util.secsRemaining(eta));
|
|
2104
2269
|
};
|
|
2270
|
+
// Extractors tick for every entry or chunk of tool output, far more
|
|
2271
|
+
// often than the shown percent changes.
|
|
2105
2272
|
const tick = () => {
|
|
2106
2273
|
count += 1;
|
|
2107
2274
|
percent = ((count / total) * 100);
|
|
2108
|
-
const displayPercent =
|
|
2109
|
-
|
|
2275
|
+
const displayPercent = Math.round(percent);
|
|
2276
|
+
if (displayPercent === lastNotifiedPercent && Date.now() - lastNotifiedAt < xvfb.util.progressThrottleMs) {
|
|
2277
|
+
return;
|
|
2278
|
+
}
|
|
2279
|
+
return notify(displayPercent);
|
|
2110
2280
|
};
|
|
2111
2281
|
const unzipWithNode = () => xvfb.__awaiter(void 0, void 0, void 0, function* () {
|
|
2112
2282
|
debug$3('unzipping with node.js (slow)');
|
|
2283
|
+
// When this is the fallback, the OS tool may already have ticked part
|
|
2284
|
+
// of the archive and used up time, but extraction starts over from the
|
|
2285
|
+
// first entry, so the progress and the ETA must too.
|
|
2286
|
+
count = 0;
|
|
2287
|
+
started = Date.now();
|
|
2288
|
+
lastNotifiedPercent = undefined;
|
|
2113
2289
|
try {
|
|
2114
2290
|
yield unzipTools.extractWithYauzl(zipFilePath, installDir, tick);
|
|
2115
2291
|
debug$3('node unzip finished');
|
|
@@ -2438,7 +2614,6 @@ function downloadArchive(version, downloadDestination) {
|
|
|
2438
2614
|
version,
|
|
2439
2615
|
downloadDestination,
|
|
2440
2616
|
progress: {
|
|
2441
|
-
throttle: 100,
|
|
2442
2617
|
onProgress: (percentComplete, remaining) => {
|
|
2443
2618
|
task.title = progressTitle(inProgressTitle, percentComplete, remaining);
|
|
2444
2619
|
},
|
|
@@ -2507,7 +2682,7 @@ var installModule = {
|
|
|
2507
2682
|
const debug$1 = Debug('cypress:cli');
|
|
2508
2683
|
const getBinaryDirectory = () => xvfb.__awaiter(void 0, void 0, void 0, function* () {
|
|
2509
2684
|
if (xvfb.util.getEnv('CYPRESS_RUN_BINARY')) {
|
|
2510
|
-
|
|
2685
|
+
const envBinaryPath = path.resolve(xvfb.util.getEnv('CYPRESS_RUN_BINARY'));
|
|
2511
2686
|
try {
|
|
2512
2687
|
const envBinaryDir = yield xvfb.stateModule.parseRealPlatformBinaryFolderAsync(envBinaryPath);
|
|
2513
2688
|
if (!envBinaryDir) {
|
|
@@ -2957,7 +3132,7 @@ const cliModule = {
|
|
|
2957
3132
|
}
|
|
2958
3133
|
if (xvfb.util.isNonProductionCypressInternalEnvValue(CYPRESS_INTERNAL_ENV)) {
|
|
2959
3134
|
debug('non-production CYPRESS_INTERNAL_ENV value', CYPRESS_INTERNAL_ENV);
|
|
2960
|
-
|
|
3135
|
+
const msg = `
|
|
2961
3136
|
${logSymbols.warning} Warning: It looks like you're passing CYPRESS_INTERNAL_ENV=${CYPRESS_INTERNAL_ENV}
|
|
2962
3137
|
|
|
2963
3138
|
The environment variable "CYPRESS_INTERNAL_ENV" is reserved and should only be used internally.
|
|
@@ -3088,7 +3263,7 @@ const cliModule = {
|
|
|
3088
3263
|
.action(function (opts, args) {
|
|
3089
3264
|
return xvfb.__awaiter(this, void 0, void 0, function* () {
|
|
3090
3265
|
try {
|
|
3091
|
-
const { default: tapModule } = yield Promise.resolve().then(function () { return require('./tap-
|
|
3266
|
+
const { default: tapModule } = yield Promise.resolve().then(function () { return require('./tap-BMFGLoCT.js'); });
|
|
3092
3267
|
const code = yield tapModule.start(args || [], _.pick(opts, ['session', 'json', 'timeout']));
|
|
3093
3268
|
process.exit(code);
|
|
3094
3269
|
}
|
|
@@ -3141,8 +3316,8 @@ const cliModule = {
|
|
|
3141
3316
|
exports.cliModule = cliModule;
|
|
3142
3317
|
exports.distExports = distExports;
|
|
3143
3318
|
exports.installModule = installModule;
|
|
3144
|
-
exports.isPidAlive = isPidAlive;
|
|
3145
3319
|
exports.openModule = openModule;
|
|
3146
3320
|
exports.readLiveSessions = readLiveSessions;
|
|
3321
|
+
exports.readStartingSessions = readStartingSessions;
|
|
3147
3322
|
exports.runModule = runModule;
|
|
3148
3323
|
exports.verifySessionRecord = verifySessionRecord;
|
package/dist/cli.js
CHANGED
|
@@ -2,15 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
require('./xvfb-
|
|
5
|
+
require('./xvfb-DxbcANVl.js');
|
|
6
6
|
require('lodash');
|
|
7
7
|
require('commander');
|
|
8
8
|
require('common-tags');
|
|
9
9
|
require('log-symbols');
|
|
10
10
|
require('debug');
|
|
11
|
-
var cli = require('./cli-
|
|
12
|
-
require('./spawn-
|
|
11
|
+
var cli = require('./cli-y9Bb9Y77.js');
|
|
12
|
+
require('./spawn-Bx99tBTm.js');
|
|
13
13
|
require('os');
|
|
14
|
+
require('path');
|
|
15
|
+
require('child_process');
|
|
16
|
+
require('fs-extra');
|
|
14
17
|
require('bluebird');
|
|
15
18
|
require('@cypress/xvfb');
|
|
16
19
|
require('chalk');
|
|
@@ -19,7 +22,6 @@ require('arch');
|
|
|
19
22
|
require('ospath');
|
|
20
23
|
require('hasha');
|
|
21
24
|
require('tty');
|
|
22
|
-
require('path');
|
|
23
25
|
require('ci-info');
|
|
24
26
|
require('execa');
|
|
25
27
|
require('systeminformation');
|
|
@@ -28,7 +30,6 @@ require('executable');
|
|
|
28
30
|
require('process');
|
|
29
31
|
require('supports-color');
|
|
30
32
|
require('is-installed-globally');
|
|
31
|
-
require('fs-extra');
|
|
32
33
|
require('fs');
|
|
33
34
|
require('untildify');
|
|
34
35
|
require('cli-table3');
|
|
@@ -40,7 +41,6 @@ require('fs/promises');
|
|
|
40
41
|
require('@cypress/request');
|
|
41
42
|
require('request-progress');
|
|
42
43
|
require('proxy-from-env');
|
|
43
|
-
require('child_process');
|
|
44
44
|
require('yauzl');
|
|
45
45
|
require('util');
|
|
46
46
|
require('stream');
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var xvfb = require('./xvfb-
|
|
3
|
+
var xvfb = require('./xvfb-DxbcANVl.js');
|
|
4
4
|
var tmp = require('tmp');
|
|
5
5
|
var fs = require('fs-extra');
|
|
6
|
-
var cli$1 = require('./cli-
|
|
6
|
+
var cli$1 = require('./cli-y9Bb9Y77.js');
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Opens Cypress GUI
|
package/dist/cypress.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('./xvfb-
|
|
3
|
+
require('./xvfb-DxbcANVl.js');
|
|
4
4
|
require('tmp');
|
|
5
5
|
require('fs-extra');
|
|
6
|
-
require('./cli-
|
|
7
|
-
var cypress = require('./cypress-
|
|
6
|
+
require('./cli-y9Bb9Y77.js');
|
|
7
|
+
var cypress = require('./cypress-CvEs5adm.js');
|
|
8
|
+
require('lodash');
|
|
8
9
|
require('os');
|
|
10
|
+
require('path');
|
|
11
|
+
require('child_process');
|
|
9
12
|
require('bluebird');
|
|
10
13
|
require('@cypress/xvfb');
|
|
11
14
|
require('common-tags');
|
|
12
15
|
require('debug');
|
|
13
16
|
require('chalk');
|
|
14
|
-
require('lodash');
|
|
15
17
|
require('assert');
|
|
16
18
|
require('arch');
|
|
17
19
|
require('ospath');
|
|
18
20
|
require('hasha');
|
|
19
21
|
require('tty');
|
|
20
|
-
require('path');
|
|
21
22
|
require('ci-info');
|
|
22
23
|
require('execa');
|
|
23
24
|
require('systeminformation');
|
|
@@ -33,12 +34,11 @@ require('commander');
|
|
|
33
34
|
require('cli-table3');
|
|
34
35
|
require('dayjs');
|
|
35
36
|
require('dayjs/plugin/relativeTime');
|
|
36
|
-
require('./spawn-
|
|
37
|
-
require('
|
|
37
|
+
require('./spawn-Bx99tBTm.js');
|
|
38
|
+
require('string_decoder');
|
|
38
39
|
require('listr2');
|
|
39
40
|
require('readline');
|
|
40
41
|
require('stream');
|
|
41
|
-
require('string_decoder');
|
|
42
42
|
require('node:string_decoder');
|
|
43
43
|
require('timers/promises');
|
|
44
44
|
require('fs/promises');
|
package/dist/exec/spawn.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
require('../xvfb-
|
|
3
|
+
require('../xvfb-DxbcANVl.js');
|
|
4
4
|
require('lodash');
|
|
5
5
|
require('os');
|
|
6
6
|
require('child_process');
|
|
7
7
|
require('path');
|
|
8
8
|
require('debug');
|
|
9
|
-
var spawn = require('../spawn-
|
|
9
|
+
var spawn = require('../spawn-Bx99tBTm.js');
|
|
10
10
|
require('readline');
|
|
11
11
|
require('process');
|
|
12
12
|
require('stream');
|
|
13
|
+
require('fs-extra');
|
|
13
14
|
require('bluebird');
|
|
14
15
|
require('@cypress/xvfb');
|
|
15
16
|
require('common-tags');
|
|
@@ -27,11 +28,10 @@ require('log-symbols');
|
|
|
27
28
|
require('executable');
|
|
28
29
|
require('supports-color');
|
|
29
30
|
require('is-installed-globally');
|
|
30
|
-
require('fs-extra');
|
|
31
31
|
require('fs');
|
|
32
32
|
require('untildify');
|
|
33
|
-
require('listr2');
|
|
34
33
|
require('string_decoder');
|
|
34
|
+
require('listr2');
|
|
35
35
|
require('node:string_decoder');
|
|
36
36
|
|
|
37
37
|
|