cypress 5.1.0 → 5.2.0

Sign up to get free protection for your applications and to get access to all the features.
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;
@@ -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 (binaryVersion) {
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(_ref2) {
339
- var zipFilePath = _ref2.zipFilePath,
340
- installDir = _ref2.installDir,
341
- progress = _ref2.progress,
342
- rendererOptions = _ref2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cypress",
3
- "version": "5.1.0",
3
+ "version": "5.2.0",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "postinstall": "node index.js --exec install",
@@ -1,10 +1,10 @@
1
1
  declare namespace Cypress {
2
2
  type FileContents = string | any[] | object
3
- type HistoryDirection = "back" | "forward"
3
+ type HistoryDirection = 'back' | 'forward'
4
4
  type HttpMethod = string
5
5
  type RequestBody = string | object
6
- type ViewportOrientation = "portrait" | "landscape"
7
- type PrevSubject = "optional" | "element" | "document" | "window"
6
+ type ViewportOrientation = 'portrait' | 'landscape'
7
+ type PrevSubject = 'optional' | 'element' | 'document' | 'window'
8
8
  type PluginConfig = (on: PluginEvents, config: PluginConfigOptions) => void | ConfigOptions | Promise<ConfigOptions>
9
9
 
10
10
  interface CommandOptions {
@@ -114,7 +114,7 @@ declare namespace Cypress {
114
114
  *
115
115
  * @see https://on.cypress.io/experiments
116
116
  */
117
- type CypressSpecType = "integration" | "component"
117
+ type CypressSpecType = 'integration' | 'component'
118
118
 
119
119
  /**
120
120
  * Window type for Application Under Test(AUT)
@@ -413,7 +413,7 @@ declare namespace Cypress {
413
413
  * Returns a boolean indicating whether an object is a DOM object.
414
414
  */
415
415
  isDom(obj: any): boolean
416
- isType(element: JQuery | HTMLElement , type: string): boolean
416
+ isType(element: JQuery | HTMLElement, type: string): boolean
417
417
  /**
418
418
  * Returns a boolean indicating whether an element is visible.
419
419
  */
@@ -518,7 +518,7 @@ declare namespace Cypress {
518
518
  off: Actions
519
519
  }
520
520
 
521
- type CanReturnChainable = void | Chainable
521
+ type CanReturnChainable = void | Chainable | Promise<unknown>
522
522
  type ThenReturn<S, R> =
523
523
  R extends void ? Chainable<S> :
524
524
  R extends R | undefined ? Chainable<S | Exclude<R, undefined>> :
@@ -1607,15 +1607,12 @@ declare namespace Cypress {
1607
1607
 
1608
1608
  /**
1609
1609
  * Traverse into an element's shadow root.
1610
- * Requires `experimentalShadowDomSupport: true` config option
1611
1610
  *
1612
- @example
1613
- ```js
1614
- cy.get('.top-level > my-component')
1615
- .shadow()
1616
- .find('.my-button')
1617
- .click()
1618
- ```
1611
+ * @example
1612
+ * cy.get('my-component')
1613
+ * .shadow()
1614
+ * .find('.my-button')
1615
+ * .click()
1619
1616
  * @see https://on.cypress.io/experimental
1620
1617
  */
1621
1618
  shadow(): Chainable<Subject>
@@ -2302,7 +2299,7 @@ declare namespace Cypress {
2302
2299
  * @default {@link Timeoutable#timeout}
2303
2300
  * @see https://docs.cypress.io/guides/references/configuration.html#Timeouts
2304
2301
  */
2305
- requestTimeout: number,
2302
+ requestTimeout: number
2306
2303
  /**
2307
2304
  * Time to wait for the response (ms)
2308
2305
  *
@@ -2485,7 +2482,7 @@ declare namespace Cypress {
2485
2482
  * If set to `system`, Cypress will try to find a `node` executable on your path to use when executing your plugins. Otherwise, Cypress will use the Node version bundled with Cypress.
2486
2483
  * @default "bundled"
2487
2484
  */
2488
- nodeVersion: "system" | "bundled"
2485
+ nodeVersion: 'system' | 'bundled'
2489
2486
  /**
2490
2487
  * Path to plugins file. (Pass false to disable)
2491
2488
  * @default "cypress/plugins/index.js"
@@ -2584,12 +2581,6 @@ declare namespace Cypress {
2584
2581
  * @default false
2585
2582
  */
2586
2583
  experimentalNetworkStubbing: boolean
2587
- /**
2588
- * Enables shadow DOM support. Adds the `cy.shadow()` command and
2589
- * the `includeShadowDom` option to some DOM commands.
2590
- * @default false
2591
- */
2592
- experimentalShadowDomSupport: boolean
2593
2584
  /**
2594
2585
  * Number of times to retry a failed test.
2595
2586
  * If a number is set, tests will retry in both runMode and openMode.
@@ -2597,9 +2588,17 @@ declare namespace Cypress {
2597
2588
  * @default null
2598
2589
  */
2599
2590
  retries: Nullable<number | {runMode: Nullable<number>, openMode: Nullable<number>}>
2591
+ /**
2592
+ * Enables including elements within the shadow DOM when using querying
2593
+ * commands (e.g. cy.get(), cy.find()). Can be set globally in cypress.json,
2594
+ * per-suite or per-test in the test configuration object, or programmatically
2595
+ * with Cypress.config()
2596
+ * @default false
2597
+ */
2598
+ includeShadowDom: boolean
2600
2599
  }
2601
2600
 
2602
- interface TestConfigOverrides extends Partial<Pick<ConfigOptions, 'baseUrl' | 'defaultCommandTimeout' | 'taskTimeout' | 'animationDistanceThreshold' | 'waitForAnimations' | 'viewportHeight' | 'viewportWidth' | 'requestTimeout' | 'execTimeout' | 'env' | 'responseTimeout' | 'retries'>> {
2601
+ interface TestConfigOverrides extends Partial<Pick<ConfigOptions, 'baseUrl' | 'defaultCommandTimeout' | 'taskTimeout' | 'animationDistanceThreshold' | 'waitForAnimations' | 'viewportHeight' | 'viewportWidth' | 'requestTimeout' | 'execTimeout' | 'env' | 'responseTimeout' | 'retries' | 'includeShadowDom'>> {
2603
2602
  browser?: IsBrowserMatcher | IsBrowserMatcher[]
2604
2603
  }
2605
2604
 
@@ -2699,18 +2698,18 @@ declare namespace Cypress {
2699
2698
  scale: boolean
2700
2699
  onBeforeScreenshot: ($el: JQuery) => void
2701
2700
  onAfterScreenshot: ($el: JQuery, props: {
2702
- path: string,
2703
- size: number,
2701
+ path: string
2702
+ size: number
2704
2703
  dimensions: {
2705
- width: number,
2704
+ width: number
2706
2705
  height: number
2707
- },
2708
- multipart: boolean,
2709
- pixelRatio: number,
2710
- takenAt: string,
2711
- name: string,
2712
- blackout: string[],
2713
- duration: number,
2706
+ }
2707
+ multipart: boolean
2708
+ pixelRatio: number
2709
+ takenAt: string
2710
+ name: string
2711
+ blackout: string[]
2712
+ duration: number
2714
2713
  testAttemptIndex: number
2715
2714
  }) => void
2716
2715
  }
@@ -2731,13 +2730,13 @@ declare namespace Cypress {
2731
2730
  *
2732
2731
  * @default 'swing'
2733
2732
  */
2734
- easing: 'swing' | 'linear',
2733
+ easing: 'swing' | 'linear'
2735
2734
  /**
2736
2735
  * Ensure element is scrollable. Error if element is not scrollable
2737
2736
  *
2738
2737
  * @default true
2739
2738
  */
2740
- ensureScrollable: boolean,
2739
+ ensureScrollable: boolean
2741
2740
  }
2742
2741
 
2743
2742
  interface ScrollIntoViewOptions extends ScrollToOptions {
@@ -2786,6 +2785,10 @@ declare namespace Cypress {
2786
2785
  sameSite: SameSiteStatus
2787
2786
  }
2788
2787
 
2788
+ interface ShadowDomOptions {
2789
+ includeShadowDom?: boolean
2790
+ }
2791
+
2789
2792
  /**
2790
2793
  * Options that control `cy.type` command
2791
2794
  *
@@ -4948,9 +4951,9 @@ declare namespace Cypress {
4948
4951
  }
4949
4952
 
4950
4953
  interface BrowserLaunchOptions {
4951
- extensions: string[],
4954
+ extensions: string[]
4952
4955
  preferences: { [key: string]: any }
4953
- args: string[],
4956
+ args: string[]
4954
4957
  }
4955
4958
 
4956
4959
  interface Dimensions {
@@ -5291,10 +5294,10 @@ declare namespace Cypress {
5291
5294
  }
5292
5295
 
5293
5296
  type Encodings = 'ascii' | 'base64' | 'binary' | 'hex' | 'latin1' | 'utf8' | 'utf-8' | 'ucs2' | 'ucs-2' | 'utf16le' | 'utf-16le'
5294
- type PositionType = "topLeft" | "top" | "topRight" | "left" | "center" | "right" | "bottomLeft" | "bottom" | "bottomRight"
5297
+ type PositionType = 'topLeft' | 'top' | 'topRight' | 'left' | 'center' | 'right' | 'bottomLeft' | 'bottom' | 'bottomRight'
5295
5298
  type ViewportPreset = 'macbook-15' | 'macbook-13' | 'macbook-11' | 'ipad-2' | 'ipad-mini' | 'iphone-xr' | 'iphone-x' | 'iphone-6+' | 'iphone-6' | 'iphone-5' | 'iphone-4' | 'iphone-3' | 'samsung-s10' | 'samsung-note9'
5296
5299
  interface Offset {
5297
- top: number,
5300
+ top: number
5298
5301
  left: number
5299
5302
  }
5300
5303
 
@@ -5382,6 +5385,6 @@ declare namespace Mocha {
5382
5385
  }
5383
5386
 
5384
5387
  interface PendingSuiteFunction {
5385
- (title: string, config: Cypress.TestConfigOverrides, fn: (this: Suite) => void): Suite | void
5388
+ (title: string, config: Cypress.TestConfigOverrides, fn: (this: Suite) => void): Suite | void
5386
5389
  }
5387
5390
  }
@@ -39,6 +39,11 @@ export namespace CyHttpMessages {
39
39
 
40
40
  export type IncomingRequest = BaseMessage & {
41
41
  responseTimeout?: number
42
+ /**
43
+ * Set if redirects should be followed when this request is made. By default, requests will
44
+ * not follow redirects before yielding the response (the 3xx redirect is yielded)
45
+ */
46
+ followRedirect?: boolean
42
47
  }
43
48
 
44
49
  export interface IncomingHttpRequest extends IncomingRequest {
@@ -173,7 +178,12 @@ export type RouteHandler = string | StaticResponse | RouteHandlerController | ob
173
178
  /**
174
179
  * Describes a response that will be sent back to the browser to fulfill the request.
175
180
  */
176
- export type StaticResponse = GenericStaticResponse<string, string | object>
181
+ export type StaticResponse = GenericStaticResponse<string, string | object> & {
182
+ /**
183
+ * If set, `delayMs` will pass before the response is sent.
184
+ */
185
+ delayMs?: number
186
+ }
177
187
 
178
188
  export interface GenericStaticResponse<Fixture, Body> {
179
189
  /**
@@ -196,6 +206,10 @@ export interface GenericStaticResponse<Fixture, Body> {
196
206
  * If `forceNetworkError` is truthy, Cypress will destroy the connection to the browser and send no response. Useful for simulating a server that is not reachable. Must not be set in combination with other options.
197
207
  */
198
208
  forceNetworkError?: boolean
209
+ /**
210
+ * If set, the `body` will be sent at `throttleKbps` kbps.
211
+ */
212
+ throttleKbps?: number
199
213
  }
200
214
 
201
215
  /**
@@ -206,7 +220,37 @@ export type StringMatcher = GlobPattern | RegExp
206
220
  declare global {
207
221
  namespace Cypress {
208
222
  interface Chainable<Subject = any> {
223
+ /**
224
+ * Use `cy.route2()` to stub and intercept HTTP requests and responses.
225
+ *
226
+ * Note: this command is only available if you have set the `experimentalNetworkStubbing`
227
+ * configuration option to `true`.
228
+ *
229
+ * @see https://on.cypress.io/route2
230
+ * @example
231
+ * cy.route2('https://localhost:7777/users', [{id: 1, name: 'Pat'}])
232
+ * @example
233
+ * cy.route2('https://localhost:7777/protected-endpoint', (req) => {
234
+ * req.headers['authorization'] = 'basic fooabc123'
235
+ * })
236
+ * @example
237
+ * cy.route2('https://localhost:7777/some-response', (req) => {
238
+ * req.reply(res => {
239
+ * res.body = 'some new body'
240
+ * })
241
+ * })
242
+ */
209
243
  route2(url: RouteMatcher, response?: RouteHandler): Chainable<null>
244
+ /**
245
+ * Use `cy.route2()` to stub and intercept HTTP requests and responses.
246
+ *
247
+ * Note: this command is only available if you have set the `experimentalNetworkStubbing`
248
+ * configuration option to `true`.
249
+ *
250
+ * @see https://on.cypress.io/route2
251
+ * @example
252
+ * cy.route2('GET', 'http://foo.com/fruits', ['apple', 'banana', 'cherry'])
253
+ */
210
254
  route2(method: string, url: RouteMatcher, response?: RouteHandler): Chainable<null>
211
255
  }
212
256
  }