cypress 10.4.0 → 10.5.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.
@@ -6,6 +6,7 @@
6
6
  */
7
7
 
8
8
  import * as React from 'react';
9
+ import React__default from 'react';
9
10
  import ReactDOM from 'react-dom';
10
11
 
11
12
  /******************************************************************************
@@ -230,7 +231,7 @@ var injectStyles = function (options) {
230
231
  return injectStylesBeforeElement(options, document, el);
231
232
  };
232
233
  };
233
- var lastMountedReactDom;
234
+ var mountCleanup;
234
235
  /**
235
236
  * Create an `mount` function. Performs all the non-React-version specific
236
237
  * behavior related to mounting. The React-version-specific code
@@ -245,6 +246,7 @@ var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOption
245
246
  if (!internalMountOptions) {
246
247
  throw Error('internalMountOptions must be provided with `render` and `reactDom` parameters');
247
248
  }
249
+ mountCleanup = internalMountOptions.cleanup;
248
250
  // Get the display name property via the component constructor
249
251
  // @ts-ignore FIXME
250
252
  var componentName = getDisplayName(jsx.type, options.alias);
@@ -258,7 +260,6 @@ var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOption
258
260
  .then(function () {
259
261
  var _a, _b, _c;
260
262
  var reactDomToUse = internalMountOptions.reactDom;
261
- lastMountedReactDom = reactDomToUse;
262
263
  var el = getContainerEl();
263
264
  if (!el) {
264
265
  throw new Error([
@@ -318,39 +319,31 @@ var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOption
318
319
  * This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
319
320
  * or people writing adapters for third-party, custom adapters.
320
321
  */
