cypress 10.4.0 → 10.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/angular/CHANGELOG.md +86 -0
  2. package/angular/README.md +85 -0
  3. package/angular/dist/index.d.ts +1 -0
  4. package/angular/dist/index.js +265 -0
  5. package/angular/dist/mount.d.ts +112 -0
  6. package/angular/package.json +68 -0
  7. package/lib/tasks/download.js +4 -3
  8. package/mount-utils/CHANGELOG.md +7 -0
  9. package/mount-utils/package.json +5 -1
  10. package/package.json +16 -4
  11. package/react/CHANGELOG.md +20 -0
  12. package/react/dist/createMount.d.ts +7 -6
  13. package/react/dist/cypress-react.cjs.js +653 -140
  14. package/react/dist/cypress-react.esm-bundler.js +640 -127
  15. package/react/dist/mount.d.ts +2 -1
  16. package/react/dist/mountHook.d.ts +1 -0
  17. package/react/dist/types.d.ts +2 -7
  18. package/react/package.json +4 -6
  19. package/react18/CHANGELOG.md +13 -0
  20. package/react18/dist/cypress-react.cjs.js +300 -118
  21. package/react18/dist/cypress-react.esm-bundler.js +286 -104
  22. package/react18/dist/index.d.ts +2 -1
  23. package/react18/package.json +2 -2
  24. package/svelte/CHANGELOG.md +0 -0
  25. package/svelte/README.md +83 -0
  26. package/svelte/dist/cypress-svelte.cjs.js +213 -0
  27. package/svelte/dist/cypress-svelte.esm-bundler.js +209 -0
  28. package/svelte/dist/index.d.ts +1 -0
  29. package/svelte/dist/mount.d.ts +30 -0
  30. package/svelte/package.json +43 -0
  31. package/types/cypress-type-helpers.d.ts +3 -1
  32. package/types/cypress.d.ts +61 -5
  33. package/vue/CHANGELOG.md +14 -0
  34. package/vue/dist/cypress-vue.cjs.js +30 -38
  35. package/vue/dist/cypress-vue.esm-bundler.js +30 -38
  36. package/vue/dist/index.d.ts +1 -0
  37. package/vue/package.json +2 -8
  38. package/vue2/CHANGELOG.md +7 -0
  39. package/vue2/dist/cypress-vue2.cjs.js +53 -84
  40. package/vue2/dist/cypress-vue2.esm-bundler.js +53 -84
  41. package/vue2/dist/index.d.ts +1 -0
  42. package/vue2/package.json +2 -5
  43. package/vue2/dist/cypress-vue2.browser.js +0 -20197
@@ -15,66 +15,40 @@ var ReactDOM = require('react-dom');
15
15
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
16
 
