cypress 5.3.0 → 5.4.0

Sign up to get free protection for your applications and to get access to all the features.
package/lib/cli.js CHANGED
@@ -123,8 +123,10 @@ var descriptions = {
123
123
  browserOpenMode: 'path to a custom browser to be added to the list of available browsers in Cypress',
124
124
  browserRunMode: 'runs Cypress in the browser with the given name. if a filesystem path is supplied, Cypress will attempt to use the browser at that path.',
125
125
  cacheClear: 'delete all cached binaries',
126
+ cachePrune: 'deletes all cached binaries except for the version currently in use',
126
127
  cacheList: 'list cached binary versions',
127
128
  cachePath: 'print the path to the binary cache',
129
+ cacheSize: 'Used with the list command to show the sizes of the cached folders',
128
130
  ciBuildId: 'the unique identifier for a run on your CI provider. typically a "BUILD_ID" env var. this value is automatically detected for most CI providers',
129
131
  config: 'sets configuration values. separate multiple values with a comma. overrides any value in cypress.json.',
130
132
  configFile: 'path to JSON file where configuration values are set. defaults to "cypress.json". pass "false" to disable.',
@@ -299,7 +301,7 @@ module.exports = {
299
301
 
300
302
  require('./tasks/verify').start(options)["catch"](util.logErrorExit1);
301
303
  });