321
- var makeUnmountFn = function (options, internalUnmountOptions) {
322
+ var makeUnmountFn = function (options) {
322
323
  return cy.then(function () {
323
- return cy.get(ROOT_SELECTOR, { log: false }).then(function ($el) {
324
- var _a;
325
- if (lastMountedReactDom) {
326
- internalUnmountOptions.unmount($el[0]);
327
- var wasUnmounted = internalUnmountOptions.unmount($el[0]);
328
- if (wasUnmounted && options.log) {
329
- Cypress.log({
330
- name: 'unmount',
331
- type: 'parent',
332
- message: [(_a = options.boundComponentMessage) !== null && _a !== void 0 ? _a : 'Unmounted component'],
333
- consoleProps: function () {
334
- return {
335
- description: 'Unmounts React component',
336
- parent: $el[0],
337
- home: 'https://github.com/cypress-io/cypress',
338
- };
339
- },
340
- });
341
- }
342
- }
343
- });
324
+ var _a;
325
+ var wasUnmounted = mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
326
+ if (wasUnmounted && options.log) {
327
+ Cypress.log({
328
+ name: 'unmount',
329
+ type: 'parent',
330
+ message: [(_a = options.boundComponentMessage) !== null && _a !== void 0 ? _a : 'Unmounted component'],
331
+ consoleProps: function () {
332
+ return {
333
+ description: 'Unmounts React component',
334
+ parent: getContainerEl().parentNode,
335
+ home: 'https://github.com/cypress-io/cypress',
336
+ };
337
+ },
338
+ });
339
+ }
344
340
  });
345
341
  };
346
342
  // Cleanup before each run
347
343
  // NOTE: we cannot use unmount here because
348
344
  // we are not in the context of a test
349
345
  var preMountCleanup = function () {
350
- var el = getContainerEl();
351
- if (el && lastMountedReactDom) {
352
- lastMountedReactDom.unmountComponentAtNode(el);
353
- }
346
+ mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
354
347
  };
355
348
  var _mount = function (jsx, options) {
356
349
  if (options === void 0) { options = {}; }
@@ -374,25 +367,580 @@ var createMount = function (defaultOptions) {
374
367
  // @see npm/react/cypress/component/advanced/set-timeout-example/loading-indicator-spec.js
375
368
  setupHooks(preMountCleanup);
376
369
 
370
+ const debug = (
371
+ typeof process === 'object' &&
372
+ process.env &&
373
+ process.env.NODE_DEBUG &&
374
+ /\bsemver\b/i.test(process.env.NODE_DEBUG)
375
+ ) ? (...args) => console.error('SEMVER', ...args)
376
+ : () => {};
377
+
378
+ var debug_1 = debug;
379
+
380
+ // Note: this is the semver.org version of the spec that it implements
381
+ // Not necessarily the package version of this code.
382
+ const SEMVER_SPEC_VERSION = '2.0.0';
383
+
384
+ const MAX_LENGTH$1 = 256;
385
+ const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER ||
386
+ /* istanbul ignore next */ 9007199254740991;
387
+
388
+ // Max safe segment length for coercion.
389
+ const MAX_SAFE_COMPONENT_LENGTH = 16;
390
+
391
+ var constants = {
392
+ SEMVER_SPEC_VERSION,
393
+ MAX_LENGTH: MAX_LENGTH$1,
394
+ MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
395
+ MAX_SAFE_COMPONENT_LENGTH,
396
+ };
397
+
398
+ function createCommonjsModule(fn) {
399
+ var module = { exports: {} };
400
+ return fn(module, module.exports), module.exports;
401
+ }
402
+
403
+ var re_1 = createCommonjsModule(function (module, exports) {
404
+ const { MAX_SAFE_COMPONENT_LENGTH } = constants;
405
+
406
+ exports = module.exports = {};
407
+
408
+ // The actual regexps go on exports.re
409
+ const re = exports.re = [];
410
+ const src = exports.src = [];
411
+ const t = exports.t = {};
412
+ let R = 0;
413
+
414
+ const createToken = (name, value, isGlobal) => {
415
+ const index = R++;
416
+ debug_1(name, index, value);
417
+ t[name] = index;
418
+ src[index] = value;
419
+ re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
420
+ };
421
+
422
+ // The following Regular Expressions can be used for tokenizing,
423
+ // validating, and parsing SemVer version strings.
424
+
425
+ // ## Numeric Identifier
426
+ // A single `0`, or a non-zero digit followed by zero or more digits.
427
+
428
+ createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
429
+ createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+');
430
+
431
+ // ## Non-numeric Identifier
432
+ // Zero or more digits, followed by a letter or hyphen, and then zero or
433
+ // more letters, digits, or hyphens.
434
+
435
+ createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*');
436
+
437
+ // ## Main Version
438
+ // Three dot-separated numeric identifiers.
439
+
440
+ createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
441
+ `(${src[t.NUMERICIDENTIFIER]})\\.` +
442
+ `(${src[t.NUMERICIDENTIFIER]})`);
443
+
444
+ createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
445
+ `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
446
+ `(${src[t.NUMERICIDENTIFIERLOOSE]})`);
447
+
448
+ // ## Pre-release Version Identifier
449
+ // A numeric identifier, or a non-numeric identifier.
450
+
451
+ createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
452
+ }|${src[t.NONNUMERICIDENTIFIER]})`);
453
+
454
+ createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
455
+ }|${src[t.NONNUMERICIDENTIFIER]})`);
456
+
457
+ // ## Pre-release Version
458
+ // Hyphen, followed by one or more dot-separated pre-release version
459
+ // identifiers.
460
+
461
+ createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
462
+ }(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
463
+
464
+ createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
465
+ }(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
466
+
467
+ // ## Build Metadata Identifier
468
+ // Any combination of digits, letters, or hyphens.
469
+
470
+ createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+');
471
+
472
+ // ## Build Metadata
473
+ // Plus sign, followed by one or more period-separated build metadata
474
+ // identifiers.
475
+
476
+ createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
477
+ }(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
478
+
479
+ // ## Full Version String
480
+ // A main version, followed optionally by a pre-release version and
481
+ // build metadata.
482
+
483
+ // Note that the only major, minor, patch, and pre-release sections of
484
+ // the version string are capturing groups. The build metadata is not a
485
+ // capturing group, because it should not ever be used in version
486
+ // comparison.
487
+
488
+ createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
489
+ }${src[t.PRERELEASE]}?${
490
+ src[t.BUILD]}?`);
491
+
492
+ createToken('FULL', `^${src[t.FULLPLAIN]}$`);
493
+
494
+ // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
495
+ // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
496
+ // common in the npm registry.
497
+ createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
498
+ }${src[t.PRERELEASELOOSE]}?${
499
+ src[t.BUILD]}?`);
500
+
501
+ createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
502
+
503
+ createToken('GTLT', '((?:<|>)?=?)');
504
+
505
+ // Something like "2.*" or "1.2.x".
506
+ // Note that "x.x" is a valid xRange identifer, meaning "any version"
507
+ // Only the first item is strictly required.
508
+ createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
509
+ createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
510
+
511
+ createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
512
+ `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
513
+ `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
514
+ `(?:${src[t.PRERELEASE]})?${
515
+ src[t.BUILD]}?` +
516
+ `)?)?`);
517
+
518
+ createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
519
+ `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
520
+ `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
521
+ `(?:${src[t.PRERELEASELOOSE]})?${
522
+ src[t.BUILD]}?` +
523
+ `)?)?`);
524
+
525
+ createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
526
+ createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
527
+
528
+ // Coercion.
529
+ // Extract anything that could conceivably be a part of a valid semver
530
+ createToken('COERCE', `${'(^|[^\\d])' +
531
+ '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
532
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
533
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
534
+ `(?:$|[^\\d])`);
535
+ createToken('COERCERTL', src[t.COERCE], true);
536
+
537
+ // Tilde ranges.
538
+ // Meaning is "reasonably at or greater than"
539
+ createToken('LONETILDE', '(?:~>?)');
540
+
541
+ createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
542
+ exports.tildeTrimReplace = '$1~';
543
+
544
+ createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
545
+ createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
546
+
547
+ // Caret ranges.
548
+ // Meaning is "at least and backwards compatible with"
549
+ createToken('LONECARET', '(?:\\^)');
550
+
551
+ createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
552
+ exports.caretTrimReplace = '$1^';
553
+
554
+ createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
555
+ createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
556
+
557
+ // A simple gt/lt/eq thing, or just "" to indicate "any version"
558
+ createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
559
+ createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
560
+
561
+ // An expression to strip any whitespace between the gtlt and the thing
562
+ // it modifies, so that `> 1.2.3` ==> `>1.2.3`
563
+ createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
564
+ }\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
565
+ exports.comparatorTrimReplace = '$1$2$3';
566
+
567
+ // Something like `1.2.3 - 1.2.4`
568
+ // Note that these all use the loose form, because they'll be
569
+ // checked against either the strict or loose comparator form
570
+ // later.
571
+ createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
572
+ `\\s+-\\s+` +
573
+ `(${src[t.XRANGEPLAIN]})` +
574
+ `\\s*$`);
575
+
576
+ createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
577
+ `\\s+-\\s+` +
578
+ `(${src[t.XRANGEPLAINLOOSE]})` +
579
+ `\\s*$`);
580
+
581
+ // Star ranges basically just allow anything at all.
582
+ createToken('STAR', '(<|>)?=?\\s*\\*');
583
+ // >=0.0.0 is like a star
584
+ createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
585
+ createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
586
+ });
587
+
588
+ // parse out just the options we care about so we always get a consistent
589
+ // obj with keys in a consistent order.
590
+ const opts = ['includePrerelease', 'loose', 'rtl'];
591
+ const parseOptions = options =>
592
+ !options ? {}
593
+ : typeof options !== 'object' ? { loose: true }
594
+ : opts.filter(k => options[k]).reduce((o, k) => {
595
+ o[k] = true;
596
+ return o
597
+ }, {});
598
+ var parseOptions_1 = parseOptions;
599
+
600
+ const numeric = /^[0-9]+$/;
601
+ const compareIdentifiers$1 = (a, b) => {
602
+ const anum = numeric.test(a);
603
+ const bnum = numeric.test(b);
604
+
605
+ if (anum && bnum) {
606
+ a = +a;
607
+ b = +b;
608
+ }
609
+
610
+ return a === b ? 0
611
+ : (anum && !bnum) ? -1
612
+ : (bnum && !anum) ? 1
613
+ : a < b ? -1
614
+ : 1
615
+ };
616
+
617
+ const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
618
+
619
+ var identifiers = {
620
+ compareIdentifiers: compareIdentifiers$1,
621
+ rcompareIdentifiers,
622
+ };
623
+
624
+ const { MAX_LENGTH, MAX_SAFE_INTEGER } = constants;
625
+ const { re, t } = re_1;
626
+
627
+
628
+ const { compareIdentifiers } = identifiers;
629
+ class SemVer {
630
+ constructor (version, options) {
631
+ options = parseOptions_1(options);
632
+
633
+ if (version instanceof SemVer) {
634
+ if (version.loose === !!options.loose &&
635
+ version.includePrerelease === !!options.includePrerelease) {
636
+ return version
637
+ } else {
638
+ version = version.version;
639
+ }
640
+ } else if (typeof version !== 'string') {
641
+ throw new TypeError(`Invalid Version: ${version}`)
642
+ }
643
+
644
+ if (version.length > MAX_LENGTH) {
645
+ throw new TypeError(
646
+ `version is longer than ${MAX_LENGTH} characters`
647
+ )
648
+ }
649
+
650
+ debug_1('SemVer', version, options);
651
+ this.options = options;
652
+ this.loose = !!options.loose;
653
+ // this isn't actually relevant for versions, but keep it so that we
654
+ // don't run into trouble passing this.options around.
655
+ this.includePrerelease = !!options.includePrerelease;
656
+
657
+ const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
658
+
659
+ if (!m) {
660
+ throw new TypeError(`Invalid Version: ${version}`)
661
+ }
662
+
663
+ this.raw = version;
664
+
665
+ // these are actually numbers
666
+ this.major = +m[1];
667
+ this.minor = +m[2];
668
+ this.patch = +m[3];
669
+
670
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
671
+ throw new TypeError('Invalid major version')
672
+ }
673
+
674
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
675
+ throw new TypeError('Invalid minor version')
676
+ }
677
+
678
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
679
+ throw new TypeError('Invalid patch version')
680
+ }
681
+
682
+ // numberify any prerelease numeric ids
683
+ if (!m[4]) {
684
+ this.prerelease = [];
685
+ } else {
686
+ this.prerelease = m[4].split('.').map((id) => {
687
+ if (/^[0-9]+$/.test(id)) {
688
+ const num = +id;
689
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
690
+ return num
691
+ }
692
+ }
693
+ return id
694
+ });
695
+ }
696
+
697
+ this.build = m[5] ? m[5].split('.') : [];
698
+ this.format();
699
+ }
700
+
701
+ format () {
702
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
703
+ if (this.prerelease.length) {
704
+ this.version += `-${this.prerelease.join('.')}`;
705
+ }
706
+ return this.version
707
+ }
708
+
709
+ toString () {
710
+ return this.version
711
+ }
712
+
713
+ compare (other) {
714
+ debug_1('SemVer.compare', this.version, this.options, other);
715
+ if (!(other instanceof SemVer)) {
716
+ if (typeof other === 'string' && other === this.version) {
717
+ return 0
718
+ }
719
+ other = new SemVer(other, this.options);
720
+ }
721
+
722
+ if (other.version === this.version) {
723
+ return 0
724
+ }
725
+
726
+ return this.compareMain(other) || this.comparePre(other)
727
+ }
728
+
729
+ compareMain (other) {
730
+ if (!(other instanceof SemVer)) {
731
+ other = new SemVer(other, this.options);
732
+ }
733
+
734
+ return (
735
+ compareIdentifiers(this.major, other.major) ||
736
+ compareIdentifiers(this.minor, other.minor) ||
737
+ compareIdentifiers(this.patch, other.patch)
738
+ )
739
+ }
740
+
741
+ comparePre (other) {
742
+ if (!(other instanceof SemVer)) {
743
+ other = new SemVer(other, this.options);
744
+ }
745
+
746
+ // NOT having a prerelease is > having one
747
+ if (this.prerelease.length && !other.prerelease.length) {
748
+ return -1
749
+ } else if (!this.prerelease.length && other.prerelease.length) {
750
+ return 1
751
+ } else if (!this.prerelease.length && !other.prerelease.length) {
752
+ return 0
753
+ }
754
+
755
+ let i = 0;
756
+ do {
757
+ const a = this.prerelease[i];
758
+ const b = other.prerelease[i];
759
+ debug_1('prerelease compare', i, a, b);
760
+ if (a === undefined && b === undefined) {
761
+ return 0
762
+ } else if (b === undefined) {
763
+ return 1
764
+ } else if (a === undefined) {
765
+ return -1
766
+ } else if (a === b) {
767
+ continue
768
+ } else {
769
+ return compareIdentifiers(a, b)
770
+ }
771
+ } while (++i)
772
+ }
773
+
774
+ compareBuild (other) {
775
+ if (!(other instanceof SemVer)) {
776
+ other = new SemVer(other, this.options);
777
+ }
778
+
779
+ let i = 0;
780
+ do {
781
+ const a = this.build[i];
782
+ const b = other.build[i];
783
+ debug_1('prerelease compare', i, a, b);
784
+ if (a === undefined && b === undefined) {
785
+ return 0
786
+ } else if (b === undefined) {
787
+ return 1
788
+ } else if (a === undefined) {
789
+ return -1
790
+ } else if (a === b) {
791
+ continue
792
+ } else {
793
+ return compareIdentifiers(a, b)
794
+ }
795
+ } while (++i)
796
+ }
797
+
798
+ // preminor will bump the version up to the next minor release, and immediately
799
+ // down to pre-release. premajor and prepatch work the same way.
800
+ inc (release, identifier) {
801
+ switch (release) {
802
+ case 'premajor':
803
+ this.prerelease.length = 0;
804
+ this.patch = 0;
805
+ this.minor = 0;
806
+ this.major++;
807
+ this.inc('pre', identifier);
808
+ break
809
+ case 'preminor':
810
+ this.prerelease.length = 0;
811
+ this.patch = 0;
812
+ this.minor++;
813
+ this.inc('pre', identifier);
814
+ break
815
+ case 'prepatch':
816
+ // If this is already a prerelease, it will bump to the next version
817
+ // drop any prereleases that might already exist, since they are not
818
+ // relevant at this point.
819
+ this.prerelease.length = 0;
820
+ this.inc('patch', identifier);
821
+ this.inc('pre', identifier);
822
+ break
823
+ // If the input is a non-prerelease version, this acts the same as
824
+ // prepatch.
825
+ case 'prerelease':
826
+ if (this.prerelease.length === 0) {
827
+ this.inc('patch', identifier);
828
+ }
829
+ this.inc('pre', identifier);
830
+ break
831
+
832
+ case 'major':
833
+ // If this is a pre-major version, bump up to the same major version.
834
+ // Otherwise increment major.
835
+ // 1.0.0-5 bumps to 1.0.0
836
+ // 1.1.0 bumps to 2.0.0
837
+ if (
838
+ this.minor !== 0 ||
839
+ this.patch !== 0 ||
840
+ this.prerelease.length === 0
841
+ ) {
842
+ this.major++;
843
+ }
844
+ this.minor = 0;
845
+ this.patch = 0;
846
+ this.prerelease = [];
847
+ break
848
+ case 'minor':
849
+ // If this is a pre-minor version, bump up to the same minor version.
850
+ // Otherwise increment minor.
851
+ // 1.2.0-5 bumps to 1.2.0
852
+ // 1.2.1 bumps to 1.3.0
853
+ if (this.patch !== 0 || this.prerelease.length === 0) {
854
+ this.minor++;
855
+ }
856
+ this.patch = 0;
857
+ this.prerelease = [];
858
+ break
859
+ case 'patch':
860
+ // If this is not a pre-release version, it will increment the patch.
861
+ // If it is a pre-release it will bump up to the same patch version.
862
+ // 1.2.0-5 patches to 1.2.0
863
+ // 1.2.0 patches to 1.2.1
864
+ if (this.prerelease.length === 0) {
865
+ this.patch++;
866
+ }
867
+ this.prerelease = [];
868
+ break
869
+ // This probably shouldn't be used publicly.
870
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
871
+ case 'pre':
872
+ if (this.prerelease.length === 0) {
873
+ this.prerelease = [0];
874
+ } else {
875
+ let i = this.prerelease.length;
876
+ while (--i >= 0) {
877
+ if (typeof this.prerelease[i] === 'number') {
878
+ this.prerelease[i]++;
879
+ i = -2;
880
+ }
881
+ }
882
+ if (i === -1) {
883
+ // didn't increment anything
884
+ this.prerelease.push(0);
885
+ }
886
+ }
887
+ if (identifier) {
888
+ // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
889
+ // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
890
+ if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
891
+ if (isNaN(this.prerelease[1])) {
892
+ this.prerelease = [identifier, 0];
893
+ }
894
+ } else {
895
+ this.prerelease = [identifier, 0];
896
+ }
897
+ }
898
+ break
899
+
900
+ default:
901
+ throw new Error(`invalid increment argument: ${release}`)
902
+ }
903
+ this.format();
904
+ this.raw = this.version;
905
+ return this
906
+ }
907
+ }
908
+
909
+ var semver = SemVer;
910
+
911
+ const major = (a, loose) => new semver(a, loose).major;
912
+ var major_1 = major;
913
+
914
+ var lastReactDom;
915
+ var cleanup = function () {
916
+ if (lastReactDom) {
917
+ var root = getContainerEl();
918
+ lastReactDom.unmountComponentAtNode(root);
919
+ return true;
920
+ }
921
+ return false;
922
+ };
377
923
  function mount(jsx, options, rerenderKey) {
378
924
  if (options === void 0) { options = {}; }
925
+ if (major_1(React__default.version) === 18) {
926
+ var 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.';
927
+ console.error(message);
928
+ Cypress.log({ name: 'warning', message: message });
929
+ }
379
930
  var internalOptions = {
380
931
  reactDom: ReactDOM,
381
932
  render: function (reactComponent, el, reactDomToUse) {
382
- return (reactDomToUse || ReactDOM).render(reactComponent, el);
933
+ lastReactDom = (reactDomToUse || ReactDOM);
934
+ return lastReactDom.render(reactComponent, el);
383
935
  },
384
936
  unmount: unmount,
937
+ cleanup: cleanup,
385
938
  };
386
939
  return makeMountFn('mount', jsx, __assign({ ReactDom: ReactDOM }, options), rerenderKey, internalOptions);
387
940
  }
