cypress 4.12.1 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/cli.js +5 -1
- package/lib/errors.js +1 -1
- package/lib/tasks/install.js +164 -16
- package/lib/util.js +8 -9
- package/package.json +11 -9
- package/types/cy-blob-util.d.ts +1 -1
- package/types/cypress-npm-api.d.ts +31 -24
- package/types/cypress.d.ts +167 -73
- package/types/index.d.ts +2 -1
- package/types/net-stubbing.ts +257 -0
- package/types/blob-util/index.d.ts +0 -97
package/lib/cli.js
CHANGED
@@ -55,6 +55,10 @@ function unknownOption(flag) {
|
|
55
55
|
|
56
56
|
commander.Command.prototype.unknownOption = unknownOption;
|
57
57
|
|
58
|
+
var coerceFalseOrString = function coerceFalseOrString(arg) {
|
59
|
+
return arg !== 'false' ? arg : false;
|
60
|
+
};
|
61
|
+
|
58
62
|
var coerceFalse = function coerceFalse(arg) {
|
59
63
|
return arg !== 'false';
|
60
64
|
};
|
@@ -196,7 +200,7 @@ var castCypressRunOptions = function castCypressRunOptions(opts) {
|
|
196
200
|
// boolean arguments
|
197
201
|
var result = R.evolve({
|
198
202
|
port: coerceAnyStringToInt,
|
199
|
-
configFile:
|
203
|
+
configFile: coerceFalseOrString
|
200
204
|
})(opts);
|
201
205
|
return result;
|
202
206
|
};
|
package/lib/errors.js
CHANGED
@@ -121,7 +121,7 @@ function _templateObject6() {
|
|
121
121
|
}
|
122
122
|
|
123
123
|
function _templateObject5() {
|
124
|
-
var data = _taggedTemplateLiteral(["\n\n Reasons this may happen:\n\n - node was installed as 'root' or with 'sudo'\n - the cypress npm package as 'root' or with 'sudo'\n\n Please check that you have the appropriate user permissions.\n "], ["\\n\n Reasons this may happen:\n\n - node was installed as 'root' or with 'sudo'\n - the cypress npm package as 'root' or with 'sudo'\n\n Please check that you have the appropriate user permissions.\n "]);
|
124
|
+
var data = _taggedTemplateLiteral(["\n\n Reasons this may happen:\n\n - node was installed as 'root' or with 'sudo'\n - the cypress npm package as 'root' or with 'sudo'\n\n Please check that you have the appropriate user permissions.\n\n You can also try clearing the cache with 'cypress cache clear' and reinstalling. \n "], ["\\n\n Reasons this may happen:\n\n - node was installed as 'root' or with 'sudo'\n - the cypress npm package as 'root' or with 'sudo'\n\n Please check that you have the appropriate user permissions.\n\n You can also try clearing the cache with 'cypress cache clear' and reinstalling. \n "]);
|
125
125
|
|
126
126
|
_templateObject5 = function _templateObject5() {
|
127
127
|
return data;
|
package/lib/tasks/install.js
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
4
|
+
|
3
5
|
function _templateObject7() {
|
4
6
|
var data = _taggedTemplateLiteral(["\n ", " Warning: Forcing a binary version different than the default.\n\n The CLI expected to install version: ", "\n\n Instead we will install version: ", "\n\n These versions may not work properly together.\n "]);
|
5
7
|
|
@@ -20,6 +22,18 @@ function _templateObject6() {
|
|
20
22
|
return data;
|
21
23
|
}
|
22
24
|
|
25
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
26
|
+
|
27
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
28
|
+
|
29
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
30
|
+
|
31
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
32
|
+
|
33
|
+
function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
34
|
+
|
35
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
36
|
+
|
23
37
|
function _templateObject5() {
|
24
38
|
var data = _taggedTemplateLiteral(["\n Failed to access ", ":\n\n ", "\n "]);
|
25
39
|
|
@@ -72,10 +86,32 @@ function _templateObject() {
|
|
72
86
|
|
73
87
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
74
88
|
|
89
|
+
function _wrapRegExp(re, groups) { _wrapRegExp = function _wrapRegExp(re, groups) { return new BabelRegExp(re, undefined, groups); }; var _RegExp = _wrapNativeSuper(RegExp); var _super = RegExp.prototype; var _groups = new WeakMap(); function BabelRegExp(re, flags, groups) { var _this = _RegExp.call(this, re, flags); _groups.set(_this, groups || _groups.get(re)); return _this; } _inherits(BabelRegExp, _RegExp); BabelRegExp.prototype.exec = function (str) { var result = _super.exec.call(this, str); if (result) result.groups = buildGroups(result, this); return result; }; BabelRegExp.prototype[Symbol.replace] = function (str, substitution) { if (typeof substitution === "string") { var groups = _groups.get(this); return _super[Symbol.replace].call(this, str, substitution.replace(/\$<([^>]+)>/g, function (_, name) { return "$" + groups[name]; })); } else if (typeof substitution === "function") { var _this = this; return _super[Symbol.replace].call(this, str, function () { var args = []; args.push.apply(args, arguments); if (_typeof(args[args.length - 1]) !== "object") { args.push(buildGroups(args, _this)); } return substitution.apply(this, args); }); } else { return _super[Symbol.replace].call(this, str, substitution); } }; function buildGroups(result, re) { var g = _groups.get(re); return Object.keys(g).reduce(function (groups, name) { groups[name] = result[g[name]]; return groups; }, Object.create(null)); } return _wrapRegExp.apply(this, arguments); }
|
90
|
+
|
91
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
92
|
+
|
93
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
94
|
+
|
95
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
96
|
+
|
97
|
+
function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
|
98
|
+
|
99
|
+
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
100
|
+
|
101
|
+
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
102
|
+
|
103
|
+
function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
|
104
|
+
|
105
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
106
|
+
|
107
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
108
|
+
|
75
109
|
var _ = require('lodash');
|
76
110
|
|
77
111
|
var os = require('os');
|
78
112
|
|
113
|
+
var url = require('url');
|
114
|
+
|
79
115
|
var path = require('path');
|
80
116
|
|
81
117
|
var chalk = require('chalk');
|
@@ -109,6 +145,102 @@ var _require2 = require('../errors'),
|
|
109
145
|
throwFormErrorText = _require2.throwFormErrorText,
|
110
146
|
errors = _require2.errors;
|
111
147
|
|
148
|
+
var getNpmArgv = function getNpmArgv() {
|
149
|
+
var json = process.env.npm_config_argv;
|
150
|
+
|
151
|
+
if (!json) {
|
152
|
+
return;
|
153
|
+
}
|
154
|
+
|
155
|
+
debug('found npm argv json %o', json);
|
156
|
+
|
157
|
+
try {
|
158
|
+
return JSON.parse(json).original || [];
|
159
|
+
} catch (e) {
|
160
|
+
return [];
|
161
|
+
}
|
162
|
+
}; // attempt to discover the version specifier used to install Cypress
|
163
|
+
// for example: "^5.0.0", "https://cdn.cypress.io/...", ...
|
164
|
+
|
165
|
+
|
166
|
+
var getVersionSpecifier = function getVersionSpecifier() {
|
167
|
+
var startDir = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : path.resolve(__dirname, '../..');
|
168
|
+
var argv = getNpmArgv();
|
169
|
+
|
170
|
+
if (argv) {
|
171
|
+
var tgz = _.find(argv, function (t) {
|
172
|
+
return t.endsWith('cypress.tgz');
|
173
|
+
});
|
174
|
+
|
175
|
+
if (tgz) {
|
176
|
+
return tgz;
|
177
|
+
}
|
178
|
+
}
|
179
|
+
|
180
|
+
var getVersionSpecifierFromPkg = function getVersionSpecifierFromPkg(dir) {
|
181
|
+
debug('looking for versionSpecifier %o', {
|
182
|
+
dir: dir
|
183
|
+
});
|
184
|
+
|
185
|
+
var tryParent = function tryParent() {
|
186
|
+
var parentPath = path.resolve(dir, '..');
|
187
|
+
|
188
|
+
if (parentPath === dir) {
|
189
|
+
debug('reached FS root with no versionSpecifier found');
|
190
|
+
return;
|
191
|
+
}
|
192
|
+
|
193
|
+
return getVersionSpecifierFromPkg(parentPath);
|
194
|
+
};
|
195
|
+
|
196
|
+
return fs.readJSON(path.join(dir, 'package.json'))["catch"](function () {
|
197
|
+
return {};
|
198
|
+
}).then(function (pkg) {
|
199
|
+
var specifier = _.chain(['dependencies', 'devDependencies', 'optionalDependencies']).map(function (prop) {
|
200
|
+
return _.get(pkg, "".concat(prop, ".cypress"));
|
201
|
+
}).compact().first().value();
|
202
|
+
|
203
|
+
return specifier || tryParent();
|
204
|
+
});
|
205
|
+
}; // recurse through parent directories until package.json with `cypress` is found
|
206
|
+
|
207
|
+
|
208
|
+
return getVersionSpecifierFromPkg(startDir).then(function (versionSpecifier) {
|
209
|
+
debug('finished looking for versionSpecifier', {
|
210
|
+
versionSpecifier: versionSpecifier
|
211
|
+
});
|
212
|
+
return versionSpecifier;
|
213
|
+
});
|
214
|
+
};
|
215
|
+
|
216
|
+
var betaNpmUrlRe = /*#__PURE__*/_wrapRegExp(/^\/beta\/npm\/([\.0-9]+)\/([\0-\.0-\uFFFF]+)\/cypress\.tgz$/, {
|
217
|
+
version: 1,
|
218
|
+
artifactSlug: 2
|
219
|
+
}); // convert a prerelease NPM package .tgz URL to the corresponding binary .zip URL
|
220
|
+
|
221
|
+
|
222
|
+
var getBinaryUrlFromPrereleaseNpmUrl = function getBinaryUrlFromPrereleaseNpmUrl(npmUrl) {
|
223
|
+
var parsed;
|
224
|
+
|
225
|
+
try {
|
226
|
+
parsed = url.parse(npmUrl);
|
227
|
+
} catch (e) {
|
228
|
+
return;
|
229
|
+
}
|
230
|
+
|
231
|
+
var matches = betaNpmUrlRe.exec(parsed.pathname);
|
232
|
+
|
233
|
+
if (parsed.hostname !== 'cdn.cypress.io' || !matches) {
|
234
|
+
return;
|
235
|
+
}
|
236
|
+
|
237
|
+
var _matches$groups = matches.groups,
|
238
|
+
version = _matches$groups.version,
|
239
|
+
artifactSlug = _matches$groups.artifactSlug;
|
240
|
+
parsed.pathname = "/beta/binary/".concat(version, "/").concat(os.platform(), "-").concat(os.arch(), "/").concat(artifactSlug, "/cypress.zip");
|
241
|
+
return parsed.format();
|
242
|
+
};
|
243
|
+
|
112
244
|
var alreadyInstalledMsg = function alreadyInstalledMsg() {
|
113
245
|
if (!util.isPostInstall()) {
|
114
246
|
logger.log(stripIndent(_templateObject(), chalk.yellow('--force')));
|
@@ -204,6 +336,7 @@ var start = function start() {
|
|
204
336
|
|
205
337
|
var pkgVersion = util.pkgVersion();
|
206
338
|
var needVersion = pkgVersion;
|
339
|
+
var binaryUrlOverride;
|
207
340
|
debug('version in package.json is', needVersion); // let this environment variable reset the binary version we need
|
208
341
|
|
209
342
|
if (util.getEnv('CYPRESS_INSTALL_BINARY')) {
|
@@ -218,14 +351,9 @@ var start = function start() {
|
|
218
351
|
logger.log(stripIndent(_templateObject3(), chalk.yellow('Note:')));
|
219
352
|
logger.log();
|
220
353
|
return Promise.resolve();
|
221
|
-
} // if this doesn't match the expected version
|
222
|
-
// then print warning to the user
|
223
|
-
|
224
|
-
|
225
|
-
if (envVarVersion !== needVersion) {
|
226
|
-
// reset the version to the env var version
|
227
|
-
needVersion = envVarVersion;
|
228
354
|
}
|
355
|
+
|
356
|
+
binaryUrlOverride = envVarVersion;
|
229
357
|
}
|
230
358
|
|
231
359
|
if (util.getEnv('CYPRESS_CACHE_FOLDER')) {
|
@@ -242,14 +370,32 @@ var start = function start() {
|
|
242
370
|
}, function (err) {
|
243
371
|
return throwFormErrorText(errors.invalidCacheDirectory)(stripIndent(_templateObject5(), chalk.cyan(cacheDir), err.message));
|
244
372
|
}).then(function () {
|
245
|
-
return state.getBinaryPkgVersionAsync(binaryDir);
|
246
|
-
}).then(function (
|
373
|
+
return Promise.all([state.getBinaryPkgVersionAsync(binaryDir), getVersionSpecifier()]);
|
374
|
+
}).then(function (_ref2) {
|
375
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
376
|
+
binaryVersion = _ref3[0],
|
377
|
+
versionSpecifier = _ref3[1];
|
378
|
+
|
379
|
+
if (!binaryUrlOverride && versionSpecifier) {
|
380
|
+
var computedBinaryUrl = getBinaryUrlFromPrereleaseNpmUrl(versionSpecifier);
|
381
|
+
|
382
|
+
if (computedBinaryUrl) {
|
383
|
+
debug('computed binary url from version specifier %o', {
|
384
|
+
computedBinaryUrl: computedBinaryUrl,
|
385
|
+
needVersion: needVersion
|
386
|
+
});
|
387
|
+
binaryUrlOverride = computedBinaryUrl;
|
388
|
+
}
|
389
|
+
}
|
390
|
+
|
391
|
+
needVersion = binaryUrlOverride || needVersion;
|
392
|
+
debug('installed version is', binaryVersion, 'version needed is', needVersion);
|
393
|
+
|
247
394
|
if (!binaryVersion) {
|
248
395
|
debug('no binary installed under cli version');
|
249
396
|
return true;
|
250
397
|
}
|
251
398
|
|
252
|
-
debug('installed version is', binaryVersion, 'version needed is', needVersion);
|
253
399
|
logger.log();
|
254
400
|
logger.log(stripIndent(_templateObject6(), chalk.green(binaryVersion), chalk.cyan(installDir)));
|
255
401
|
logger.log();
|
@@ -332,14 +478,16 @@ var start = function start() {
|
|
332
478
|
};
|
333
479
|
|
334
480
|
module.exports = {
|
335
|
-
start: start
|
481
|
+
start: start,
|
482
|
+
_getVersionSpecifier: getVersionSpecifier,
|
483
|
+
_getBinaryUrlFromPrereleaseNpmUrl: getBinaryUrlFromPrereleaseNpmUrl
|
336
484
|
};
|
337
485
|
|
338
|
-
var unzipTask = function unzipTask(
|
339
|
-
var zipFilePath =
|
340
|
-
installDir =
|
341
|
-
progress =
|
342
|
-
rendererOptions =
|
486
|
+
var unzipTask = function unzipTask(_ref4) {
|
487
|
+
var zipFilePath = _ref4.zipFilePath,
|
488
|
+
installDir = _ref4.installDir,
|
489
|
+
progress = _ref4.progress,
|
490
|
+
rendererOptions = _ref4.rendererOptions;
|
343
491
|
return {
|
344
492
|
title: util.titleize('Unzipping Cypress'),
|
345
493
|
task: function task(ctx, _task3) {
|
package/lib/util.js
CHANGED
@@ -449,20 +449,19 @@ var util = {
|
|
449
449
|
},
|
450
450
|
getEnv: function getEnv(varName, trim) {
|
451
451
|
la(is.unemptyString(varName), 'expected environment variable name, not', varName);
|
452
|
-
var
|
453
|
-
var
|
454
|
-
var packageConfigVar = process.env["npm_package_config_".concat(varName)];
|
452
|
+
var configVarName = "npm_config_".concat(varName);
|
453
|
+
var packageConfigVarName = "npm_package_config_".concat(varName);
|
455
454
|
var result;
|
456
455
|
|
457
|
-
if (
|
456
|
+
if (process.env.hasOwnProperty(varName)) {
|
458
457
|
debug("Using ".concat(varName, " from environment variable"));
|
459
|
-
result =
|
460
|
-
} else if (
|
458
|
+
result = process.env[varName];
|
459
|
+
} else if (process.env.hasOwnProperty(configVarName)) {
|
461
460
|
debug("Using ".concat(varName, " from npm config"));
|
462
|
-
result =
|
463
|
-
} else if (
|
461
|
+
result = process.env[configVarName];
|
462
|
+
} else if (process.env.hasOwnProperty(packageConfigVarName)) {
|
464
463
|
debug("Using ".concat(varName, " from package.json config"));
|
465
|
-
result =
|
464
|
+
result = process.env[packageConfigVarName];
|
466
465
|
} // environment variables are often set double quotes to escape characters
|
467
466
|
// and on Windows it can lead to weird things: for example
|
468
467
|
// set FOO="C:\foo.txt" && node -e "console.log('>>>%s<<<', process.env.FOO)"
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "cypress",
|
3
|
-
"version": "
|
3
|
+
"version": "5.3.0",
|
4
4
|
"main": "index.js",
|
5
5
|
"scripts": {
|
6
6
|
"postinstall": "node index.js --exec install",
|
@@ -13,26 +13,27 @@
|
|
13
13
|
"@types/sinonjs__fake-timers": "^6.0.1",
|
14
14
|
"@types/sizzle": "^2.3.2",
|
15
15
|
"arch": "^2.1.2",
|
16
|
+
"blob-util": "2.0.2",
|
16
17
|
"bluebird": "^3.7.2",
|
17
18
|
"cachedir": "^2.3.0",
|
18
|
-
"chalk": "^
|
19
|
+
"chalk": "^4.1.0",
|
19
20
|
"check-more-types": "^2.24.0",
|
20
|
-
"cli-table3": "~0.
|
21
|
+
"cli-table3": "~0.6.0",
|
21
22
|
"commander": "^4.1.1",
|
22
23
|
"common-tags": "^1.8.0",
|
23
24
|
"debug": "^4.1.1",
|
24
25
|
"eventemitter2": "^6.4.2",
|
25
|
-
"execa": "^
|
26
|
+
"execa": "^4.0.2",
|
26
27
|
"executable": "^4.1.1",
|
27
28
|
"extract-zip": "^1.7.0",
|
28
|
-
"fs-extra": "^
|
29
|
+
"fs-extra": "^9.0.1",
|
29
30
|
"getos": "^3.2.1",
|
30
31
|
"is-ci": "^2.0.0",
|
31
32
|
"is-installed-globally": "^0.3.2",
|
32
33
|
"lazy-ass": "^1.6.0",
|
33
34
|
"listr": "^0.14.3",
|
34
35
|
"lodash": "^4.17.19",
|
35
|
-
"log-symbols": "^
|
36
|
+
"log-symbols": "^4.0.0",
|
36
37
|
"minimist": "^1.2.5",
|
37
38
|
"moment": "^2.27.0",
|
38
39
|
"ospath": "^1.2.2",
|
@@ -40,7 +41,7 @@
|
|
40
41
|
"ramda": "~0.26.1",
|
41
42
|
"request-progress": "^3.0.0",
|
42
43
|
"supports-color": "^7.1.0",
|
43
|
-
"tmp": "~0.1
|
44
|
+
"tmp": "~0.2.1",
|
44
45
|
"untildify": "^4.0.0",
|
45
46
|
"url": "^0.11.0",
|
46
47
|
"yauzl": "^2.10.0"
|
@@ -49,13 +50,14 @@
|
|
49
50
|
"bin",
|
50
51
|
"lib",
|
51
52
|
"index.js",
|
52
|
-
"types/**/*.d.ts"
|
53
|
+
"types/**/*.d.ts",
|
54
|
+
"types/net-stubbing.ts"
|
53
55
|
],
|
54
56
|
"bin": {
|
55
57
|
"cypress": "bin/cypress"
|
56
58
|
},
|
57
59
|
"engines": {
|
58
|
-
"node": ">=
|
60
|
+
"node": ">=10.0.0"
|
59
61
|
},
|
60
62
|
"types": "types",
|
61
63
|
"description": "Cypress.io end to end testing tool",
|
package/types/cy-blob-util.d.ts
CHANGED
@@ -7,6 +7,12 @@
|
|
7
7
|
// but for now describe it as an ambient module
|
8
8
|
|
9
9
|
declare namespace CypressCommandLine {
|
10
|
+
type HookName = 'before' | 'beforeEach' | 'afterEach' | 'after'
|
11
|
+
interface TestError {
|
12
|
+
name: string
|
13
|
+
message: string
|
14
|
+
stack: string
|
15
|
+
}
|
10
16
|
/**
|
11
17
|
* All options that one can pass to "cypress.run"
|
12
18
|
* @see https://on.cypress.io/module-api#cypress-run
|
@@ -154,39 +160,36 @@ declare namespace CypressCommandLine {
|
|
154
160
|
// small utility types to better express meaning of other types
|
155
161
|
type dateTimeISO = string
|
156
162
|
type ms = number
|
157
|
-
type hookId = string
|
158
|
-
type testId = string
|
159
163
|
type pixels = number
|
160
164
|
|
161
165
|
/**
|
162
166
|
* Cypress single test result
|
163
167
|
*/
|
164
168
|
interface TestResult {
|
165
|
-
testId: testId
|
166
169
|
title: string[]
|
167
170
|
state: string
|
168
171
|
body: string
|
169
|
-
|
170
|
-
* Error
|
171
|
-
*/
|
172
|
-
stack: string | null
|
173
|
-
/**
|
174
|
-
* Error message if there is an error
|
172
|
+
/**
|
173
|
+
* Error string as it's presented in console if the test fails
|
175
174
|
*/
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
175
|
+
displayError: string | null
|
176
|
+
attempts: AttemptResult[]
|
177
|
+
}
|
178
|
+
|
179
|
+
interface AttemptResult {
|
180
|
+
state: string
|
181
|
+
error: TestError | null
|
182
|
+
startedAt: dateTimeISO
|
183
|
+
duration: ms
|
181
184
|
videoTimestamp: ms
|
185
|
+
screenshots: ScreenshotInformation[]
|
182
186
|
}
|
183
187
|
|
184
188
|
/**
|
185
189
|
* Information about a single "before", "beforeEach", "afterEach" and "after" hook.
|
186
190
|
*/
|
187
191
|
interface HookInformation {
|
188
|
-
|
189
|
-
hookName: 'before' | 'beforeEach' | 'afterEach' | 'after'
|
192
|
+
hookName: HookName
|
190
193
|
title: string[]
|
191
194
|
body: string
|
192
195
|
}
|
@@ -195,9 +198,7 @@ declare namespace CypressCommandLine {
|
|
195
198
|
* Information about a single screenshot.
|
196
199
|
*/
|
197
200
|
interface ScreenshotInformation {
|
198
|
-
screenshotId: string
|
199
201
|
name: string
|
200
|
-
testId: testId
|
201
202
|
takenAt: dateTimeISO
|
202
203
|
/**
|
203
204
|
* Absolute path to the saved image
|
@@ -221,9 +222,9 @@ declare namespace CypressCommandLine {
|
|
221
222
|
pending: number
|
222
223
|
skipped: number
|
223
224
|
failures: number
|
224
|
-
|
225
|
-
|
226
|
-
|
225
|
+
startedAt: dateTimeISO
|
226
|
+
endedAt: dateTimeISO
|
227
|
+
duration: ms
|
227
228
|
},
|
228
229
|
/**
|
229
230
|
* Reporter name like "spec"
|
@@ -238,7 +239,6 @@ declare namespace CypressCommandLine {
|
|
238
239
|
tests: TestResult[]
|
239
240
|
error: string | null
|
240
241
|
video: string | null
|
241
|
-
screenshots: ScreenshotInformation[]
|
242
242
|
/**
|
243
243
|
* information about the spec test file.
|
244
244
|
*/
|
@@ -264,6 +264,7 @@ declare namespace CypressCommandLine {
|
|
264
264
|
* @see https://on.cypress.io/module-api
|
265
265
|
*/
|
266
266
|
interface CypressRunResult {
|
267
|
+
status: 'finished'
|
267
268
|
startedTestsAt: dateTimeISO
|
268
269
|
endedTestsAt: dateTimeISO
|
269
270
|
totalDuration: ms
|
@@ -294,7 +295,8 @@ declare namespace CypressCommandLine {
|
|
294
295
|
* @example
|
295
296
|
```
|
296
297
|
const result = await cypress.run()
|
297
|
-
if (result.
|
298
|
+
if (result.status === 'failed') {
|
299
|
+
console.error('failures %d', result.failures)
|
298
300
|
console.error(result.message)
|
299
301
|
process.exit(result.failures)
|
300
302
|
}
|
@@ -302,6 +304,7 @@ declare namespace CypressCommandLine {
|
|
302
304
|
*
|
303
305
|
**/
|
304
306
|
interface CypressFailedRunResult {
|
307
|
+
status: 'failed'
|
305
308
|
failures: number
|
306
309
|
message: string
|
307
310
|
}
|
@@ -347,7 +350,11 @@ declare module 'cypress' {
|
|
347
350
|
cypress.run({
|
348
351
|
spec: 'cypress/integration/admin*-spec.js'
|
349
352
|
}).then(results => {
|
350
|
-
|
353
|
+
if (results.status === 'failed') {
|
354
|
+
// Cypress could not run
|
355
|
+
} else {
|
356
|
+
// inspect results object
|
357
|
+
}
|
351
358
|
})
|
352
359
|
```
|
353
360
|
*/
|