17
17
  function _interopNamespace(e) {
18
- if (e && e.__esModule) return e;
19
- var n = Object.create(null);
20
- if (e) {
21
- Object.keys(e).forEach(function (k) {
22
- if (k !== 'default') {
23
- var d = Object.getOwnPropertyDescriptor(e, k);
24
- Object.defineProperty(n, k, d.get ? d : {
25
- enumerable: true,
26
- get: function () { return e[k]; }
27
- });
28
- }
18
+ if (e && e.__esModule) return e;
19
+ var n = Object.create(null);
20
+ if (e) {
21
+ Object.keys(e).forEach(function (k) {
22
+ if (k !== 'default') {
23
+ var d = Object.getOwnPropertyDescriptor(e, k);
24
+ Object.defineProperty(n, k, d.get ? d : {
25
+ enumerable: true,
26
+ get: function () { return e[k]; }
29
27
  });
30
- }
31
- n["default"] = e;
32
- return Object.freeze(n);
28
+ }
29
+ });
30
+ }
31
+ n["default"] = e;
32
+ return Object.freeze(n);
33
33
  }
34
34
 
35
35
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
36
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
36
37
  var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
37
38
 
38
- /******************************************************************************
39
- Copyright (c) Microsoft Corporation.
40
-
41
- Permission to use, copy, modify, and/or distribute this software for any
42
- purpose with or without fee is hereby granted.
43
-
44
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
45
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
46
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
47
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
48
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
49
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
50
- PERFORMANCE OF THIS SOFTWARE.
51
- ***************************************************************************** */
52
-
53
- var __assign = function() {
54
- __assign = Object.assign || function __assign(t) {
55
- for (var s, i = 1, n = arguments.length; i < n; i++) {
56
- s = arguments[i];
57
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
58
- }
59
- return t;
60
- };
61
- return __assign.apply(this, arguments);
62
- };
63
-
64
- var cachedDisplayNames = new WeakMap();
39
+ const cachedDisplayNames = new WeakMap();
65
40
  /**
66
41
  * Gets the display name of the component when possible.
67
42
  * @param type {JSX} The type object returned from creating the react element.
68
43
  * @param fallbackName {string} The alias, or fallback name to use when the name cannot be derived.
69
44
  * @link https://github.com/facebook/react-devtools/blob/master/backend/getDisplayName.js
70
45
  */
71
- function getDisplayName(type, fallbackName) {
72
- if (fallbackName === void 0) { fallbackName = 'Unknown'; }
73
- var nameFromCache = cachedDisplayNames.get(type);
46
+ function getDisplayName(type, fallbackName = 'Unknown') {
47
+ const nameFromCache = cachedDisplayNames.get(type);
74
48
  if (nameFromCache != null) {
75
49
  return nameFromCache;
76
50
  }
77
- var displayName = null;
51
+ let displayName = null;
78
52
  // The displayName property is not guaranteed to be a string.
79
53
  // It's only safe to use for our purposes if it's a string.
80
54
  // github.com/facebook/react-devtools/issues/803
@@ -86,13 +60,13 @@ function getDisplayName(type, fallbackName) {
86
60
  }
87
61
  // Facebook-specific hack to turn "Image [from Image.react]" into just "Image".
88
62
  // We need displayName with module name for error reports but it clutters the DevTools.
89
- var match = displayName.match(/^(.*) \[from (.*)\]$/);
63
+ const match = displayName.match(/^(.*) \[from (.*)\]$/);
90
64
  if (match) {
91
- var componentName = match[1];
92
- var moduleName = match[2];
65
+ const componentName = match[1];
66
+ const moduleName = match[2];
93
67
  if (componentName && moduleName) {
94
68
  if (moduleName === componentName ||
95
- moduleName.startsWith(componentName + ".")) {
69
+ moduleName.startsWith(`${componentName}.`)) {
96
70
  displayName = componentName;
97
71
  }
98
72
  }
@@ -251,13 +225,13 @@ function setupHooks(optionalCallback) {
251
225
  /**
252
226
  * Inject custom style text or CSS file or 3rd party style resources
253
227
  */
254
- var injectStyles = function (options) {
255
- return function () {
256
- var el = getContainerEl();
228
+ const injectStyles = (options) => {
229
+ return () => {
230
+ const el = getContainerEl();
257
231
  return injectStylesBeforeElement(options, document, el);
258
232
  };
259
233
  };
260
- exports.lastMountedReactDom = void 0;
234
+ let mountCleanup;
261
235
  /**
262
236
  * Create an `mount` function. Performs all the non-React-version specific
263
237
  * behavior related to mounting. The React-version-specific code
@@ -267,41 +241,40 @@ exports.lastMountedReactDom = void 0;
267
241
  * This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
268
242
  * or people writing adapters for third-party, custom adapters.
269
243
  */
270
- var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOptions) {
271
- if (options === void 0) { options = {}; }
244
+ const makeMountFn = (type, jsx, options = {}, rerenderKey, internalMountOptions) => {
272
245
  if (!internalMountOptions) {
273
246
  throw Error('internalMountOptions must be provided with `render` and `reactDom` parameters');
274
247
  }
248
+ mountCleanup = internalMountOptions.cleanup;
275
249
  // Get the display name property via the component constructor
276
250
  // @ts-ignore FIXME
277
- var componentName = getDisplayName(jsx.type, options.alias);
278
- var displayName = options.alias || componentName;
279
- var jsxComponentName = "<" + componentName + " ... />";
280
- var message = options.alias
281
- ? jsxComponentName + " as \"" + options.alias + "\""
251
+ const componentName = getDisplayName(jsx.type, options.alias);
252
+ const displayName = options.alias || componentName;
253
+ const jsxComponentName = `<${componentName} ... />`;
254
+ const message = options.alias
255
+ ? `${jsxComponentName} as "${options.alias}"`
282
256
  : jsxComponentName;
283
257
  return cy
284
258
  .then(injectStyles(options))
285
- .then(function () {
259
+ .then(() => {
286
260
  var _a, _b, _c;
287
- var reactDomToUse = internalMountOptions.reactDom;
288
- exports.lastMountedReactDom = reactDomToUse;
289
- var el = getContainerEl();
261
+ const reactDomToUse = internalMountOptions.reactDom;
262
+ const el = getContainerEl();
290
263
  if (!el) {
291
264
  throw new Error([
292
- "[@cypress/react] \uD83D\uDD25 Hmm, cannot find root element to mount the component. Searched for " + ROOT_SELECTOR,
265
+ `[@cypress/react] 🔥 Hmm, cannot find root element to mount the component. Searched for ${ROOT_SELECTOR}`,
293
266
  ].join(' '));
294
267
  }
295
- var key = rerenderKey !== null && rerenderKey !== void 0 ? rerenderKey :
268
+ const key = rerenderKey !== null && rerenderKey !== void 0 ? rerenderKey :
296
269
  // @ts-ignore provide unique key to the the wrapped component to make sure we are rerendering between tests
297
270
  (((_c = (_b = (_a = Cypress === null || Cypress === void 0 ? void 0 : Cypress.mocha) === null || _a === void 0 ? void 0 : _a.getRunner()) === null || _b === void 0 ? void 0 : _b.test) === null || _c === void 0 ? void 0 : _c.title) || '') + Math.random();
298
- var props = {
299
- key: key,
271
+ const props = {
272
+ key,
300
273
  };
301
- var reactComponent = React__namespace.createElement(options.strict ? React__namespace.StrictMode : React__namespace.Fragment, props, jsx);
274
+ const reactComponent = React__namespace.createElement(options.strict ? React__namespace.StrictMode : React__namespace.Fragment, props, jsx);
302
275
  // since we always surround the component with a fragment
303
276
  // let's get back the original component
304
- var userComponent = reactComponent.props.children;
277
+ const userComponent = reactComponent.props.children;
305
278
  internalMountOptions.render(reactComponent, el, reactDomToUse);
306
279
  if (options.log !== false) {
307
280
  Cypress.log({
@@ -310,7 +283,7 @@ var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOption
310
283
  message: [message],
311
284
  // @ts-ignore
312
285
  $el: el.children.item(0),
313
- consoleProps: function () {
286
+ consoleProps: () => {
314
287
  return {
315
288
  // @ts-ignore protect the use of jsx functional components use ReactNode
316
289
  props: jsx.props,
@@ -324,10 +297,10 @@ var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOption
324
297
  // Separate alias and returned value. Alias returns the component only, and the thenable returns the additional functions
325
298
  cy.wrap(userComponent, { log: false })
326
299
  .as(displayName)
327
- .then(function () {
300
+ .then(() => {
328
301
  return cy.wrap({
329
302
  component: userComponent,
330
- rerender: function (newComponent) { return makeMountFn('rerender', newComponent, options, key, internalMountOptions); },
303
+ rerender: (newComponent) => makeMountFn('rerender', newComponent, options, key, internalMountOptions),
331
304
  unmount: internalMountOptions.unmount,
332
305
  }, { log: false });
333
306
  })
@@ -345,47 +318,36 @@ var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOption
345
318
  * This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
346
319
  * or people writing adapters for third-party, custom adapters.
347
320
  */
348
- var makeUnmountFn = function (options, internalUnmountOptions) {
349
- return cy.then(function () {
350
- return cy.get(ROOT_SELECTOR, { log: false }).then(function ($el) {
351
- var _a;
352
- if (exports.lastMountedReactDom) {
353
- internalUnmountOptions.unmount($el[0]);
354
- var wasUnmounted = internalUnmountOptions.unmount($el[0]);
355
- if (wasUnmounted && options.log) {
356
- Cypress.log({
357
- name: 'unmount',
358
- type: 'parent',
359
- message: [(_a = options.boundComponentMessage) !== null && _a !== void 0 ? _a : 'Unmounted component'],
360
- consoleProps: function () {
361
- return {
362
- description: 'Unmounts React component',
363
- parent: $el[0],
364
- home: 'https://github.com/cypress-io/cypress',
365
- };
366
- },
367
- });
368
- }
369
- }
370
- });
321
+ const makeUnmountFn = (options) => {
322
+ return cy.then(() => {
323
+ var _a;
324
+ const wasUnmounted = mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
325
+ if (wasUnmounted && options.log) {
326
+ Cypress.log({
327
+ name: 'unmount',
328
+ type: 'parent',
329
+ message: [(_a = options.boundComponentMessage) !== null && _a !== void 0 ? _a : 'Unmounted component'],
330
+ consoleProps: () => {
331
+ return {
332
+ description: 'Unmounts React component',
333
+ parent: getContainerEl().parentNode,
334
+ home: 'https://github.com/cypress-io/cypress',
335
+ };
336
+ },
337
+ });
338
+ }
371
339
  });
372
340
  };
373
341
  // Cleanup before each run
374
342
  // NOTE: we cannot use unmount here because
375
343
  // we are not in the context of a test
376
- var preMountCleanup = function () {
377
- var el = getContainerEl();
378
- if (el && exports.lastMountedReactDom) {
379
- exports.lastMountedReactDom.unmountComponentAtNode(el);
380
- }
344
+ const preMountCleanup = () => {
345
+ mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
381
346
  };
382
- var _mount = function (jsx, options) {
383
- if (options === void 0) { options = {}; }
384
- return makeMountFn('mount', jsx, options);
385
- };
386
- var createMount = function (defaultOptions) {
387
- return function (element, options) {
388
- return _mount(element, __assign(__assign({}, defaultOptions), options));
347
+ const _mount = (jsx, options = {}) => makeMountFn('mount', jsx, options);
348
+ const createMount = (defaultOptions) => {
349
+ return (element, options) => {
350
+ return _mount(element, Object.assign(Object.assign({}, defaultOptions), options));
389
351
  };
390
352
  };
391
353
  // Side effects from "import { mount } from '@cypress/<my-framework>'" are annoying, we should avoid doing this
@@ -401,34 +363,587 @@ var createMount = function (defaultOptions) {
401
363
  // @see npm/react/cypress/component/advanced/set-timeout-example/loading-indicator-spec.js
402
364
  setupHooks(preMountCleanup);
403
365
 
404
- function mount(jsx, options, rerenderKey) {
405
- if (options === void 0) { options = {}; }
406
- var internalOptions = {
366
+ const debug = (
367
+ typeof process === 'object' &&
368
+ process.env &&
369
+ process.env.NODE_DEBUG &&
370
+ /\bsemver\b/i.test(process.env.NODE_DEBUG)
371
+ ) ? (...args) => console.error('SEMVER', ...args)
372
+ : () => {};
373
+
374
+ var debug_1 = debug;
375
+
376
+ // Note: this is the semver.org version of the spec that it implements
377
+ // Not necessarily the package version of this code.
378
+ const SEMVER_SPEC_VERSION = '2.0.0';
379
+
380
+ const MAX_LENGTH$1 = 256;
381
+ const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER ||
382
+ /* istanbul ignore next */ 9007199254740991;
383
+
384
+ // Max safe segment length for coercion.
385
+ const MAX_SAFE_COMPONENT_LENGTH = 16;
386
+
387
+ var constants = {
388
+ SEMVER_SPEC_VERSION,
389
+ MAX_LENGTH: MAX_LENGTH$1,
390
+ MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
391
+ MAX_SAFE_COMPONENT_LENGTH,
392
+ };
393
+
394
+ function createCommonjsModule(fn) {
395
+ var module = { exports: {} };
396
+ return fn(module, module.exports), module.exports;
397
+ }
398
+
399
+ var re_1 = createCommonjsModule(function (module, exports) {
400
+ const { MAX_SAFE_COMPONENT_LENGTH } = constants;
401
+
402
+ exports = module.exports = {};
403
+
404
+ // The actual regexps go on exports.re
405
+ const re = exports.re = [];
406
+ const src = exports.src = [];
407
+ const t = exports.t = {};
408
+ let R = 0;
409
+
410
+ const createToken = (name, value, isGlobal) => {
411
+ const index = R++;
412
+ debug_1(name, index, value);
413
+ t[name] = index;
414
+ src[index] = value;
415
+ re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
416
+ };
417
+
418
+ // The following Regular Expressions can be used for tokenizing,
419
+ // validating, and parsing SemVer version strings.
420
+
421
+ // ## Numeric Identifier
422
+ // A single `0`, or a non-zero digit followed by zero or more digits.
423
+
424
+ createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
425
+ createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+');
426
+
427
+ // ## Non-numeric Identifier
428
+ // Zero or more digits, followed by a letter or hyphen, and then zero or
429
+ // more letters, digits, or hyphens.
430
+
431
+ createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*');
432
+
433
+ // ## Main Version
434
+ // Three dot-separated numeric identifiers.
435
+
436
+ createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
437
+ `(${src[t.NUMERICIDENTIFIER]})\\.` +
438
+ `(${src[t.NUMERICIDENTIFIER]})`);
439
+
440
+ createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
441
+ `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
442
+ `(${src[t.NUMERICIDENTIFIERLOOSE]})`);
443
+
444
+ // ## Pre-release Version Identifier
445
+ // A numeric identifier, or a non-numeric identifier.
446
+
447
+ createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
448
+ }|${src[t.NONNUMERICIDENTIFIER]})`);
449
+
450
+ createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
451
+ }|${src[t.NONNUMERICIDENTIFIER]})`);
452
+
453
+ // ## Pre-release Version
454
+ // Hyphen, followed by one or more dot-separated pre-release version
455
+ // identifiers.
456
+
457
+ createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
458
+ }(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
459
+
460
+ createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
461
+ }(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
462
+
463
+ // ## Build Metadata Identifier
464
+ // Any combination of digits, letters, or hyphens.
465
+
466
+ createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+');
467
+
468
+ // ## Build Metadata
469
+ // Plus sign, followed by one or more period-separated build metadata
470
+ // identifiers.
471
+
472
+ createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
473
+ }(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
474
+
475
+ // ## Full Version String
476
+ // A main version, followed optionally by a pre-release version and
477
+ // build metadata.
478
+
479
+ // Note that the only major, minor, patch, and pre-release sections of
480
+ // the version string are capturing groups. The build metadata is not a
481
+ // capturing group, because it should not ever be used in version
482
+ // comparison.
483
+
484
+ createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
485
+ }${src[t.PRERELEASE]}?${
486
+ src[t.BUILD]}?`);
487
+
488
+ createToken('FULL', `^${src[t.FULLPLAIN]}$`);
489
+
490
+ // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
491
+ // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
492
+ // common in the npm registry.
493
+ createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
494
+ }${src[t.PRERELEASELOOSE]}?${
495
+ src[t.BUILD]}?`);
496
+
497
+ createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
498
+
499
+ createToken('GTLT', '((?:<|>)?=?)');
500
+
501
+ // Something like "2.*" or "1.2.x".
502
+ // Note that "x.x" is a valid xRange identifer, meaning "any version"
503
+ // Only the first item is strictly required.
504
+ createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
505
+ createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
506
+
507
+ createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
508
+ `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
509
+ `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
510
+ `(?:${src[t.PRERELEASE]})?${
511
+ src[t.BUILD]}?` +
512
+ `)?)?`);
513
+
514
+ createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
515
+ `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
516
+ `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
517
+ `(?:${src[t.PRERELEASELOOSE]})?${
518
+ src[t.BUILD]}?` +
519
+ `)?)?`);
520
+
521
+ createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
522
+ createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
523
+
524
+ // Coercion.
525
+ // Extract anything that could conceivably be a part of a valid semver
526
+ createToken('COERCE', `${'(^|[^\\d])' +
527
+ '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
528
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
529
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
530
+ `(?:$|[^\\d])`);
531
+ createToken('COERCERTL', src[t.COERCE], true);
532
+
533
+ // Tilde ranges.
534
+ // Meaning is "reasonably at or greater than"
535
+ createToken('LONETILDE', '(?:~>?)');
536
+
537
+ createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
538
+ exports.tildeTrimReplace = '$1~';
539
+
540
+ createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
541
+ createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
542
+
543
+ // Caret ranges.
544
+ // Meaning is "at least and backwards compatible with"
545
+ createToken('LONECARET', '(?:\\^)');
546
+
547
+ createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
548
+ exports.caretTrimReplace = '$1^';
549
+
550
+ createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
551
+ createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
552
+
553
+ // A simple gt/lt/eq thing, or just "" to indicate "any version"
554
+ createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
555
+ createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
556
+
557
+ // An expression to strip any whitespace between the gtlt and the thing
558
+ // it modifies, so that `> 1.2.3` ==> `>1.2.3`
559
+ createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
560
+ }\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
561
+ exports.comparatorTrimReplace = '$1$2$3';
562
+
563
+ // Something like `1.2.3 - 1.2.4`
564
+ // Note that these all use the loose form, because they'll be
565
+ // checked against either the strict or loose comparator form
566
+ // later.
567
+ createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
568
+ `\\s+-\\s+` +
569
+ `(${src[t.XRANGEPLAIN]})` +
570
+ `\\s*$`);
571
+
572
+ createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
573
+ `\\s+-\\s+` +
574
+ `(${src[t.XRANGEPLAINLOOSE]})` +
575
+ `\\s*$`);
576
+
577
+ // Star ranges basically just allow anything at all.
578
+ createToken('STAR', '(<|>)?=?\\s*\\*');
579
+ // >=0.0.0 is like a star
580
+ createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
581
+ createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
582
+ });
583
+
584
+ // parse out just the options we care about so we always get a consistent
585
+ // obj with keys in a consistent order.
586
+ const opts = ['includePrerelease', 'loose', 'rtl'];
587
+ const parseOptions = options =>
588
+ !options ? {}
589
+ : typeof options !== 'object' ? { loose: true }
590
+ : opts.filter(k => options[k]).reduce((o, k) => {
591
+ o[k] = true;
592
+ return o
593
+ }, {});
594
+ var parseOptions_1 = parseOptions;
595
+
596
+ const numeric = /^[0-9]+$/;
597
+ const compareIdentifiers$1 = (a, b) => {
598
+ const anum = numeric.test(a);
599
+ const bnum = numeric.test(b);
600
+
601
+ if (anum && bnum) {
602
+ a = +a;
603
+ b = +b;
604
+ }
605
+
606
+ return a === b ? 0
607
+ : (anum && !bnum) ? -1
608
+ : (bnum && !anum) ? 1
609
+ : a < b ? -1
610
+ : 1
611
+ };
612
+
613
+ const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
614
+
615
+ var identifiers = {
616
+ compareIdentifiers: compareIdentifiers$1,
617
+ rcompareIdentifiers,
618
+ };
619
+
620
+ const { MAX_LENGTH, MAX_SAFE_INTEGER } = constants;
621
+ const { re, t } = re_1;
622
+
623
+
624
+ const { compareIdentifiers } = identifiers;
625
+ class SemVer {
626
+ constructor (version, options) {
627
+ options = parseOptions_1(options);
628
+
629
+ if (version instanceof SemVer) {
630
+ if (version.loose === !!options.loose &&
631
+ version.includePrerelease === !!options.includePrerelease) {
632
+ return version
633
+ } else {
634
+ version = version.version;
635
+ }
636
+ } else if (typeof version !== 'string') {
637
+ throw new TypeError(`Invalid Version: ${version}`)
638
+ }
639
+
640
+ if (version.length > MAX_LENGTH) {
641
+ throw new TypeError(
642
+ `version is longer than ${MAX_LENGTH} characters`
643
+ )
644
+ }
645
+
646
+ debug_1('SemVer', version, options);
647
+ this.options = options;
648
+ this.loose = !!options.loose;
649
+ // this isn't actually relevant for versions, but keep it so that we
650
+ // don't run into trouble passing this.options around.
651
+ this.includePrerelease = !!options.includePrerelease;
652
+
653
+ const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
654
+
655
+ if (!m) {
656
+ throw new TypeError(`Invalid Version: ${version}`)
657
+ }
658
+
659
+ this.raw = version;
660
+
661
+ // these are actually numbers
662
+ this.major = +m[1];
663
+ this.minor = +m[2];
664
+ this.patch = +m[3];
665
+
666
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
667
+ throw new TypeError('Invalid major version')
668
+ }
669
+
670
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
671
+ throw new TypeError('Invalid minor version')
672
+ }
673
+
674
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
675
+ throw new TypeError('Invalid patch version')
676
+ }
677
+
678
+ // numberify any prerelease numeric ids
679
+ if (!m[4]) {
680
+ this.prerelease = [];
681
+ } else {
682
+ this.prerelease = m[4].split('.').map((id) => {
683
+ if (/^[0-9]+$/.test(id)) {
684
+ const num = +id;
685
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
686
+ return num
687
+ }
688
+ }
689
+ return id
690
+ });
691
+ }
692
+
693
+ this.build = m[5] ? m[5].split('.') : [];
694
+ this.format();
695
+ }
696
+
697
+ format () {
698
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
699
+ if (this.prerelease.length) {
700
+ this.version += `-${this.prerelease.join('.')}`;
701
+ }
702
+ return this.version
703
+ }
704
+
705
+ toString () {
706
+ return this.version
707
+ }
708
+
709
+ compare (other) {
710
+ debug_1('SemVer.compare', this.version, this.options, other);
711
+ if (!(other instanceof SemVer)) {
712
+ if (typeof other === 'string' && other === this.version) {
713
+ return 0
714
+ }
715
+ other = new SemVer(other, this.options);
716
+ }
717
+
718
+ if (other.version === this.version) {
719
+ return 0
720
+ }
721
+
722
+ return this.compareMain(other) || this.comparePre(other)
723
+ }
724
+
725
+ compareMain (other) {
726
+ if (!(other instanceof SemVer)) {
727
+ other = new SemVer(other, this.options);
728
+ }
729
+
730
+ return (
731
+ compareIdentifiers(this.major, other.major) ||
732
+ compareIdentifiers(this.minor, other.minor) ||
733
+ compareIdentifiers(this.patch, other.patch)
734
+ )
735
+ }
736
+
737
+ comparePre (other) {
738
+ if (!(other instanceof SemVer)) {
739
+ other = new SemVer(other, this.options);
740
+ }
741
+
742
+ // NOT having a prerelease is > having one
743
+ if (this.prerelease.length && !other.prerelease.length) {
744
+ return -1
745
+ } else if (!this.prerelease.length && other.prerelease.length) {
746
+ return 1
747
+ } else if (!this.prerelease.length && !other.prerelease.length) {
748
+ return 0
749
+ }
750
+
751
+ let i = 0;
752
+ do {
753
+ const a = this.prerelease[i];
754
+ const b = other.prerelease[i];
755
+ debug_1('prerelease compare', i, a, b);
756
+ if (a === undefined && b === undefined) {
757
+ return 0
758
+ } else if (b === undefined) {
759
+ return 1
760
+ } else if (a === undefined) {
761
+ return -1
762
+ } else if (a === b) {
763
+ continue
764
+ } else {
765
+ return compareIdentifiers(a, b)
766
+ }
767
+ } while (++i)
768
+ }
769
+
770
+ compareBuild (other) {
771
+ if (!(other instanceof SemVer)) {
772
+ other = new SemVer(other, this.options);
773
+ }
774
+
775
+ let i = 0;
776
+ do {
777
+ const a = this.build[i];
778
+ const b = other.build[i];
779
+ debug_1('prerelease compare', i, a, b);
780
+ if (a === undefined && b === undefined) {
781
+ return 0
782
+ } else if (b === undefined) {
783
+ return 1
784
+ } else if (a === undefined) {
785
+ return -1
786
+ } else if (a === b) {
787
+ continue
788
+ } else {
789
+ return compareIdentifiers(a, b)
790
+ }
791
+ } while (++i)
792
+ }
793
+
794
+ // preminor will bump the version up to the next minor release, and immediately
795
+ // down to pre-release. premajor and prepatch work the same way.
796
+ inc (release, identifier) {
797
+ switch (release) {
798
+ case 'premajor':
799
+ this.prerelease.length = 0;
800
+ this.patch = 0;
801
+ this.minor = 0;
802
+ this.major++;
803
+ this.inc('pre', identifier);
804
+ break
805
+ case 'preminor':
806
+ this.prerelease.length = 0;
807
+ this.patch = 0;
808
+ this.minor++;
809
+ this.inc('pre', identifier);
810
+ break
811
+ case 'prepatch':
812
+ // If this is already a prerelease, it will bump to the next version
813
+ // drop any prereleases that might already exist, since they are not
814
+ // relevant at this point.
815
+ this.prerelease.length = 0;
816
+ this.inc('patch', identifier);
817
+ this.inc('pre', identifier);
818
+ break
819
+ // If the input is a non-prerelease version, this acts the same as
820
+ // prepatch.
821
+ case 'prerelease':
822
+ if (this.prerelease.length === 0) {
823
+ this.inc('patch', identifier);
824
+ }
825
+ this.inc('pre', identifier);
826
+ break
827
+
828
+ case 'major':
829
+ // If this is a pre-major version, bump up to the same major version.
830
+ // Otherwise increment major.
831
+ // 1.0.0-5 bumps to 1.0.0
832
+ // 1.1.0 bumps to 2.0.0
833
+ if (
834
+ this.minor !== 0 ||
835
+ this.patch !== 0 ||
836
+ this.prerelease.length === 0
837
+ ) {
838
+ this.major++;
839
+ }
840
+ this.minor = 0;
841
+ this.patch = 0;
842
+ this.prerelease = [];
843
+ break
844
+ case 'minor':
845
+ // If this is a pre-minor version, bump up to the same minor version.
846
+ // Otherwise increment minor.
847
+ // 1.2.0-5 bumps to 1.2.0
848
+ // 1.2.1 bumps to 1.3.0
849
+ if (this.patch !== 0 || this.prerelease.length === 0) {
850
+ this.minor++;
851
+ }
852
+ this.patch = 0;
853
+ this.prerelease = [];
854
+ break
855
+ case 'patch':
856
+ // If this is not a pre-release version, it will increment the patch.
857
+ // If it is a pre-release it will bump up to the same patch version.
858
+ // 1.2.0-5 patches to 1.2.0
859
+ // 1.2.0 patches to 1.2.1
860
+ if (this.prerelease.length === 0) {
861
+ this.patch++;
862
+ }
863
+ this.prerelease = [];
864
+ break
865
+ // This probably shouldn't be used publicly.
866
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
867
+ case 'pre':
868
+ if (this.prerelease.length === 0) {
869
+ this.prerelease = [0];
870
+ } else {
871
+ let i = this.prerelease.length;
872
+ while (--i >= 0) {
873
+ if (typeof this.prerelease[i] === 'number') {
874
+ this.prerelease[i]++;
875
+ i = -2;
876
+ }
877
+ }
878
+ if (i === -1) {
879
+ // didn't increment anything
880
+ this.prerelease.push(0);
881
+ }
882
+ }
883
+ if (identifier) {
884
+ // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
885
+ // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
886
+ if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
887
+ if (isNaN(this.prerelease[1])) {
888
+ this.prerelease = [identifier, 0];
889
+ }
890
+ } else {
891
+ this.prerelease = [identifier, 0];
892
+ }
893
+ }
894
+ break
895
+
896
+ default:
897
+ throw new Error(`invalid increment argument: ${release}`)
898
+ }
899
+ this.format();
900
+ this.raw = this.version;
901
+ return this
902
+ }
903
+ }
904
+
905
+ var semver = SemVer;
906
+
907
+ const major = (a, loose) => new semver(a, loose).major;
908
+ var major_1 = major;
909
+
910
+ let lastReactDom;
911
+ const cleanup = () => {
912
+ if (lastReactDom) {
913
+ const root = getContainerEl();
914
+ lastReactDom.unmountComponentAtNode(root);
915
+ return true;
916
+ }
917
+ return false;
918
+ };
919
+ function mount(jsx, options = {}, rerenderKey) {
920
+ if (major_1(React__default["default"].version) === 18) {
921
+ const message = '[cypress/react]: You are using `cypress/react`, which is designed for React <= 17. Consider changing to `cypress/react18`, which is designed for React 18.';
922
+ console.error(message);
923
+ Cypress.log({ name: 'warning', message });
924
+ }
925
+ const internalOptions = {
407
926
  reactDom: ReactDOM__default["default"],
408
- render: function (reactComponent, el, reactDomToUse) {
409
- return (reactDomToUse || ReactDOM__default["default"]).render(reactComponent, el);
927
+ render: (reactComponent, el, reactDomToUse) => {
928
+ lastReactDom = (reactDomToUse || ReactDOM__default["default"]);
929
+ return lastReactDom.render(reactComponent, el);
410
930
  },
411
- unmount: unmount,
931
+ unmount,
932
+ cleanup,
412
933
  };
413
- return makeMountFn('mount', jsx, __assign({ ReactDom: ReactDOM__default["default"] }, options), rerenderKey, internalOptions);
934
+ return makeMountFn('mount', jsx, Object.assign({ ReactDom: ReactDOM__default["default"] }, options), rerenderKey, internalOptions);
414
935
  }
415
- function unmount(options) {
416
- if (options === void 0) { options = { log: true }; }
417
- var internalOptions = {
418
- unmount: function (el) {
419
- return (exports.lastMountedReactDom || ReactDOM__default["default"]).unmountComponentAtNode(el);
420
- },
421
- };
422
- return makeUnmountFn(options, internalOptions);
936
+ function unmount(options = { log: true }) {
937
+ return makeUnmountFn(options);
423
938
  }
424
939
 
425
940
  // mounting hooks inside a test component mostly copied from
426
941
  // https://github.com/testing-library/react-hooks-testing-library/blob/master/src/pure.js
427
942
  function resultContainer() {
428
- var value = null;
429
- var error = null;
430
- var resolvers = [];
431
- var result = {
943
+ let value = null;
944
+ let error = null;
945
+ const resolvers = [];
946
+ const result = {
432
947
  get current() {
433
948
  if (error) {
434
949
  throw error;
@@ -439,23 +954,21 @@ function resultContainer() {
439
954
  return error;
440
955
  },
441
956
  };
442
- var updateResult = function (val, err) {
443
- if (err === void 0) { err = null; }
957
+ const updateResult = (val, err = null) => {
444
958
  value = val;
445
959
  error = err;
446
- resolvers.splice(0, resolvers.length).forEach(function (resolve) { return resolve(); });
960
+ resolvers.splice(0, resolvers.length).forEach((resolve) => resolve());
447
961
  };
448
962
  return {
449
- result: result,
450
- addResolver: function (resolver) {
963
+ result,
964
+ addResolver: (resolver) => {
451
965
  resolvers.push(resolver);
452
966
  },
453
- setValue: function (val) { return updateResult(val); },
454
- setError: function (err) { return updateResult(undefined, err); },
967
+ setValue: (val) => updateResult(val),
968
+ setError: (err) => updateResult(undefined, err),
455
969
  };
456
970
  }
457
- function TestHook(_a) {
458
- var callback = _a.callback, onError = _a.onError, children = _a.children;
971
+ function TestHook({ callback, onError, children }) {
459
972
  try {
460
973
  children(callback());
461
974
  }
@@ -473,14 +986,14 @@ function TestHook(_a) {
473
986
  * Mounts a React hook function in a test component for testing.
474
987
  *
475
988
  */
476
- var mountHook = function (hookFn) {
477
- var _a = resultContainer(), result = _a.result, setValue = _a.setValue, setError = _a.setError;
478
- var componentTest = React__namespace.createElement(TestHook, {
989
+ const mountHook = (hookFn) => {
990
+ const { result, setValue, setError } = resultContainer();
991
+ const componentTest = React__namespace.createElement(TestHook, {
479
992
  callback: hookFn,
480
993
  onError: setError,
481
994
  children: setValue,
482
995
  });
483
- return mount(componentTest).then(function () { return result; });
996
+ return mount(componentTest).then(() => result);
484
997
  };
485
998
 
486
999
  exports.createMount = createMount;