388
941
  function unmount(options) {
389
942
  if (options === void 0) { options = { log: true }; }
390
- var internalOptions = {
391
- unmount: function (el) {
392
- return (lastMountedReactDom || ReactDOM).unmountComponentAtNode(el);
393
- },
394
- };
395
- return makeUnmountFn(options, internalOptions);
943
+ return makeUnmountFn(options);
396
944
  }
397
945
 
398
946
  // mounting hooks inside a test component mostly copied from
@@ -456,4 +1004,4 @@ var mountHook = function (hookFn) {
456
1004
  return mount(componentTest).then(function () { return result; });
457
1005
  };
458
1006
 
459
- export { createMount, lastMountedReactDom, makeMountFn, makeUnmountFn, mount, mountHook, unmount };
1007
+ export { createMount, makeMountFn, makeUnmountFn, mount, mountHook, unmount };
@@ -4,4 +4,4 @@ import type { MountOptions } from './types';
4
4
  export declare function mount(jsx: React.ReactNode, options?: MountOptions, rerenderKey?: string): Cypress.Chainable<import("./types").MountReturn>;
5
5
  export declare function unmount(options?: {
6
6
  log: boolean;
7
- }): Cypress.Chainable<JQuery<HTMLElement>>;
7
+ }): Cypress.Chainable<undefined>;