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,18 +1,20 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var _ = require('lodash');
|
|
3
4
|
var os = require('os');
|
|
5
|
+
var path = require('path');
|
|
6
|
+
var cp = require('child_process');
|
|
7
|
+
var fs$1 = require('fs-extra');
|
|
4
8
|
var Bluebird = require('bluebird');
|
|
5
9
|
var Xvfb = require('@cypress/xvfb');
|
|
6
10
|
var commonTags = require('common-tags');
|
|
7
11
|
var Debug = require('debug');
|
|
8
12
|
var chalk = require('chalk');
|
|
9
|
-
var _ = require('lodash');
|
|
10
13
|
var assert = require('assert');
|
|
11
14
|
var arch = require('arch');
|
|
12
15
|
var ospath = require('ospath');
|
|
13
16
|
var hasha = require('hasha');
|
|
14
17
|
var tty = require('tty');
|
|
15
|
-
var path = require('path');
|
|
16
18
|
var ciInfo = require('ci-info');
|
|
17
19
|
var execa = require('execa');
|
|
18
20
|
var si = require('systeminformation');
|
|
@@ -22,7 +24,6 @@ var executable = require('executable');
|
|
|
22
24
|
var process$1 = require('process');
|
|
23
25
|
var supportsColor = require('supports-color');
|
|
24
26
|
var isInstalledGlobally = require('is-installed-globally');
|
|
25
|
-
var fs$1 = require('fs-extra');
|
|
26
27
|
var fs = require('fs');
|
|
27
28
|
var untildify = require('untildify');
|
|
28
29
|
|
|
@@ -150,7 +151,9 @@ const getFileSize = (filename) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
150
151
|
const { size } = yield fs$1.stat(filename);
|
|
151
152
|
return size;
|
|
152
153
|
});
|
|
153
|
-
|
|
154
|
+
// When DISPLAY is set but nothing is listening on it, Electron prints either the Gtk
|
|
155
|
+
// message or the X server one, depending on its version.
|
|
156
|
+
const isBrokenGtkDisplayRe = /Gtk: cannot open display|Missing X server or \$DISPLAY/;
|
|
154
157
|
const stringify = (val) => {
|
|
155
158
|
return _.isObject(val) ? JSON.stringify(val) : val;
|
|
156
159
|
};
|
|
@@ -397,6 +400,10 @@ const util = {
|
|
|
397
400
|
args = _.compact(args);
|
|
398
401
|
return chalk.blue(...args);
|
|
399
402
|
},
|
|
403
|
+
// Download and unzip progress use this to limit how often they update.
|
|
404
|
+
// In an interactive terminal each update redraws the install task list,
|
|
405
|
+
// so updating for every chunk or entry slows the install down.
|
|
406
|
+
progressThrottleMs: 100,
|
|
400
407
|
calculateEta(percent, elapsed) {
|
|
401
408
|
// returns the number of seconds remaining
|
|
402
409
|
// if we're at 100% already just return 0
|
|
@@ -510,19 +517,19 @@ const util = {
|
|
|
510
517
|
const configVarNameLower = configVarName.toLowerCase();
|
|
511
518
|
const packageConfigVarName = `npm_package_config_${varName}`;
|
|
512
519
|
let result;
|
|
513
|
-
if (
|
|
520
|
+
if (Object.prototype.hasOwnProperty.call(process.env, varName)) {
|
|
514
521
|
debug$2(`Using ${varName} from environment variable`);
|
|
515
522
|
result = process.env[varName];
|
|
516
523
|
}
|
|
517
|
-
else if (
|
|
524
|
+
else if (Object.prototype.hasOwnProperty.call(process.env, configVarName)) {
|
|
518
525
|
debug$2(`Using ${varName} from npm config`);
|
|
519
526
|
result = process.env[configVarName];
|
|
520
527
|
}
|
|
521
|
-
else if (
|
|
528
|
+
else if (Object.prototype.hasOwnProperty.call(process.env, configVarNameLower)) {
|
|
522
529
|
debug$2(`Using ${varName.toLowerCase()} from npm config`);
|
|
523
530
|
result = process.env[configVarNameLower];
|
|
524
531
|
}
|
|
525
|
-
else if (
|
|
532
|
+
else if (Object.prototype.hasOwnProperty.call(process.env, packageConfigVarName)) {
|
|
526
533
|
debug$2(`Using ${varName} from package.json config`);
|
|
527
534
|
result = process.env[packageConfigVarName];
|
|
528
535
|
}
|
|
@@ -827,7 +834,11 @@ const nonZeroExitCodeXvfb = {
|
|
|
827
834
|
const missingXvfb = {
|
|
828
835
|
description: 'Your system is missing the dependency: Xvfb',
|
|
829
836
|
solution: commonTags.stripIndent `
|
|
830
|
-
Install Xvfb and run Cypress again.
|
|
837
|
+
Install Xvfb and run Cypress again. On Debian and Ubuntu:
|
|
838
|
+
|
|
839
|
+
${chalk.cyan('apt-get install -y xvfb')}
|
|
840
|
+
|
|
841
|
+
Or run Cypress on a display that already exists by setting the DISPLAY environment variable.
|
|
831
842
|
|
|
832
843
|
Read our documentation on dependencies for more information:
|
|
833
844
|
|
|
@@ -836,6 +847,22 @@ const missingXvfb = {
|
|
|
836
847
|
If you are using Docker, we provide containers with all required dependencies installed.
|
|
837
848
|
`,
|
|
838
849
|
};
|
|
850
|
+
const xvfbFailedToStart = (timeoutSeconds) => {
|
|
851
|
+
return {
|
|
852
|
+
description: 'Xvfb is installed but could not start.',
|
|
853
|
+
solution: commonTags.stripIndent `
|
|
854
|
+
Cypress could not start Xvfb, the virtual display it uses on Linux when DISPLAY is not set.
|
|
855
|
+
|
|
856
|
+
Common causes:
|
|
857
|
+
|
|
858
|
+
- The display number is already in use, for example by an Xvfb left running from an earlier run. Stop that Xvfb, or set the XVFB_DISPLAY_NUM environment variable to a free number.
|
|
859
|
+
- Xvfb did not create its display within ${timeoutSeconds} seconds.
|
|
860
|
+
- The Xvfb binary cannot be run by the user running Cypress, or that user cannot write to /tmp.
|
|
861
|
+
|
|
862
|
+
Run Cypress again with DEBUG=cypress:xvfb to see what Xvfb printed.
|
|
863
|
+
`,
|
|
864
|
+
};
|
|
865
|
+
};
|
|
839
866
|
const smokeTestFailure = (smokeTestCommand, timedOut) => {
|
|
840
867
|
return {
|
|
841
868
|
description: `Cypress verification ${timedOut ? 'timed out' : 'failed'}.`,
|
|
@@ -868,14 +895,63 @@ const invalidSmokeTestDisplayError = {
|
|
|
868
895
|
`;
|
|
869
896
|
},
|
|
870
897
|
};
|
|
898
|
+
// Where each library the dynamic linker names comes from on Debian and Ubuntu
|
|
899
|
+
const APT_PACKAGES = {
|
|
900
|
+
'libnss3.so': 'libnss3',
|
|
901
|
+
'libgtk-3.so.0': 'libgtk-3-0',
|
|
902
|
+
'libgbm.so.1': 'libgbm1',
|
|
903
|
+
// The package was renamed in Debian 13 and Ubuntu 24.04, so the line falls back to the old name
|
|
904
|
+
'libasound.so.2': 'libasound2t64 || apt-get install -y libasound2',
|
|
905
|
+
'libXss.so.1': 'libxss1',
|
|
906
|
+
'libXtst.so.6': 'libxtst6',
|
|
907
|
+
'libX11-xcb.so.1': 'libx11-xcb1',
|
|
908
|
+
'libxkbcommon.so.0': 'libxkbcommon0',
|
|
909
|
+
'libatk-1.0.so.0': 'libatk1.0-0',
|
|
910
|
+
'libatk-bridge-2.0.so.0': 'libatk-bridge2.0-0',
|
|
911
|
+
'libcups.so.2': 'libcups2',
|
|
912
|
+
'libdrm.so.2': 'libdrm2',
|
|
913
|
+
'libnspr4.so': 'libnspr4',
|
|
914
|
+
'libXcomposite.so.1': 'libxcomposite1',
|
|
915
|
+
'libXdamage.so.1': 'libxdamage1',
|
|
916
|
+
'libXrandr.so.2': 'libxrandr2',
|
|
917
|
+
'libcairo.so.2': 'libcairo2',
|
|
918
|
+
'libpango-1.0.so.0': 'libpango-1.0-0',
|
|
919
|
+
};
|
|
920
|
+
const parseMissingLibraries = (output = '') => {
|
|
921
|
+
const libraries = Array.from(output.matchAll(/error while loading shared libraries: ([^:\s]+):/g), (match) => match[1]);
|
|
922
|
+
return _.uniq(libraries);
|
|
923
|
+
};
|
|
924
|
+
const missingLibrariesSolution = (libraries) => {
|
|
925
|
+
const known = libraries.filter((library) => APT_PACKAGES[library]);
|
|
926
|
+
const unknown = libraries.filter((library) => !APT_PACKAGES[library]);
|
|
927
|
+
const lines = [
|
|
928
|
+
`Cypress could not start because the system ${libraries.length === 1 ? 'library' : 'libraries'} below could not be loaded:`,
|
|
929
|
+
'',
|
|
930
|
+
...libraries.map((library) => ` ${library}`),
|
|
931
|
+
];
|
|
932
|
+
if (known.length) {
|
|
933
|
+
lines.push('', 'On Debian and Ubuntu, install the packages that provide them:', '', ...known.map((library) => ` apt-get install -y ${APT_PACKAGES[library]}`));
|
|
934
|
+
}
|
|
935
|
+
if (unknown.length) {
|
|
936
|
+
lines.push('', 'Find the package that provides each of these with apt-file, or your distribution\'s equivalent:', '', ...unknown.map((library) => ` apt-file search ${library}`));
|
|
937
|
+
}
|
|
938
|
+
lines.push('', `More about the required dependencies: ${chalk.blue(requiredDependenciesUrl)}`);
|
|
939
|
+
return lines.join('\n');
|
|
940
|
+
};
|
|
871
941
|
const missingDependency = {
|
|
872
942
|
description: 'Cypress failed to start.',
|
|
873
|
-
//
|
|
874
|
-
solution:
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
943
|
+
// A function is given the error output, and when it is, it is responsible for printing it
|
|
944
|
+
solution: (msg) => {
|
|
945
|
+
const libraries = parseMissingLibraries(msg);
|
|
946
|
+
// this message is too Linux specific
|
|
947
|
+
const advice = libraries.length ? missingLibrariesSolution(libraries) : commonTags.stripIndent `
|
|
948
|
+
This may be due to a missing library or dependency. ${chalk.blue(requiredDependenciesUrl)}
|
|
949
|
+
`;
|
|
950
|
+
if (!msg) {
|
|
951
|
+
return advice;
|
|
952
|
+
}
|
|
953
|
+
return [advice, '', 'Please refer to the error below for more details.', '', hr, '', msg].join('\n');
|
|
954
|
+
},
|
|
879
955
|
};
|
|
880
956
|
const invalidCacheDirectory = {
|
|
881
957
|
description: 'Cypress cannot write to the cache directory due to file permissions',
|
|
@@ -1026,6 +1102,7 @@ const errors = {
|
|
|
1026
1102
|
unknownError,
|
|
1027
1103
|
nonZeroExitCodeXvfb,
|
|
1028
1104
|
missingXvfb,
|
|
1105
|
+
xvfbFailedToStart,
|
|
1029
1106
|
missingApp,
|
|
1030
1107
|
notInstalledCI,
|
|
1031
1108
|
missingDependency,
|
|
@@ -1052,9 +1129,10 @@ const errors = {
|
|
|
1052
1129
|
const debug = Debug('cypress:cli');
|
|
1053
1130
|
const debugXvfb = Debug('cypress:xvfb');
|
|
1054
1131
|
debug.Debug = debugXvfb.Debug = Debug;
|
|
1132
|
+
const XVFB_START_TIMEOUT_SECONDS = 30;
|
|
1055
1133
|
const xvfbOptions = {
|
|
1056
1134
|
displayNum: process.env.XVFB_DISPLAY_NUM,
|
|
1057
|
-
timeout:
|
|
1135
|
+
timeout: XVFB_START_TIMEOUT_SECONDS * 1000,
|
|
1058
1136
|
// need to explicitly define screen otherwise electron will crash
|
|
1059
1137
|
// https://github.com/cypress-io/cypress/issues/6184
|
|
1060
1138
|
xvfb_args: ['-screen', '0', '1280x1024x24'],
|
|
@@ -1064,15 +1142,140 @@ const xvfbOptions = {
|
|
|
1064
1142
|
}
|
|
1065
1143
|
},
|
|
1066
1144
|
};
|
|
1145
|
+
// Starts Xvfb in a session of its own with no pipes to the CLI, so an app that keeps running
|
|
1146
|
+
// after the CLI exits keeps its display when a host ends the CLI's process group or closes its
|
|
1147
|
+
// output. @cypress/xvfb offers no option for this, so only the spawn is replaced and the lock file
|
|
1148
|
+
// wait and timeout stay the library's.
|
|
1149
|
+
// Once the CLI has exited nothing is left to stop this Xvfb, so `-terminate` has it exit, and remove
|
|
1150
|
+
// its lock file, when its last client disconnects: when the app closes or crashes.
|
|
1151
|
+
// The library ships no usable types for the members the override reaches into
|
|
1152
|
+
const XvfbBase = Xvfb;
|
|
1153
|
+
// A file rather than a pipe: once the CLI exits, Xvfb's next write to a pipe would end it
|
|
1154
|
+
function openStderrFile() {
|
|
1155
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1156
|
+
const dir = yield fs$1.mkdtemp(path.join(os.tmpdir(), 'cypress-xvfb-'));
|
|
1157
|
+
const file = path.join(dir, 'stderr');
|
|
1158
|
+
try {
|
|
1159
|
+
return { dir, file, fd: yield fs$1.open(file, 'wx', 0o600) };
|
|
1160
|
+
}
|
|
1161
|
+
catch (err) {
|
|
1162
|
+
yield fs$1.remove(dir).catch(() => undefined);
|
|
1163
|
+
throw err;
|
|
1164
|
+
}
|
|
1165
|
+
});
|
|
1166
|
+
}
|
|
1167
|
+
class DetachedXvfb extends XvfbBase {
|
|
1168
|
+
// Without it the class takes no arguments as far as the type checker can tell
|
|
1169
|
+
constructor(options) {
|
|
1170
|
+
var _a;
|
|
1171
|
+
super(options);
|
|
1172
|
+
this._avoidDisplays = (_a = options.avoidDisplays) !== null && _a !== void 0 ? _a : [];
|
|
1173
|
+
}
|
|
1174
|
+
// Picks the first free display as the library does, but skips `avoidDisplays`, so a Xvfb left
|
|
1175
|
+
// running for the app does not hold a display that a later run in this process will use
|
|
1176
|
+
display() {
|
|
1177
|
+
if (!this._display) {
|
|
1178
|
+
let displayNum = 99;
|
|
1179
|
+
while (this._avoidDisplays.includes(displayNum) || fs$1.existsSync(this._lockFile(displayNum))) {
|
|
1180
|
+
displayNum++;
|
|
1181
|
+
}
|
|
1182
|
+
this._display = `:${displayNum}`;
|
|
1183
|
+
}
|
|
1184
|
+
return this._display;
|
|
1185
|
+
}
|
|
1186
|
+
// What Xvfb prints is only read when it fails to start, so it reaches DEBUG=cypress:xvfb and
|
|
1187
|
+
// the error as it does for an Xvfb started with pipes. Without a file for it, Xvfb still starts.
|
|
1188
|
+
start(cb) {
|
|
1189
|
+
openStderrFile().catch((err) => {
|
|
1190
|
+
debug('no file for the output of Xvfb, discarding it', err);
|
|
1191
|
+
}).then((stderrFile) => {
|
|
1192
|
+
this._stderrFile = stderrFile !== null && stderrFile !== void 0 ? stderrFile : undefined;
|
|
1193
|
+
super.start((err, proc) => __awaiter(this, void 0, void 0, function* () {
|
|
1194
|
+
yield this._drainStderr(err);
|
|
1195
|
+
cb === null || cb === void 0 ? void 0 : cb(err, proc);
|
|
1196
|
+
}));
|
|
1197
|
+
});
|
|
1198
|
+
}
|
|
1199
|
+
// Removing the file once Xvfb has started leaves it writing to a file nobody can open, so
|
|
1200
|
+
// nothing is left in the temp directory for an Xvfb that outlives the CLI
|
|
1201
|
+
_drainStderr(err) {
|
|
1202
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
1203
|
+
const stderrFile = this._stderrFile;
|
|
1204
|
+
if (!stderrFile) {
|
|
1205
|
+
return;
|
|
1206
|
+
}
|
|
1207
|
+
this._stderrFile = undefined;
|
|
1208
|
+
try {
|
|
1209
|
+
yield fs$1.close(stderrFile.fd);
|
|
1210
|
+
if (!err) {
|
|
1211
|
+
return;
|
|
1212
|
+
}
|
|
1213
|
+
const output = (yield fs$1.readFile(stderrFile.file, 'utf8')).trim();
|
|
1214
|
+
if (output) {
|
|
1215
|
+
this._onStderrData(output);
|
|
1216
|
+
if (err.nonZeroExitCode) {
|
|
1217
|
+
err.message = `${err.message}:\n${output}`;
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
catch (_a) {
|
|
1222
|
+
// Best effort: the start error is reported either way
|
|
1223
|
+
}
|
|
1224
|
+
finally {
|
|
1225
|
+
yield fs$1.remove(stderrFile.dir).catch(() => undefined);
|
|
1226
|
+
}
|
|
1227
|
+
});
|
|
1228
|
+
}
|
|
1229
|
+
_spawnProcess(lockFileExists, onAsyncSpawnError) {
|
|
1230
|
+
var _a, _b;
|
|
1231
|
+
// A process that cannot be spawned emits both 'error' and 'exit', and start reports only one
|
|
1232
|
+
const onError = _.once(onAsyncSpawnError);
|
|
1233
|
+
const display = this.display();
|
|
1234
|
+
if (lockFileExists) {
|
|
1235
|
+
if (!this._reuse) {
|
|
1236
|
+
throw new Error(`Display ${display} is already in use and the "reuse" option is false.`);
|
|
1237
|
+
}
|
|
1238
|
+
return;
|
|
1239
|
+
}
|
|
1240
|
+
const stderr = (_b = (_a = this._stderrFile) === null || _a === void 0 ? void 0 : _a.fd) !== null && _b !== void 0 ? _b : 'ignore';
|
|
1241
|
+
const proc = cp.spawn('Xvfb', [display, '-terminate', ...this._xvfb_args], { detached: true, stdio: ['ignore', 'ignore', stderr] });
|
|
1242
|
+
this._process = proc;
|
|
1243
|
+
proc.once('error', onError);
|
|
1244
|
+
proc.once('exit', (code, signal) => {
|
|
1245
|
+
if (code !== 0) {
|
|
1246
|
+
const err = new Error(code === null ? `Xvfb was killed by ${signal}` : `Xvfb exited with code ${code}`);
|
|
1247
|
+
err.nonZeroExitCode = true;
|
|
1248
|
+
onError(err);
|
|
1249
|
+
}
|
|
1250
|
+
});
|
|
1251
|
+
proc.unref();
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1067
1254
|
const xvfb = Bluebird.promisifyAll(new Xvfb(xvfbOptions));
|
|
1255
|
+
// The instance that was started, so `stop` ends that one. Each detached launch gets its own, since
|
|
1256
|
+
// the Xvfb a previous one left for its app may still hold its display.
|
|
1257
|
+
let running = xvfb;
|
|
1068
1258
|
const _debugXvfb = debugXvfb;
|
|
1069
1259
|
const _xvfb = xvfb;
|
|
1070
1260
|
const _xvfbOptions = xvfbOptions;
|
|
1261
|
+
// The Xvfb started for a detached app keeps its display for as long as the app runs, so it leaves
|
|
1262
|
+
// XVFB_DISPLAY_NUM, and the display the Xvfb that stops with the CLI has already picked, to that one
|
|
1263
|
+
function createDetachedXvfb() {
|
|
1264
|
+
var _a;
|
|
1265
|
+
if (xvfbOptions.displayNum) {
|
|
1266
|
+
loggerModule.warn('XVFB_DISPLAY_NUM is set and was ignored because a detached Cypress app keeps its display running after Cypress returns.');
|
|
1267
|
+
}
|
|
1268
|
+
const avoidDisplays = [xvfbOptions.displayNum, (_a = xvfb._display) === null || _a === void 0 ? void 0 : _a.slice(1)]
|
|
1269
|
+
.filter(Boolean)
|
|
1270
|
+
.map(Number);
|
|
1271
|
+
return new DetachedXvfb(Object.assign(Object.assign({}, _.omit(xvfbOptions, 'displayNum')), { avoidDisplays }));
|
|
1272
|
+
}
|
|
1071
1273
|
function start() {
|
|
1072
|
-
return __awaiter(this,
|
|
1073
|
-
debug('Starting Xvfb');
|
|
1274
|
+
return __awaiter(this, arguments, void 0, function* ({ detached = false } = {}) {
|
|
1275
|
+
debug('Starting Xvfb', { detached });
|
|
1276
|
+
running = detached ? Bluebird.promisifyAll(createDetachedXvfb()) : xvfb;
|
|
1074
1277
|
try {
|
|
1075
|
-
yield
|
|
1278
|
+
yield running.startAsync();
|
|
1076
1279
|
return null;
|
|
1077
1280
|
}
|
|
1078
1281
|
catch (e) {
|
|
@@ -1083,7 +1286,8 @@ function start() {
|
|
|
1083
1286
|
if (e.known) {
|
|
1084
1287
|
throw e;
|
|
1085
1288
|
}
|
|
1086
|
-
|
|
1289
|
+
// Only a binary that is not there is a missing dependency
|
|
1290
|
+
const raiseErrorFn = throwFormErrorText(e.code === 'ENOENT' ? errors.missingXvfb : errors.xvfbFailedToStart(XVFB_START_TIMEOUT_SECONDS));
|
|
1087
1291
|
yield raiseErrorFn(e);
|
|
1088
1292
|
}
|
|
1089
1293
|
});
|
|
@@ -1092,7 +1296,7 @@ function stop() {
|
|
|
1092
1296
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1093
1297
|
debug('Stopping Xvfb');
|
|
1094
1298
|
try {
|
|
1095
|
-
yield
|
|
1299
|
+
yield running.stopAsync();
|
|
1096
1300
|
return null;
|
|
1097
1301
|
}
|
|
1098
1302
|
catch (e) {
|
|
@@ -1100,18 +1304,24 @@ function stop() {
|
|
|
1100
1304
|
}
|
|
1101
1305
|
});
|
|
1102
1306
|
}
|
|
1103
|
-
|
|
1104
|
-
|
|
1307
|
+
// Leaves a detached Xvfb running for the app it was started for. The CLI gets its own DISPLAY back
|
|
1308
|
+
// and forgets that Xvfb, so a later launch from the same process neither uses nor stops it.
|
|
1309
|
+
function release() {
|
|
1310
|
+
running._restoreDisplayEnvVariable();
|
|
1311
|
+
running = xvfb;
|
|
1312
|
+
}
|
|
1313
|
+
function isNeeded(env = process.env) {
|
|
1314
|
+
if (env.ELECTRON_RUN_AS_NODE) {
|
|
1105
1315
|
debug('Environment variable ELECTRON_RUN_AS_NODE detected, xvfb is not needed');
|
|
1106
1316
|
return false; // xvfb required for electron processes only.
|
|
1107
1317
|
}
|
|
1108
1318
|
if (os.platform() !== 'linux') {
|
|
1109
1319
|
return false;
|
|
1110
1320
|
}
|
|
1111
|
-
if (
|
|
1321
|
+
if (env.DISPLAY) {
|
|
1112
1322
|
const issueUrl = util.getGitHubIssueUrl(4034);
|
|
1113
1323
|
const message = commonTags.stripIndent `
|
|
1114
|
-
DISPLAY environment variable is set to ${
|
|
1324
|
+
DISPLAY environment variable is set to ${env.DISPLAY} on Linux
|
|
1115
1325
|
Assuming this DISPLAY points at working X11 server,
|
|
1116
1326
|
Cypress will not spawn own Xvfb
|
|
1117
1327
|
|
|
@@ -1149,11 +1359,13 @@ var xvfb$1 = {
|
|
|
1149
1359
|
_xvfbOptions,
|
|
1150
1360
|
start,
|
|
1151
1361
|
stop,
|
|
1362
|
+
release,
|
|
1152
1363
|
isNeeded,
|
|
1153
1364
|
verify,
|
|
1154
1365
|
};
|
|
1155
1366
|
|
|
1156
1367
|
exports.DEVELOPMENT_VERSION = DEVELOPMENT_VERSION;
|
|
1368
|
+
exports.DetachedXvfb = DetachedXvfb;
|
|
1157
1369
|
exports.__awaiter = __awaiter;
|
|
1158
1370
|
exports._debugXvfb = _debugXvfb;
|
|
1159
1371
|
exports._xvfb = _xvfb;
|
|
@@ -1165,6 +1377,7 @@ exports.isNeeded = isNeeded;
|
|
|
1165
1377
|
exports.loggerModule = loggerModule;
|
|
1166
1378
|
exports.posixify = posixify;
|
|
1167
1379
|
exports.relativeToRepoRoot = relativeToRepoRoot;
|
|
1380
|
+
exports.release = release;
|
|
1168
1381
|
exports.start = start;
|
|
1169
1382
|
exports.stateModule = stateModule;
|
|
1170
1383
|
exports.stop = stop;
|
|
@@ -15,6 +15,7 @@ export const getContainerEl = () => {
|
|
|
15
15
|
* Utility function to register CT side effects and run cleanup code during the "test:before:run" Cypress hook
|
|
16
16
|
* @param optionalCallback Callback to be called before the next test runs
|
|
17
17
|
*/
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type -- published API; narrowing the parameter would break callers that pass a `Function`
|
|
18
19
|
export function setupHooks(optionalCallback) {
|
|
19
20
|
// We don't want CT side effects to run when e2e
|
|
20
21
|
// testing so we early return.
|
|
@@ -34,7 +35,6 @@ export function setupHooks(optionalCallback) {
|
|
|
34
35
|
Cypress.Commands.overwrite('origin', () => {
|
|
35
36
|
throw new Error('cy.origin from a component spec is not allowed');
|
|
36
37
|
});
|
|
37
|
-
// @ts-ignore
|
|
38
38
|
Cypress.on('test:before:after:run:async', () => {
|
|
39
39
|
optionalCallback?.();
|
|
40
40
|
});
|
package/mount-utils/package.json
CHANGED
|
@@ -2,7 +2,18 @@
|
|
|
2
2
|
"name": "@cypress/mount-utils",
|
|
3
3
|
"version": "0.0.0-development",
|
|
4
4
|
"description": "Shared utilities for the various component testing adapters",
|
|
5
|
+
"homepage": "https://github.com/cypress-io/cypress/tree/develop/npm/mount-utils#readme",
|
|
6
|
+
"bugs": "https://github.com/cypress-io/cypress/issues/new?template=1-bug-report.md",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/cypress-io/cypress.git"
|
|
10
|
+
},
|
|
11
|
+
"license": "MIT",
|
|
5
12
|
"main": "dist/index.js",
|
|
13
|
+
"types": "dist/index.d.ts",
|
|
14
|
+
"files": [
|
|
15
|
+
"dist"
|
|
16
|
+
],
|
|
6
17
|
"scripts": {
|
|
7
18
|
"build": "tsc || echo 'built, with type errors'",
|
|
8
19
|
"postbuild": "node ../../scripts/sync-exported-npm-with-cli.js",
|
|
@@ -10,32 +21,22 @@
|
|
|
10
21
|
"lint": "eslint",
|
|
11
22
|
"watch": "tsc -w"
|
|
12
23
|
},
|
|
24
|
+
"lint-staged": {
|
|
25
|
+
"**/*.{js,jsx,ts,tsx,json}": "eslint --fix"
|
|
26
|
+
},
|
|
13
27
|
"dependencies": {},
|
|
14
28
|
"devDependencies": {
|
|
15
29
|
"@packages/eslint-config": "0.0.0-development",
|
|
16
30
|
"@rollup/plugin-commonjs": "^29.0.2",
|
|
17
31
|
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
18
32
|
"eslint": "^9.31.0",
|
|
33
|
+
"jiti": "^2.4.2",
|
|
19
34
|
"lodash": "^4.17.21",
|
|
20
35
|
"rollup": "4.60.2",
|
|
21
36
|
"rollup-plugin-dts": "6.4.1",
|
|
22
37
|
"rollup-plugin-typescript2": "^0.37.0",
|
|
23
38
|
"typescript": "~5.4.5"
|
|
24
39
|
},
|
|
25
|
-
"files": [
|
|
26
|
-
"dist"
|
|
27
|
-
],
|
|
28
|
-
"types": "dist/index.d.ts",
|
|
29
|
-
"license": "MIT",
|
|
30
|
-
"repository": {
|
|
31
|
-
"type": "git",
|
|
32
|
-
"url": "https://github.com/cypress-io/cypress.git"
|
|
33
|
-
},
|
|
34
|
-
"homepage": "https://github.com/cypress-io/cypress/tree/develop/npm/mount-utils#readme",
|
|
35
|
-
"bugs": "https://github.com/cypress-io/cypress/issues/new?template=1-bug-report.md",
|
|
36
|
-
"lint-staged": {
|
|
37
|
-
"**/*.{js,jsx,ts,tsx,json}": "eslint --fix"
|
|
38
|
-
},
|
|
39
40
|
"publishConfig": {
|
|
40
41
|
"access": "public"
|
|
41
42
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cypress",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.3.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"postinstall": "node dist/index.js --exec install",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"proxy-from-env": "1.0.0",
|
|
42
42
|
"request-progress": "^3.0.0",
|
|
43
43
|
"supports-color": "^8.1.1",
|
|
44
|
-
"systeminformation": "^5.
|
|
44
|
+
"systeminformation": "^5.33.16",
|
|
45
45
|
"tmp": "~0.2.4",
|
|
46
46
|
"tree-kill": "1.2.2",
|
|
47
47
|
"untildify": "^4.0.0",
|
|
@@ -132,8 +132,8 @@
|
|
|
132
132
|
},
|
|
133
133
|
"buildInfo": {
|
|
134
134
|
"commitBranch": "develop",
|
|
135
|
-
"commitSha": "
|
|
136
|
-
"commitDate": "2026-
|
|
135
|
+
"commitSha": "e5b073de605c59a31cf6d9a6fb6576b82a0bfb7d",
|
|
136
|
+
"commitDate": "2026-11-10T17:04:56.000Z",
|
|
137
137
|
"stable": true
|
|
138
138
|
},
|
|
139
139
|
"description": "Cypress is a next generation front end testing tool built for the modern web",
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
},
|
|
145
145
|
"repository": {
|
|
146
146
|
"type": "git",
|
|
147
|
-
"url": "https://github.com/cypress-io/cypress.git"
|
|
147
|
+
"url": "git+https://github.com/cypress-io/cypress.git"
|
|
148
148
|
},
|
|
149
149
|
"keywords": [
|
|
150
150
|
"automation",
|
|
@@ -83,6 +83,7 @@ const getContainerEl = () => {
|
|
|
83
83
|
* Utility function to register CT side effects and run cleanup code during the "test:before:run" Cypress hook
|
|
84
84
|
* @param optionalCallback Callback to be called before the next test runs
|
|
85
85
|
*/
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type -- published API; narrowing the parameter would break callers that pass a `Function`
|
|
86
87
|
function setupHooks(optionalCallback) {
|
|
87
88
|
// We don't want CT side effects to run when e2e
|
|
88
89
|
// testing so we early return.
|
|
@@ -102,7 +103,6 @@ function setupHooks(optionalCallback) {
|
|
|
102
103
|
Cypress.Commands.overwrite('origin', () => {
|
|
103
104
|
throw new Error('cy.origin from a component spec is not allowed');
|
|
104
105
|
});
|
|
105
|
-
// @ts-ignore
|
|
106
106
|
Cypress.on('test:before:after:run:async', () => {
|
|
107
107
|
optionalCallback?.();
|
|
108
108
|
});
|
|
@@ -134,7 +134,7 @@ const makeMountFn = (type, jsx, options = {}, rerenderKey, internalMountOptions)
|
|
|
134
134
|
].join(' '));
|
|
135
135
|
}
|
|
136
136
|
const key = rerenderKey !== null && rerenderKey !== void 0 ? rerenderKey :
|
|
137
|
-
// @ts-
|
|
137
|
+
// @ts-expect-error - `mocha` is not in the public Cypress types. Provide unique key to the wrapped component to make sure we are rerendering between tests
|
|
138
138
|
(((_c = (_b = (_a = Cypress === null || Cypress === void 0 ? void 0 : Cypress.mocha) === null || _a === void 0 ? void 0 : _a.getRunner()) === null || _b === void 0 ? void 0 : _b.test) === null || _c === void 0 ? void 0 : _c.title) || '') + Math.random();
|
|
139
139
|
const props = {
|
|
140
140
|
key,
|
|
@@ -144,7 +144,9 @@ const makeMountFn = (type, jsx, options = {}, rerenderKey, internalMountOptions)
|
|
|
144
144
|
// let's get back the original component
|
|
145
145
|
const userComponent = reactComponent.props.children;
|
|
146
146
|
internalMountOptions.render(reactComponent, el, reactDomToUse);
|
|
147
|
-
return (
|
|
147
|
+
return (
|
|
148
|
+
// eslint-disable-next-line cypress/no-unnecessary-waiting -- the chained zero-length wait is the event-loop tick described below
|
|
149
|
+
cy.wrap(userComponent, { log: false })
|
|
148
150
|
.then(() => {
|
|
149
151
|
return cy.wrap({
|
|
150
152
|
component: userComponent,
|
|
@@ -158,18 +160,18 @@ const makeMountFn = (type, jsx, options = {}, rerenderKey, internalMountOptions)
|
|
|
158
160
|
.then(() => {
|
|
159
161
|
if (options.log !== false) {
|
|
160
162
|
// Get the display name property via the component constructor
|
|
161
|
-
// @ts-ignore FIXME
|
|
162
163
|
const componentName = getDisplayName(jsx);
|
|
163
164
|
const jsxComponentName = `<${componentName} ... />`;
|
|
164
165
|
Cypress.log({
|
|
165
166
|
name: type,
|
|
166
167
|
type: 'parent',
|
|
167
168
|
message: [jsxComponentName],
|
|
168
|
-
// @ts-
|
|
169
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- @ts-expect-error would be unused once the cli typedefs are generated
|
|
170
|
+
// @ts-ignore - JQuery comes from cli/types/jquery, which is generated by the cli build and missing when this package builds first
|
|
169
171
|
$el: el.children.item(0),
|
|
170
172
|
consoleProps: () => {
|
|
171
173
|
return {
|
|
172
|
-
// @ts-
|
|
174
|
+
// @ts-expect-error - `props` is not on every `ReactNode` member, such as string
|
|
173
175
|
props: jsx === null || jsx === void 0 ? void 0 : jsx.props,
|
|
174
176
|
description: type === 'mount' ? 'Mounts React component' : 'Rerenders mounted React component',
|
|
175
177
|
home: 'https://github.com/cypress-io/cypress',
|
|
@@ -232,7 +234,7 @@ const createMount = (defaultOptions) => {
|
|
|
232
234
|
// Note: This would be a breaking change
|
|
233
235
|
// it is required to unmount component in beforeEach hook in order to provide a clean state inside test
|
|
234
236
|
// because `mount` can be called after some preparation that can side effect unmount
|
|
235
|
-
// @see npm/react/cypress/component/advanced/set-timeout-example/loading-indicator
|
|
237
|
+
// @see npm/react/cypress/component/advanced/set-timeout-example/loading-indicator.cy.tsx
|
|
236
238
|
setupHooks(preMountCleanup);
|
|
237
239
|
|
|
238
240
|
let root;
|
|
@@ -62,6 +62,7 @@ const getContainerEl = () => {
|
|
|
62
62
|
* Utility function to register CT side effects and run cleanup code during the "test:before:run" Cypress hook
|
|
63
63
|
* @param optionalCallback Callback to be called before the next test runs
|
|
64
64
|
*/
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type -- published API; narrowing the parameter would break callers that pass a `Function`
|
|
65
66
|
function setupHooks(optionalCallback) {
|
|
66
67
|
// We don't want CT side effects to run when e2e
|
|
67
68
|
// testing so we early return.
|
|
@@ -81,7 +82,6 @@ function setupHooks(optionalCallback) {
|
|
|
81
82
|
Cypress.Commands.overwrite('origin', () => {
|
|
82
83
|
throw new Error('cy.origin from a component spec is not allowed');
|
|
83
84
|
});
|
|
84
|
-
// @ts-ignore
|
|
85
85
|
Cypress.on('test:before:after:run:async', () => {
|
|
86
86
|
optionalCallback?.();
|
|
87
87
|
});
|
|
@@ -113,7 +113,7 @@ const makeMountFn = (type, jsx, options = {}, rerenderKey, internalMountOptions)
|
|
|
113
113
|
].join(' '));
|
|
114
114
|
}
|
|
115
115
|
const key = rerenderKey !== null && rerenderKey !== void 0 ? rerenderKey :
|
|
116
|
-
// @ts-
|
|
116
|
+
// @ts-expect-error - `mocha` is not in the public Cypress types. Provide unique key to the wrapped component to make sure we are rerendering between tests
|
|
117
117
|
(((_c = (_b = (_a = Cypress === null || Cypress === void 0 ? void 0 : Cypress.mocha) === null || _a === void 0 ? void 0 : _a.getRunner()) === null || _b === void 0 ? void 0 : _b.test) === null || _c === void 0 ? void 0 : _c.title) || '') + Math.random();
|
|
118
118
|
const props = {
|
|
119
119
|
key,
|
|
@@ -123,7 +123,9 @@ const makeMountFn = (type, jsx, options = {}, rerenderKey, internalMountOptions)
|
|
|
123
123
|
// let's get back the original component
|
|
124
124
|
const userComponent = reactComponent.props.children;
|
|
125
125
|
internalMountOptions.render(reactComponent, el, reactDomToUse);
|
|
126
|
-
return (
|
|
126
|
+
return (
|
|
127
|
+
// eslint-disable-next-line cypress/no-unnecessary-waiting -- the chained zero-length wait is the event-loop tick described below
|
|
128
|
+
cy.wrap(userComponent, { log: false })
|
|
127
129
|
.then(() => {
|
|
128
130
|
return cy.wrap({
|
|
129
131
|
component: userComponent,
|
|
@@ -137,18 +139,18 @@ const makeMountFn = (type, jsx, options = {}, rerenderKey, internalMountOptions)
|
|
|
137
139
|
.then(() => {
|
|
138
140
|
if (options.log !== false) {
|
|
139
141
|
// Get the display name property via the component constructor
|
|
140
|
-
// @ts-ignore FIXME
|
|
141
142
|
const componentName = getDisplayName(jsx);
|
|
142
143
|
const jsxComponentName = `<${componentName} ... />`;
|
|
143
144
|
Cypress.log({
|
|
144
145
|
name: type,
|
|
145
146
|
type: 'parent',
|
|
146
147
|
message: [jsxComponentName],
|
|
147
|
-
// @ts-
|
|
148
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment -- @ts-expect-error would be unused once the cli typedefs are generated
|
|
149
|
+
// @ts-ignore - JQuery comes from cli/types/jquery, which is generated by the cli build and missing when this package builds first
|
|
148
150
|
$el: el.children.item(0),
|
|
149
151
|
consoleProps: () => {
|
|
150
152
|
return {
|
|
151
|
-
// @ts-
|
|
153
|
+
// @ts-expect-error - `props` is not on every `ReactNode` member, such as string
|
|
152
154
|
props: jsx === null || jsx === void 0 ? void 0 : jsx.props,
|
|
153
155
|
description: type === 'mount' ? 'Mounts React component' : 'Rerenders mounted React component',
|
|
154
156
|
home: 'https://github.com/cypress-io/cypress',
|
|
@@ -211,7 +213,7 @@ const createMount = (defaultOptions) => {
|
|
|
211
213
|
// Note: This would be a breaking change
|
|
212
214
|
// it is required to unmount component in beforeEach hook in order to provide a clean state inside test
|
|
213
215
|
// because `mount` can be called after some preparation that can side effect unmount
|
|
214
|
-
// @see npm/react/cypress/component/advanced/set-timeout-example/loading-indicator
|
|
216
|
+
// @see npm/react/cypress/component/advanced/set-timeout-example/loading-indicator.cy.tsx
|
|
215
217
|
setupHooks(preMountCleanup);
|
|
216
218
|
|
|
217
219
|
let root;
|