302
- program.command('cache').usage('[command]').description('Manages the Cypress binary cache').option('list', text('cacheList')).option('path', text('cachePath')).option('clear', text('cacheClear')).action(function (opts, args) {
304
+ program.command('cache').usage('[command]').description('Manages the Cypress binary cache').option('list', text('cacheList')).option('path', text('cachePath')).option('clear', text('cacheClear')).option('prune', text('cachePrune')).option('--size', text('cacheSize')).action(function (opts, args) {
303
305
  if (!args || !args.length) {
304
306
  this.outputHelp();
305
307
  util.exit(1);
@@ -308,10 +310,15 @@ module.exports = {
308
310
  var _args = _slicedToArray(args, 1),
309
311
  command = _args[0];
310
312
 
311
- if (!_.includes(['list', 'path', 'clear'], command)) {
313
+ if (!_.includes(['list', 'path', 'clear', 'prune'], command)) {
312
314
  unknownOption.call(this, "cache ".concat(command), 'command');
313
315
  }
314
316
 
317
+ if (command === 'list') {
318
+ cache.list(opts.size);
319
+ return;
320
+ }
321
+
315
322
  cache[command]();
316
323
  });
317
324
  program.command('info').usage('[command]').description('Prints Cypress and system information').option('--dev', text('dev'), coerceFalse).action(function (opts) {
@@ -1,5 +1,11 @@
1
1
  "use strict";
2
2
 
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
6
+
7
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
+
3
9
  var state = require('./state');
4
10
 
5
11
  var logger = require('../logger');
@@ -17,13 +23,18 @@ var moment = require('moment');
17
23
 
18
24
  var chalk = require('chalk');
19
25
 
20
- var _ = require('lodash'); // output colors for the table
26
+ var _ = require('lodash');
27
+
28
+ var getFolderSize = require('./get-folder-size');
29
+
30
+ var Bluebird = require('bluebird'); // output colors for the table
21
31
 
22
32
 
23
33
  var colors = {
24
34
  titles: chalk.white,
25
35
  dates: chalk.cyan,
26
- values: chalk.green
36
+ values: chalk.green,
37
+ size: chalk.gray
27
38
  };
28
39
 
29
40
  var logCachePath = function logCachePath() {
@@ -34,27 +45,69 @@ var logCachePath = function logCachePath() {
34
45
  var clear = function clear() {
35
46
  return fs.removeAsync(state.getCacheDir());
36
47
  };
48
+
49
+ var prune = function prune() {
50
+ var cacheDir = state.getCacheDir();
51
+ var currentVersion = util.pkgVersion();
52
+ var deletedBinary = false;
53
+ return fs.readdirAsync(cacheDir).then(function (versions) {
54
+ return Bluebird.all(versions.map(function (version) {
55
+ if (version !== currentVersion) {
56
+ deletedBinary = true;
57
+ var versionDir = join(cacheDir, version);
58
+ return fs.removeAsync(versionDir);
59
+ }
60
+ }));
61
+ }).then(function () {
62
+ if (deletedBinary) {
63
+ logger.always("Deleted all binary caches except for the ".concat(currentVersion, " binary cache."));
64
+ } else {
65
+ logger.always("No binary caches found to prune.");
66
+ }
67
+ })["catch"]({
68
+ code: 'ENOENT'
69
+ }, function () {
70
+ logger.always("No Cypress cache was found at ".concat(cacheDir, ". Nothing to prune."));
71
+ });
72
+ };
73
+
74
+ var fileSizeInMB = function fileSizeInMB(size) {
75
+ return "".concat((size / 1024 / 1024).toFixed(1), "MB");
76
+ };
37
77
  /**
38
78
  * Collects all cached versions, finds when each was used
39
79
  * and prints a table with results to the terminal
40
80
  */
41
81
 
42
82
 
43
- var list = function list() {
44
- return getCachedVersions().then(function (binaries) {
83
+ var list = function list(showSize) {
84
+ return getCachedVersions(showSize).then(function (binaries) {
85
+ var head = [colors.titles('version'), colors.titles('last used')];
86
+
87
+ if (showSize) {
88
+ head.push(colors.titles('size'));
89
+ }
90
+
45
91
  var table = new Table({
46
- head: [colors.titles('version'), colors.titles('last used')]
92
+ head: head
47
93
  });
48
94
  binaries.forEach(function (binary) {
49
95
  var versionString = colors.values(binary.version);
50
96
  var lastUsed = binary.accessed ? colors.dates(binary.accessed) : 'unknown';
51
- return table.push([versionString, lastUsed]);
97
+ var row = [versionString, lastUsed];
98
+
99
+ if (showSize) {
100
+ var size = colors.size(fileSizeInMB(binary.size));
101
+ row.push(size);
102
+ }
103
+
104
+ return table.push(row);
52
105
  });
53
106
  logger.always(table.toString());
54
107
  });
55
108
  };
56
109
 
57
- var getCachedVersions = function getCachedVersions() {
110
+ var getCachedVersions = function getCachedVersions(showSize) {
58
111
  var cacheDir = state.getCacheDir();
59
112
  return fs.readdirAsync(cacheDir).filter(util.isSemver).map(function (version) {
60
113
  return {
@@ -82,12 +135,24 @@ var getCachedVersions = function getCachedVersions() {
82
135
  // could not find the binary or gets its stats
83
136
  return binary;
84
137
  });
138
+ }).mapSeries(function (binary) {
139
+ if (showSize) {
140
+ var binaryDir = state.getBinaryDir(binary.version);
141
+ return getFolderSize(binaryDir).then(function (size) {
142
+ return _objectSpread(_objectSpread({}, binary), {}, {
143
+ size: size
144
+ });
145
+ });
146
+ }
147
+
148
+ return binary;
85
149
  });
86
150
  };
87
151
 
88
152
  module.exports = {
89
153
  path: logCachePath,
90
154
  clear: clear,
155
+ prune: prune,
91
156
  list: list,
92
157
  getCachedVersions: getCachedVersions
93
158
  };
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+
3
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
4
+
5
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
6
+
7
+ var fs = require('../fs');
8
+
9
+ var _require = require('path'),
10
+ join = _require.join;
11
+
12
+ var Bluebird = require('bluebird');
13
+ /**
14
+ * Get the size of a folder or a file.
15
+ *
16
+ * This function returns the actual file size of the folder (size), not the allocated space on disk (size on disk).
17
+ * For more details between the difference, check this link:
18
+ * https://www.howtogeek.com/180369/why-is-there-a-big-difference-between-size-and-size-on-disk/
19
+ *
20
+ * @param {string} path path to the file or the folder.
21
+ */
22
+
23
+
24
+ function getSize(_x) {
25
+ return _getSize.apply(this, arguments);
26
+ }
27
+
28
+ function _getSize() {
29
+ _getSize = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(path) {
30
+ var stat, list;
31
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
32
+ while (1) {
33
+ switch (_context2.prev = _context2.next) {
34
+ case 0:
35
+ _context2.next = 2;
36
+ return fs.lstat(path);
37
+
38
+ case 2:
39
+ stat = _context2.sent;
40
+
41
+ if (!stat.isDirectory()) {
42
+ _context2.next = 8;
43
+ break;
44
+ }
45
+
46
+ _context2.next = 6;
47
+ return fs.readdir(path);
48
+
49
+ case 6:
50
+ list = _context2.sent;
51
+ return _context2.abrupt("return", Bluebird.resolve(list).reduce( /*#__PURE__*/function () {
52
+ var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(prev, curr) {
53
+ var currPath, s;
54
+ return regeneratorRuntime.wrap(function _callee$(_context) {
55
+ while (1) {
56
+ switch (_context.prev = _context.next) {
57
+ case 0:
58
+ currPath = join(path, curr);
59
+ _context.next = 3;
60
+ return fs.lstat(currPath);
61
+
62
+ case 3:
63
+ s = _context.sent;
64
+
65
+ if (!s.isDirectory()) {
66
+ _context.next = 10;
67
+ break;
68
+ }
69
+
70
+ _context.t0 = prev;
71
+ _context.next = 8;
72
+ return getSize(currPath);
73
+
74
+ case 8:
75
+ _context.t1 = _context.sent;
76
+ return _context.abrupt("return", _context.t0 + _context.t1);
77
+
78
+ case 10:
79
+ return _context.abrupt("return", prev + s.size);
80
+
81
+ case 11:
82
+ case "end":
83
+ return _context.stop();
84
+ }
85
+ }
86
+ }, _callee);
87
+ }));
88
+
89
+ return function (_x2, _x3) {
90
+ return _ref.apply(this, arguments);
91
+ };
92
+ }(), 0));
93
+
94
+ case 8:
95
+ return _context2.abrupt("return", stat.size);
96
+
97
+ case 9:
98
+ case "end":
99
+ return _context2.stop();
100
+ }
101
+ }
102
+ }, _callee2);
103
+ }));
104
+ return _getSize.apply(this, arguments);
105
+ }
106
+
107
+ module.exports = getSize;
package/lib/util.js CHANGED
@@ -239,7 +239,7 @@ var dequote = function dequote(str) {
239
239
  };
240
240
 
241
241
  var parseOpts = function parseOpts(opts) {
242
- opts = _.pick(opts, 'browser', 'cachePath', 'cacheList', 'cacheClear', 'ciBuildId', 'config', 'configFile', 'cypressVersion', 'destination', 'detached', 'dev', 'exit', 'env', 'force', 'global', 'group', 'headed', 'headless', 'key', 'path', 'parallel', 'port', 'project', 'quiet', 'reporter', 'reporterOptions', 'record', 'spec', 'tag');
242
+ opts = _.pick(opts, 'browser', 'cachePath', 'cacheList', 'cacheClear', 'cachePrune', 'ciBuildId', 'config', 'configFile', 'cypressVersion', 'destination', 'detached', 'dev', 'exit', 'env', 'force', 'global', 'group', 'headed', 'headless', 'key', 'path', 'parallel', 'port', 'project', 'quiet', 'reporter', 'reporterOptions', 'record', 'spec', 'tag');
243
243
 
244
244
  if (opts.exit) {
245
245
  opts = _.omit(opts, 'exit');
@@ -307,7 +307,7 @@ var util = {
307
307
  } // https://github.com/cypress-io/cypress/issues/5431
308
308
 
309
309
 
310
- var NODE_OPTIONS = "--max-http-header-size=".concat(Math.pow(1024, 2), " --http-parser=legacy");
310
+ var NODE_OPTIONS = "--max-http-header-size=".concat(Math.pow(1024, 2));
311
311
 
312
312
  if (_.isString(process.env.NODE_OPTIONS)) {
313
313
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cypress",
3
- "version": "5.3.0",
3
+ "version": "5.4.0",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "postinstall": "node index.js --exec install",
@@ -8,6 +8,7 @@
8
8
 
9
9
  declare namespace CypressCommandLine {
10
10
  type HookName = 'before' | 'beforeEach' | 'afterEach' | 'after'
11
+
11
12
  interface TestError {
12
13
  name: string
13
14
  message: string
@@ -225,7 +226,7 @@ declare namespace CypressCommandLine {
225
226
  startedAt: dateTimeISO
226
227
  endedAt: dateTimeISO
227
228
  duration: ms
228
- },
229
+ }
229
230
  /**
230
231
  * Reporter name like "spec"
231
232
  */
@@ -255,7 +256,7 @@ declare namespace CypressCommandLine {
255
256
  * resolved filename of the spec
256
257
  */
257
258
  absolute: string
258
- },
259
+ }
259
260
  shouldUploadVideo: boolean
260
261
  }
261
262
 
@@ -358,7 +359,7 @@ declare module 'cypress' {
358
359
  })
359
360
  ```
360
361
  */
361
- run(options?: Partial<CypressCommandLine.CypressRunOptions>): Promise<CypressCommandLine.CypressRunResult | CypressCommandLine.CypressFailedRunResult>,
362
+ run(options?: Partial<CypressCommandLine.CypressRunOptions>): Promise<CypressCommandLine.CypressRunResult | CypressCommandLine.CypressFailedRunResult>
362
363
  /**
363
364
  * Opens Cypress GUI. Resolves with void when the
364
365
  * GUI is closed.
@@ -5295,7 +5295,7 @@ declare namespace Cypress {
5295
5295
 
5296
5296
  type Encodings = 'ascii' | 'base64' | 'binary' | 'hex' | 'latin1' | 'utf8' | 'utf-8' | 'ucs2' | 'ucs-2' | 'utf16le' | 'utf-16le'
5297
5297
  type PositionType = 'topLeft' | 'top' | 'topRight' | 'left' | 'center' | 'right' | 'bottomLeft' | 'bottom' | 'bottomRight'
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'
5298
+ type ViewportPreset = 'macbook-15' | 'macbook-13' | 'macbook-11' | 'ipad-2' | 'ipad-mini' | 'iphone-xr' | 'iphone-x' | 'iphone-6+' | 'iphone-se2' | 'iphone-8' | 'iphone-7' | 'iphone-6' | 'iphone-5' | 'iphone-4' | 'iphone-3' | 'samsung-s10' | 'samsung-note9'
5299
5299
  interface Offset {
5300
5300
  top: number
5301
5301
  left: number
@@ -1,8 +1,7 @@
1
- // Type definitions for mocha 5.2
1
+ // Type definitions for mocha 8.0
2
2
  // Project: https://mochajs.org
3
3
  // Definitions by: Kazi Manzur Rashid <https://github.com/kazimanzurrashid>
4
4
  // otiai10 <https://github.com/otiai10>
5
- // jt000 <https://github.com/jt000>
6
5
  // Vadim Macagon <https://github.com/enlight>
7
6
  // Andrew Bradley <https://github.com/cspotcode>
8
7
  // Dmitrii Sorin <https://github.com/1999>
@@ -90,13 +89,6 @@ declare class Mocha {
90
89
  */
91
90
  invert(): this;
92
91
 
93
- /**
94
- * Ignore global leaks.
95
- *
96
- * @see https://mochajs.org/api/mocha#ignoreLeaks
97
- */
98
- ignoreLeaks(ignore: boolean): this;
99
-
100
92
  /**
101
93
  * Enable global leak checking.
102
94
  *
@@ -125,27 +117,6 @@ declare class Mocha {
125
117
  */
126
118
  globals(globals: string | ReadonlyArray<string>): this;
127
119
 
128
- /**
129
- * Emit color output.
130
- *
131
- * @see https://mochajs.org/api/mocha#useColors
132
- */
133
- useColors(colors: boolean): this;
134
-
135
- /**
136
- * Use inline diffs rather than +/-.
137
- *
138
- * @see https://mochajs.org/api/mocha#useInlineDiffs
139
- */
140
- useInlineDiffs(inlineDiffs: boolean): this;
141
-
142
- /**
143
- * Do not show diffs at all.
144
- *
145
- * @see https://mochajs.org/api/mocha#hideDiff
146
- */
147
- hideDiff(hideDiff: boolean): this;
148
-
149
120
  /**
150
121
  * Set the timeout in milliseconds.
151
122
  *
@@ -167,13 +138,6 @@ declare class Mocha {
167
138
  */
168
139
  slow(slow: string | number): this;
169
140
 
170
- /**
171
- * Enable timeouts.
172
- *
173
- * @see https://mochajs.org/api/mocha#enableTimeouts
174
- */
175
- enableTimeouts(enabled?: boolean): this;
176
-
177
141
  /**
178
142
  * Makes all tests async (accepting a callback)
179
143
  *
@@ -231,12 +195,45 @@ declare class Mocha {
231
195
  */
232
196
  run(fn?: (failures: number) => void): Mocha.Runner;
233
197
 
198
+ /**
199
+ * Loads ESM (and CJS) test files asynchronously.
200
+ *
201
+ * @see https://mochajs.org/api/mocha#loadFilesAsync
202
+ */
203
+ loadFilesAsync(): Promise<void>;
204
+
234
205
  /**
235
206
  * Load registered files.
236
207
  *
237
208
  * @see https://mochajs.org/api/mocha#loadFiles
238
209
  */
239
210
  protected loadFiles(fn?: () => void): void;
211
+
212
+ /**
213
+ * Unloads `files` from Node's `require` cache.
214
+ *
215
+ * This allows required files to be "freshly" reloaded, providing the ability
216
+ * to reuse a Mocha instance programmatically.
217
+ * Note: does not clear ESM module files from the cache
218
+ */
219
+ unloadFiles(): this;
220
+
221
+ /**
222
+ * Toggles parallel mode.
223
+ *
224
+ * Must be run before calling `run`. Changes the `Runner` class to
225
+ * use; also enables lazy file loading if not already done so.
226
+ *
227
+ * @see https://mochajs.org/api/mocha#parallelMode
228
+ */
229
+ parallelMode(enabled?: boolean): this;
230
+
231
+ /**
232
+ * Assigns hooks to the root suite.
233
+ *
234
+ * @see https://mochajs.org/api/mocha#rootHooks
235
+ */
236
+ rootHooks(hooks: Mocha.RootHookObject): this;
240
237
  }
241
238
 
242
239
  declare namespace Mocha {
@@ -684,8 +681,6 @@ declare namespace Mocha {
684
681
  */
685
682
  class Base {
686
683
  constructor(runner: Runner, options?: MochaOptions);
687
- /** @deprecated Use the overload that accepts `Mocha.Runner` instead. */
688
- constructor(runner: IRunner, options?: MochaOptions);
689
684
 
690
685
  /**
691
686
  * Test run statistics
@@ -974,8 +969,6 @@ declare namespace Mocha {
974
969
  */
975
970
  class XUnit extends Base {
976
971
  constructor(runner: Runner, options?: XUnit.MochaOptions);
977
- /** @deprecated Use the overload that accepts `Mocha.Runner` instead. */
978
- constructor(runner: IRunner, options?: XUnit.MochaOptions);
979
972
 
980
973
  /**
981
974
  * Override done to close the stream (if it's a file).
@@ -1025,8 +1018,6 @@ declare namespace Mocha {
1025
1018
  */
1026
1019
  class Progress extends Base {
1027
1020
  constructor(runner: Runner, options?: Progress.MochaOptions);
1028
- /** @deprecated Use the overload that accepts `Mocha.Runner` instead. */
1029
- constructor(runner: IRunner, options?: Progress.MochaOptions);
1030
1021
  }
1031
1022
 
1032
1023
  namespace Progress {
@@ -1084,7 +1075,6 @@ declare namespace Mocha {
1084
1075
  */
1085
1076
  class Runnable {
1086
1077
  private _slow;
1087
- private _enableTimeouts;
1088
1078
  private _retries;
1089
1079
  private _currentRetry;
1090
1080
  private _timeout;
@@ -1136,20 +1126,6 @@ declare namespace Mocha {
1136
1126
  */
1137
1127
  slow(ms: string | number): this;
1138
1128
 
1139
- /**
1140
- * Get whether timeouts are enabled.
1141
- *
1142
- * @see https://mochajs.org/api/Runnable.html#enableTimeouts
1143
- */
1144
- enableTimeouts(): boolean;
1145
-
1146
- /**
1147
- * Set whether timeouts are enabled.
1148
- *
1149
- * @see https://mochajs.org/api/Runnable.html#enableTimeouts
1150
- */
1151
- enableTimeouts(enabled: boolean): this;
1152
-
1153
1129
  /**
1154
1130
  * Halt and mark as pending.
1155
1131
  */
@@ -1296,8 +1272,6 @@ declare namespace Mocha {
1296
1272
  * Set the context `Runnable`.
1297
1273
  */
1298
1274
  runnable(runnable: Runnable): this;
1299
- /** @deprecated Use the overload that accepts `Mocha.Runnable` instead. */
1300
- runnable(runnable: IRunnable): this;
1301
1275
 
1302
1276
  /**
1303
1277
  * Get test timeout.
@@ -1309,16 +1283,6 @@ declare namespace Mocha {
1309
1283
  */
1310
1284
  timeout(ms: string | number): this;
1311
1285
 
1312
- /**
1313
- * Get whether timeouts are enabled.
1314
- */
1315
- enableTimeouts(): boolean;
1316
-
1317
- /**
1318
- * Set whether timeouts are enabled.
1319
- */
1320
- enableTimeouts(enabled: boolean): this;
1321
-
1322
1286
  /**
1323
1287
  * Get test slowness threshold.
1324
1288
  */
@@ -1347,6 +1311,23 @@ declare namespace Mocha {
1347
1311
  [key: string]: any;
1348
1312
  }
1349
1313
 
1314
+ interface RunnerConstants {
1315
+ readonly EVENT_HOOK_BEGIN: 'hook';
1316
+ readonly EVENT_HOOK_END: 'hook end';
1317
+ readonly EVENT_RUN_BEGIN: 'start';
1318
+ readonly EVENT_DELAY_BEGIN: 'waiting';
1319
+ readonly EVENT_DELAY_END: 'ready';
1320
+ readonly EVENT_RUN_END: 'end';
1321
+ readonly EVENT_SUITE_BEGIN: 'suite';
1322
+ readonly EVENT_SUITE_END: 'suite end';
1323
+ readonly EVENT_TEST_BEGIN: 'test';
1324
+ readonly EVENT_TEST_END: 'test end';
1325
+ readonly EVENT_TEST_FAIL: 'fail';
1326
+ readonly EVENT_TEST_PASS: 'pass';
1327
+ readonly EVENT_TEST_PENDING: 'pending';
1328
+ readonly EVENT_TEST_RETRY: 'retry';
1329
+ }
1330
+
1350
1331
  /**
1351
1332
  * Initialize a `Runner` for the given `suite`.
1352
1333
  *
@@ -1362,10 +1343,9 @@ declare namespace Mocha {
1362
1343
  private prevGlobalsLength;
1363
1344
  private nextSuite;
1364
1345
 
1365
- constructor(suite: Suite, delay: boolean);
1346
+ static readonly constants: RunnerConstants;
1366
1347
 
1367
- /** @deprecated Use the overload that accepts `Mocha.Suite` instead. */
1368
- constructor(suite: ISuite, delay: boolean);
1348
+ constructor(suite: Suite, delay: boolean);
1369
1349
 
1370
1350
  suite: Suite;
1371
1351
  started: boolean;
@@ -1376,7 +1356,7 @@ declare namespace Mocha {
1376
1356
  fullStackTrace?: boolean;
1377
1357
  forbidOnly?: boolean;
1378
1358
  forbidPending?: boolean;
1379
- ignoreLeaks?: boolean;
1359
+ checkLeaks?: boolean;
1380
1360
  test?: Test;
1381
1361
  currentRunnable?: Runnable;
1382
1362
  stats?: Stats; // added by reporters
@@ -1397,9 +1377,6 @@ declare namespace Mocha {
1397
1377
  */
1398
1378
  grepTotal(suite: Suite): number;
1399
1379
 
1400
- /** @deprecated Use the overload that accepts `Mocha.Suite` instead. */
1401
- grepTotal(suite: ISuite): number;
1402
-
1403
1380
  /**
1404
1381
  * Gets the allowed globals.
1405
1382
  *
@@ -1683,6 +1660,25 @@ declare namespace Mocha {
1683
1660
  }
1684
1661
  // #endregion Runner untyped events
1685
1662
 
1663
+ interface SuiteConstants {
1664
+ readonly EVENT_FILE_POST_REQUIRE: 'post-require';
1665
+ readonly EVENT_FILE_PRE_REQUIRE: 'pre-require';
1666
+ readonly EVENT_FILE_REQUIRE: 'require';
1667
+ readonly EVENT_ROOT_SUITE_RUN: 'run';
1668
+
1669
+ readonly HOOK_TYPE_AFTER_ALL: 'afterAll';
1670
+ readonly HOOK_TYPE_AFTER_EACH: 'afterEach';
1671
+ readonly HOOK_TYPE_BEFORE_ALL: 'beforeAll';
1672
+ readonly HOOK_TYPE_BEFORE_EACH: 'beforeEach';
1673
+
1674
+ readonly EVENT_SUITE_ADD_HOOK_AFTER_ALL: 'afterAll';
1675
+ readonly EVENT_SUITE_ADD_HOOK_AFTER_EACH: 'afterEach';
1676
+ readonly EVENT_SUITE_ADD_HOOK_BEFORE_ALL: 'beforeAll';
1677
+ readonly EVENT_SUITE_ADD_HOOK_BEFORE_EACH: 'beforeEach';
1678
+ readonly EVENT_SUITE_ADD_SUITE: 'suite';
1679
+ readonly EVENT_SUITE_ADD_TEST: 'test';
1680
+ }
1681
+
1686
1682
  /**
1687
1683
  * Initialize a new `Suite` with the given `title` and `ctx`.
1688
1684
  *
@@ -1694,16 +1690,15 @@ declare namespace Mocha {
1694
1690
  private _afterEach;
1695
1691
  private _afterAll;
1696
1692
  private _timeout;
1697
- private _enableTimeouts;
1698
1693
  private _slow;
1699
1694
  private _bail;
1700
1695
  private _retries;
1701
1696
  private _onlyTests;
1702
1697
  private _onlySuites;
1703
1698
 
1699
+ static readonly constants: SuiteConstants;
1700
+
1704
1701
  constructor(title: string, parentContext?: Context);
1705
- /** @deprecated Use the overload that accepts `Mocha.Context` instead. */
1706
- constructor(title: string, parentContext?: IContext);
1707
1702
 
1708
1703
  ctx: Context;
1709
1704
  suites: Suite[];
@@ -1723,8 +1718,6 @@ declare namespace Mocha {
1723
1718
  * @see https://mochajs.org/api/mocha#.exports.create
1724
1719
  */
1725
1720
  static create(parent: Suite, title: string): Suite;
1726
- /** @deprecated Use the overload that accepts `Mocha.Suite` instead. */
1727
- static create(parent: ISuite, title: string): Suite;
1728
1721
 
1729
1722
  /**
1730
1723
  * Return a clone of this `Suite`.
@@ -1761,20 +1754,6 @@ declare namespace Mocha {
1761
1754
  */
1762
1755
  retries(n: string | number): this;
1763
1756
 
1764
- /**
1765
- * Get whether timeouts are enabled.
1766
- *
1767
- * @see https://mochajs.org/api/Mocha.Suite.html#enableTimeouts
1768
- */
1769
- enableTimeouts(): boolean;
1770
-
1771
- /**
1772
- * Set whether timeouts are `enabled`.
1773
- *
1774
- * @see https://mochajs.org/api/Mocha.Suite.html#enableTimeouts
1775
- */
1776
- enableTimeouts(enabled: boolean): this;
1777
-
1778
1757
  /**
1779
1758
  * Get slow `ms`.
1780
1759
  *
@@ -1928,8 +1907,6 @@ declare namespace Mocha {
1928
1907
  * @see https://mochajs.org/api/Mocha.Suite.html#addSuite
1929
1908
  */
1930
1909
  addSuite(suite: Suite): this;
1931
- /** @deprecated Use the overload that accepts `Mocha.ISuite` instead. */
1932
- addSuite(suite: ISuite): this;
1933
1910
 
1934
1911
  /**
1935
1912
  * Add a `test` to this suite.
@@ -1937,8 +1914,6 @@ declare namespace Mocha {
1937
1914
  * @see https://mochajs.org/api/Mocha.Suite.html#addTest
1938
1915
  */
1939
1916
  addTest(test: Test): this;
1940
- /** @deprecated Use the overload that accepts `Mocha.ITest` instead. */
1941
- addTest(test: ITest): this;
1942
1917
 
1943
1918
  /**
1944
1919
  * Return the full title generated by recursively concatenating the parent's
@@ -2132,6 +2107,37 @@ declare namespace Mocha {
2132
2107
  error(err: any): void;
2133
2108
  }
2134
2109
 
2110
+ /**
2111
+ * An alternative way to define root hooks that works with parallel runs.
2112
+ *
2113
+ * Root hooks work with any interface, but the property names do not change.
2114
+ * In other words, if you are using the tdd interface, suiteSetup maps to beforeAll, and setup maps to beforeEach.
2115
+ *
2116
+ * As with other hooks, `this` refers to to the current context object.
2117
+ *
2118
+ * @see https://mochajs.org/#root-hook-plugins
2119
+ */
2120
+ interface RootHookObject {
2121
+ /**
2122
+ * In serial mode, run after all tests end, once only.
2123
+ * In parallel mode, run after all tests end, for each file.
2124
+ */
2125
+ afterAll?: Func | AsyncFunc | Func[] | AsyncFunc[];
2126
+ /**
2127
+ * In serial mode (Mocha's default), before all tests begin, once only.
2128
+ * In parallel mode, run before all tests begin, for each file.
2129
+ */
2130
+ beforeAll?: Func | AsyncFunc | Func[] | AsyncFunc[];
2131
+ /**
2132
+ * In both modes, run after every test.
2133
+ */
2134
+ afterEach?: Func | AsyncFunc | Func[] | AsyncFunc[];
2135
+ /**
2136
+ * In both modes, run before each test.
2137
+ */
2138
+ beforeEach?: Func | AsyncFunc | Func[] | AsyncFunc[];
2139
+ }
2140
+
2135
2141
  /**
2136
2142
  * Initialize a new `Test` with the given `title` and callback `fn`.
2137
2143
  *
@@ -2195,10 +2201,8 @@ declare namespace Mocha {
2195
2201
  /** Array of accepted globals. */
2196
2202
  globals?: string[];
2197
2203
 
2198
- /** timeout in milliseconds. */
2199
- timeout?: number;
2200
-
2201
- enableTimeouts?: boolean;
2204
+ /** timeout in milliseconds or time string like '1s'. */
2205
+ timeout?: number | string;
2202
2206
 
2203
2207
  /** number of times to retry failed tests. */
2204
2208
  retries?: number;
@@ -2209,8 +2213,8 @@ declare namespace Mocha {
2209
2213
  /** milliseconds to wait before considering a test slow. */
2210
2214
  slow?: number;
2211
2215
 
2212
- /** ignore global leaks. */
2213
- ignoreLeaks?: boolean;
2216
+ /** check for global variable leaks. */
2217
+ checkLeaks?: boolean;
2214
2218
 
2215
2219
  /** display the full stack trace on failure. */
2216
2220
  fullStackTrace?: boolean;
@@ -2221,8 +2225,8 @@ declare namespace Mocha {
2221
2225
  /** Enable growl support. */
2222
2226
  growl?: boolean;
2223
2227
 
2224
- /** Emit color output. */
2225
- useColors?: boolean;
2228
+ /** Color TTY output from reporter */
2229
+ color?: boolean;
2226
2230
 
2227
2231
  /** Use inline diffs rather than +/-. */
2228
2232
  inlineDiffs?: boolean;
@@ -2230,12 +2234,22 @@ declare namespace Mocha {
2230
2234
  /** Do not show diffs at all. */
2231
2235
  hideDiff?: boolean;
2232
2236
 
2237
+ /** Run job in parallel */
2238
+ parallel?: boolean;
2239
+
2240
+ /** Max number of worker processes for parallel runs */
2241
+ jobs?: number;
2242
+
2243
+ /** Assigns hooks to the root suite */
2244
+ rootHooks?: RootHookObject;
2245
+
2233
2246
  asyncOnly?: boolean;
2234
2247
  delay?: boolean;
2235
2248
  forbidOnly?: boolean;
2236
2249
  forbidPending?: boolean;
2237
2250
  noHighlighting?: boolean;
2238
2251
  allowUncaught?: boolean;
2252
+ fullTrace?: boolean;
2239
2253
  }
2240
2254
 
2241
2255
  interface MochaInstanceOptions extends MochaOptions {
@@ -2440,186 +2454,6 @@ declare namespace Mocha {
2440
2454
  }
2441
2455
 
2442
2456
  type Interface = keyof InterfaceContributions;
2443
-
2444
- // #region Deprecations
2445
-
2446
- /** @deprecated use `Mocha.Context` instead. */
2447
- interface IContext {
2448
- test?: IRunnable;
2449
- runnable(): IRunnable | undefined;
2450
- /** @deprecated `.runnable()` returns `this` in `Mocha.Context`. */
2451
- runnable(runnable: IRunnable): IContext;
2452
- timeout(): number;
2453
- /** @deprecated `.timeout()` returns `this` in `Mocha.Context`. */
2454
- timeout(timeout: number): IContext;
2455
- /** @deprecated `.enableTimeouts()` has additional overloads in `Mocha.Context`. */
2456
- /** @deprecated `.enableTimeouts()` returns `this` in `Mocha.Context`. */
2457
- enableTimeouts(enableTimeouts: boolean): IContext;
2458
- /** @deprecated `.slow()` has additional overloads in `Mocha.Context`. */
2459
- /** @deprecated `.slow()` returns `this` in `Mocha.Context`. */
2460
- slow(slow: number): IContext;
2461
- /** @deprecated `.skip()` returns `never` in `Mocha.Context`. */
2462
- skip(): IContext;
2463
- retries(): number;
2464
- /** @deprecated `.retries()` returns `this` in `Mocha.Context`. */
2465
- retries(retries: number): IContext;
2466
- }
2467
-
2468
- /** @deprecated use `Mocha.Suite` instead. */
2469
- interface ISuiteCallbackContext {
2470
- /** @deprecated `.timeout()` has additional overloads in `Mocha.Suite`. */
2471
- timeout(ms: number | string): this;
2472
- /** @deprecated `.retries()` has additional overloads in `Mocha.Suite`. */
2473
- retries(n: number): this;
2474
- /** @deprecated `.slow()` has additional overloads in `Mocha.Suite`. */
2475
- slow(ms: number): this;
2476
- }
2477
-
2478
- /** @deprecated use `Mocha.Context` instead. */
2479
- interface IHookCallbackContext {
2480
- /** @deprecated `.skip()` returns `never` in `Mocha.Context`. */
2481
- skip(): this;
2482
- /** @deprecated `.timeout()` has additional overloads in `Mocha.Context`. */
2483
- timeout(ms: number | string): this;
2484
- [index: string]: any;
2485
- }
2486
-
2487
- /** @deprecated use `Mocha.Context` instead. */
2488
- interface ITestCallbackContext {
2489
- /** @deprecated `.skip()` returns `never` in `Mocha.Context`. */
2490
- skip(): this;
2491
- /** @deprecated `.timeout()` has additional overloads in `Mocha.Context`. */
2492
- timeout(ms: number | string): this;
2493
- /** @deprecated `.retries()` has additional overloads in `Mocha.Context`. */
2494
- retries(n: number): this;
2495
- /** @deprecated `.slow()` has additional overloads in `Mocha.Context`. */
2496
- slow(ms: number): this;
2497
- [index: string]: any;
2498
- }
2499
-
2500
- /** Partial interface for Mocha's `Runnable` class. */
2501
- /** @deprecated use `Mocha.Runnable` instead. */
2502
- interface IRunnable extends NodeJS.EventEmitter {
2503
- title: string;
2504
- /** @deprecated `.fn` has type `Func | AsyncFunc` in `Mocha.Runnable`. */
2505
- fn: Function | undefined;
2506
- async: boolean;
2507
- sync: boolean;
2508
- timedOut: boolean;
2509
- /** @deprecated `.timeout()` has additional overloads in `Mocha.Runnable`. */
2510
- timeout(n: number | string): this;
2511
- duration?: number;
2512
- }
2513
-
2514
- /** Partial interface for Mocha's `Suite` class. */
2515
- /** @deprecated use `Mocha.Suite` instead. */
2516
- interface ISuite {
2517
- /** @deprecated `.ctx` has type `Mocha.Context` in `Mocha.Suite`. */
2518
- ctx: IContext;
2519
- /** @deprecated `.parent` has type `Mocha.Suite | undefined` in `Mocha.Suite`. */
2520
- parent: ISuite | undefined;
2521
- root: boolean;
2522
- title: string;
2523
- /** @deprecated `.suites` has type `Mocha.Suite[]` in `Mocha.Suite`. */
2524
- suites: ISuite[];
2525
- /** @deprecated `.tests` has type `Mocha.Test[]` in `Mocha.Suite`. */
2526
- tests: ITest[];
2527
-
2528
- bail(): boolean;
2529
- /** @deprecated `.bail()` returns `this` in `Mocha.Suite`. */
2530
- bail(bail: boolean): ISuite;
2531
- fullTitle(): string;
2532
- retries(): number;
2533
- /** @deprecated `.retries()` returns `this` in `Mocha.Suite`. */
2534
- retries(retries: number): ISuite;
2535
- slow(): number;
2536
- /** @deprecated `.slow()` returns `this` in `Mocha.Suite`. */
2537
- slow(slow: number): ISuite;
2538
- timeout(): number;
2539
- /** @deprecated `.timeout()` returns `this` in `Mocha.Suite`. */
2540
- timeout(timeout: number): ISuite;
2541
- }
2542
-
2543
- /** Partial interface for Mocha's `Test` class. */
2544
- /** @deprecated use `Mocha.Test` instead. */
2545
- interface ITest extends IRunnable {
2546
- body?: string;
2547
- file?: string;
2548
- /** @deprecated `.parent` has type `Mocha.Suite | undefined` in `Mocha.Test`. */
2549
- parent?: ISuite;
2550
- pending: boolean;
2551
- state?: 'failed' | 'passed';
2552
- type: 'test';
2553
- fullTitle(): string;
2554
- }
2555
-
2556
- /** @deprecated use `Mocha.Hook` instead. */
2557
- interface IHook extends IRunnable {
2558
- /** @deprecated `.ctx` has type `Mocha.Context` in `Mocha.Runnable`. */
2559
- ctx?: IContext;
2560
- /** @deprecated `.parent` has type `Mocha.Suite` in `Mocha.Runnable`. */
2561
- parent?: ISuite;
2562
- type: 'hook';
2563
- /** @deprecated `.error()` has additional overloads in `Mocha.Hook`. */
2564
- error(err: Error): void;
2565
- }
2566
-
2567
- /** @deprecated use `Mocha.Context` instead. */
2568
- interface IBeforeAndAfterContext extends IHookCallbackContext {
2569
- /** @deprecated `.currentTest` has type `Mocha.Test` in `Mocha.Context`. */
2570
- currentTest?: ITest;
2571
- }
2572
-
2573
- /** @deprecated use `Mocha.Stats` instead. */
2574
- type IStats = Stats;
2575
-
2576
- /** Partial interface for Mocha's `Runner` class. */
2577
- /** @deprecated use `Mocha.Runner` instead. */
2578
- interface IRunner extends NodeJS.EventEmitter {
2579
- asyncOnly?: boolean;
2580
- stats?: IStats;
2581
- started: boolean;
2582
- /** @deprecated `.suite` has type `Mocha.Suite` in `Mocha.Runner`. */
2583
- suite: ISuite;
2584
- total: number;
2585
- failures: number;
2586
- forbidOnly?: boolean;
2587
- forbidPending?: boolean;
2588
- fullStackTrace?: boolean;
2589
- ignoreLeaks?: boolean;
2590
- grep(re: RegExp, invert: boolean): this;
2591
- /** @deprecated Parameter `suite` has type `Mocha.Suite` in `Mocha.Runner`. */
2592
- grepTotal(suite: ISuite): number;
2593
- /** @deprecated `.globals()` has different overloads in `Mocha.Runner`. */
2594
- globals(arr: ReadonlyArray<string>): this | string[];
2595
- abort(): this;
2596
- run(fn?: (failures: number) => void): this;
2597
- }
2598
-
2599
- /** @deprecated use `Mocha.SuiteFunction` instead. */
2600
- interface IContextDefinition {
2601
- /** @deprecated use `Mocha.SuiteFunction` instead. */
2602
- (description: string, callback: (this: ISuiteCallbackContext) => void): ISuite;
2603
- /** @deprecated use `Mocha.SuiteFunction` instead. */
2604
- only(description: string, callback: (this: ISuiteCallbackContext) => void): ISuite;
2605
- /** @deprecated use `Mocha.SuiteFunction` instead. */
2606
- skip(description: string, callback: (this: ISuiteCallbackContext) => void): void;
2607
- }
2608
-
2609
- /** @deprecated use `Mocha.TestFunction` instead. */
2610
- interface ITestDefinition {
2611
- /** @deprecated use `Mocha.TestFunction` instead. */
2612
- /** @deprecated `Mocha.TestFunction` does not allow mixing `done` with a return type of `PromiseLike<any>`. */
2613
- (expectation: string, callback?: (this: ITestCallbackContext, done: MochaDone) => PromiseLike<any> | void): ITest;
2614
- /** @deprecated use `Mocha.TestFunction` instead. */
2615
- /** @deprecated `Mocha.TestFunction#only` does not allow mixing `done` with a return type of `PromiseLike<any>`. */
2616
- only(expectation: string, callback?: (this: ITestCallbackContext, done: MochaDone) => PromiseLike<any> | void): ITest;
2617
- /** @deprecated use `Mocha.TestFunction` instead. */
2618
- /** @deprecated `Mocha.TestFunction#skip` does not allow mixing `done` with a return type of `PromiseLike<any>`. */
2619
- skip(expectation: string, callback?: (this: ITestCallbackContext, done: MochaDone) => PromiseLike<any> | void): void;
2620
- }
2621
-
2622
- // #endregion
2623
2457
  }
2624
2458
 
2625
2459
  // #region Test interface augmentations
@@ -2828,30 +2662,11 @@ interface BrowserMocha extends Mocha {
2828
2662
  *
2829
2663
  * - _Only supported in the browser._
2830
2664
  */
2831
- setup(opts?: Mocha.Interface | MochaSetupOptions): this;
2832
- }
2833
-
2834
- /**
2835
- * Options to pass to `mocha.setup` in the browser.
2836
- */
2837
- interface MochaSetupOptions extends Mocha.MochaOptions {
2838
- /** @deprecated This is not used by Mocha. Use `files` instead. */
2839
- require?: string[];
2840
- fullTrace?: boolean;
2665
+ setup(opts?: Mocha.Interface | Mocha.MochaOptions): this;
2841
2666
  }
2842
2667
 
2843
2668
  // #endregion Browser augmentations
2844
2669
 
2845
- // #region Deprecations
2846
-
2847
- /** @deprecated use `Mocha.Done` instead. */
2848
- type MochaDone = Mocha.Done;
2849
-
2850
- /** @deprecated use `Mocha.ReporterConstructor` instead. */
2851
- type ReporterConstructor = Mocha.ReporterConstructor;
2852
-
2853
- // #endregion Deprecations
2854
-
2855
2670
  declare module "mocha" {
2856
2671
  export = Mocha;
2857
2672
  }
@@ -3,7 +3,6 @@
3
3
  */
4
4
  export namespace CyHttpMessages {
5
5
  interface BaseMessage {
6
- // as much stuff from `incomingmessage` as makes sense to serialize and send
7
6
  body?: any
8
7
  headers: { [key: string]: string }
9
8
  url: string
@@ -47,11 +46,31 @@ export namespace CyHttpMessages {
47
46
  }
48
47
 
49
48
  export interface IncomingHttpRequest extends IncomingRequest {
49
+ /**
50
+ * Destroy the request and respond with a network error.
51
+ */
50
52
  destroy(): void
53
+ /**
54
+ * Control the response to this request.
55
+ * If a function is passed, the request will be sent outgoing, and the function will be called
56
+ * with the response from the upstream server.
57
+ * If a `StaticResponse` is passed, it will be used as the response, and no request will be made
58
+ * to the upstream server.
59
+ */
51
60
  reply(interceptor?: StaticResponse | HttpResponseInterceptor): void
61
+ /**
62
+ * Shortcut to reply to the request with a body and optional headers.
63
+ */
52
64
  reply(body: string | object, headers?: { [key: string]: string }): void
65
+ /**
66
+ * Shortcut to reply to the request with an HTTP status code and optional body and headers.
67
+ */
53
68
  reply(status: number, body?: string | object, headers?: { [key: string]: string }): void
54
- redirect(location: string, statusCode: number): void
69
+ /**
70
+ * Respond to this request with a redirect to a new `location`.
71
+ * @param statusCode HTTP status code to redirect with. Default: 302
72
+ */
73
+ redirect(location: string, statusCode?: number): void
55
74
  }
56
75
  }
57
76
 
@@ -64,9 +83,19 @@ export interface DictMatcher<T> {
64
83
  */
65
84
  export type GlobPattern = string
66
85
 
86
+ /**
87
+ * Interceptor for an HTTP request. If a Promise is returned, it will be awaited before passing the
88
+ * request to the next handler (if there is one), otherwise the request will be passed to the next
89
+ * handler synchronously.
90
+ */
67
91
  export type HttpRequestInterceptor = (req: CyHttpMessages.IncomingHttpRequest) => void | Promise<void>
68
92
 
69
- export type HttpResponseInterceptor = (res: CyHttpMessages.IncomingHttpResponse, send?: () => void) => void | Promise<void>
93
+ /**
94
+ * Interceptor for an HTTP response. If a Promise is returned, it will be awaited before passing the
95
+ * request to the next handler (if there is one), otherwise the request will be passed to the next
96
+ * handler synchronously.
97
+ */
98
+ export type HttpResponseInterceptor = (res: CyHttpMessages.IncomingHttpResponse) => void | Promise<void>
70
99
 
71
100
  /**
72
101
  * Matches a single number or any of an array of acceptable numbers.
@@ -130,22 +159,24 @@ export type RouteMatcherOptions = RouteMatcherOptionsGeneric<StringMatcher>
130
159
 
131
160
  export interface RouteMatcherOptionsGeneric<S> extends RouteMatcherCompatOptions {
132
161
  /**
133
- * Match HTTP basic authentication.
162
+ * Match against the username and password used in HTTP Basic authentication.
134
163
  */
135
164
  auth?: { username: S, password: S }
136
165
  /**
137
- * Match client request headers.
166
+ * Match against HTTP headers on the request.
138
167
  */
139
168
  headers?: DictMatcher<S>
140
169
  /**
141
- * Match based on requested hostname.
170
+ * Match against the requested HTTP hostname.
142
171
  */
143
172
  hostname?: S
144
173
  /**
145
- * Match requests served via HTTPS only.
174
+ * If 'true', only HTTPS requests will be matched.
175
+ * If 'false', only HTTP requests will be matched.
146
176
  */
147
177
  https?: boolean
148
178
  /**
179
+ * Match against the request's HTTP method.
149
180
  * @default 'GET'
150
181
  */
151
182
  method?: S
@@ -158,7 +189,8 @@ export interface RouteMatcherOptionsGeneric<S> extends RouteMatcherCompatOptions
158
189
  */
159
190
  pathname?: S
160
191
  /**
161
- * Match based on requested port.
192
+ * Match based on requested port, or pass an array of ports
193
+ * to match against any in that array.
162
194
  */
163
195
  port?: NumberMatcher
164
196
  /**
@@ -166,7 +198,9 @@ export interface RouteMatcherOptionsGeneric<S> extends RouteMatcherCompatOptions
166
198
  */
167
199
  query?: DictMatcher<S>
168
200
  /**
169
- * Match based on full request URL.
201
+ * Match against the full request URL.
202
+ * If a string is passed, it will be used as a substring match,
203
+ * not an equality match.
170
204
  */
171
205
  url?: S
172
206
  }
@@ -180,34 +214,38 @@ export type RouteHandler = string | StaticResponse | RouteHandlerController | ob
180
214
  */
181
215
  export type StaticResponse = GenericStaticResponse<string, string | object> & {
182
216
  /**
183
- * If set, `delayMs` will pass before the response is sent.
184
- */
217
+ * Milliseconds to delay before the response is sent.
218
+ */
185
219
  delayMs?: number
186
220
  }
187
221
 
188
222
  export interface GenericStaticResponse<Fixture, Body> {
189
223
  /**
190
- * If set, serve a fixture as the response body.
224
+ * Serve a fixture as the response body.
191
225
  */
192
226
  fixture?: Fixture
193
227
  /**
194
- * If set, serve a static string/JSON object as the response body.
228
+ * Serve a static string/JSON object as the response body.
195
229
  */
196
230
  body?: Body
197
231
  /**
232
+ * HTTP headers to accompany the response.
198
233
  * @default {}
199
234
  */
200
235
  headers?: { [key: string]: string }
201
236
  /**
237
+ * The HTTP status code to send.
202
238
  * @default 200
203
239
  */
204
240
  statusCode?: number
205
241
  /**
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.
242
+ * If 'forceNetworkError' is truthy, Cypress will destroy the browser connection
243
+ * and send no response. Useful for simulating a server that is not reachable.
244
+ * Must not be set in combination with other options.
207
245
  */
208
246
  forceNetworkError?: boolean
209
247
  /**
210
- * If set, the `body` will be sent at `throttleKbps` kbps.
248
+ * Kilobits per second to send 'body'.
211
249
  */
212
250
  throttleKbps?: number
213
251
  }