cypress 13.17.0 → 14.0.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 (73) hide show
  1. package/angular/README.md +5 -0
  2. package/angular/angular/README.md +5 -0
  3. package/angular/angular/dist/index.d.ts +11 -2
  4. package/angular/angular/dist/index.js +944 -4
  5. package/angular/angular/package.json +16 -9
  6. package/angular/dist/index.d.ts +11 -2
  7. package/angular/dist/index.js +944 -4
  8. package/angular/package.json +16 -9
  9. package/lib/cli.js +1 -30
  10. package/lib/exec/spawn.js +17 -7
  11. package/mount-utils/dist/index.d.ts +0 -28
  12. package/mount-utils/dist/index.js +0 -27
  13. package/mount-utils/mount-utils/dist/index.d.ts +0 -28
  14. package/mount-utils/mount-utils/dist/index.js +0 -27
  15. package/package.json +5 -23
  16. package/react/README.md +5 -0
  17. package/react/dist/cypress-react.cjs.js +21 -676
  18. package/react/dist/cypress-react.esm-bundler.js +22 -676
  19. package/react/dist/index.d.ts +13 -30
  20. package/react/package.json +13 -15
  21. package/react/react/README.md +5 -0
  22. package/react/react/dist/cypress-react.cjs.js +21 -676
  23. package/react/react/dist/cypress-react.esm-bundler.js +22 -676
  24. package/react/react/dist/index.d.ts +13 -30
  25. package/react/react/package.json +13 -15
  26. package/svelte/README.md +6 -2
  27. package/svelte/dist/cypress-svelte.cjs.js +12 -12
  28. package/svelte/dist/cypress-svelte.esm-bundler.js +12 -12
  29. package/svelte/dist/index.d.ts +8 -179
  30. package/svelte/package.json +2 -2
  31. package/svelte/svelte/README.md +6 -2
  32. package/svelte/svelte/dist/cypress-svelte.cjs.js +12 -12
  33. package/svelte/svelte/dist/cypress-svelte.esm-bundler.js +12 -12
  34. package/svelte/svelte/dist/index.d.ts +8 -179
  35. package/svelte/svelte/package.json +2 -2
  36. package/types/cypress.d.ts +32 -49
  37. package/types/net-stubbing.d.ts +2 -7
  38. package/vue/dist/cypress-vue.cjs.js +380 -275
  39. package/vue/dist/cypress-vue.esm-bundler.js +382 -276
  40. package/vue/dist/index.d.ts +61 -78
  41. package/vue/package.json +2 -5
  42. package/vue/vue/dist/cypress-vue.cjs.js +380 -275
  43. package/vue/vue/dist/cypress-vue.esm-bundler.js +382 -276
  44. package/vue/vue/dist/index.d.ts +61 -78
  45. package/vue/vue/package.json +2 -5
  46. package/angular-signals/README.md +0 -11
  47. package/angular-signals/angular-signals/README.md +0 -11
  48. package/angular-signals/angular-signals/dist/index.d.ts +0 -136
  49. package/angular-signals/angular-signals/dist/index.js +0 -1861
  50. package/angular-signals/angular-signals/package.json +0 -74
  51. package/angular-signals/dist/index.d.ts +0 -136
  52. package/angular-signals/dist/index.js +0 -1861
  53. package/angular-signals/package.json +0 -74
  54. package/react18/README.md +0 -7
  55. package/react18/dist/cypress-react.cjs.js +0 -597
  56. package/react18/dist/cypress-react.esm-bundler.js +0 -574
  57. package/react18/dist/index.d.ts +0 -78
  58. package/react18/package.json +0 -71
  59. package/react18/react18/README.md +0 -7
  60. package/react18/react18/dist/cypress-react.cjs.js +0 -597
  61. package/react18/react18/dist/cypress-react.esm-bundler.js +0 -574
  62. package/react18/react18/dist/index.d.ts +0 -78
  63. package/react18/react18/package.json +0 -71
  64. package/vue2/README.md +0 -7
  65. package/vue2/dist/cypress-vue2.cjs.js +0 -20045
  66. package/vue2/dist/cypress-vue2.esm-bundler.js +0 -20042
  67. package/vue2/dist/index.d.ts +0 -207
  68. package/vue2/package.json +0 -65
  69. package/vue2/vue2/README.md +0 -7
  70. package/vue2/vue2/dist/cypress-vue2.cjs.js +0 -20045
  71. package/vue2/vue2/dist/cypress-vue2.esm-bundler.js +0 -20042
  72. package/vue2/vue2/dist/index.d.ts +0 -207
  73. package/vue2/vue2/package.json +0 -65
@@ -1,14 +1,14 @@
1
1
 
2
2
  /**
3
3
  * @cypress/react v0.0.0-development
4
- * (c) 2024 Cypress.io
4
+ * (c) 2025 Cypress.io
5
5
  * Released under the MIT License
6
6
  */
7
7
 
8
8
  'use strict';
9
9
 
10
10
  var React = require('react');
11
- var ReactDOM = require('react-dom');
11
+ var ReactDOM = require('react-dom/client');
12
12
 
13
13
  function _interopNamespaceDefault(e) {
14
14
  var n = Object.create(null);
@@ -79,13 +79,6 @@ const getContainerEl = () => {
79
79
  }
80
80
  throw Error(`No element found that matches selector ${ROOT_SELECTOR}. Please add a root element with data-cy-root attribute to your "component-index.html" file so that Cypress can attach your component to the DOM.`);
81
81
  };
82
- function checkForRemovedStyleOptions(mountingOptions) {
83
- for (const key of ['cssFile', 'cssFiles', 'style', 'styles', 'stylesheet', 'stylesheets']) {
84
- if (mountingOptions[key]) {
85
- Cypress.utils.throwErrByPath('mount.removed_style_mounting_options', key);
86
- }
87
- }
88
- }
89
82
  /**
90
83
  * Utility function to register CT side effects and run cleanup code during the "test:before:run" Cypress hook
91
84
  * @param optionalCallback Callback to be called before the next test runs
@@ -129,12 +122,6 @@ const makeMountFn = (type, jsx, options = {}, rerenderKey, internalMountOptions)
129
122
  if (!internalMountOptions) {
130
123
  throw Error('internalMountOptions must be provided with `render` and `reactDom` parameters');
131
124
  }
132
- // @ts-expect-error - this is removed but we want to check if a user is passing it, and error if they are.
133
- if (options.alias) {
134
- // @ts-expect-error
135
- Cypress.utils.throwErrByPath('mount.alias', options.alias);
136
- }
137
- checkForRemovedStyleOptions(options);
138
125
  mountCleanup = internalMountOptions.cleanup;
139
126
  return cy
140
127
  .then(() => {
@@ -162,10 +149,6 @@ const makeMountFn = (type, jsx, options = {}, rerenderKey, internalMountOptions)
162
149
  return cy.wrap({
163
150
  component: userComponent,
164
151
  rerender: (newComponent) => makeMountFn('rerender', newComponent, options, key, internalMountOptions),
165
- unmount: () => {
166
- // @ts-expect-error - undocumented API
167
- Cypress.utils.throwErrByPath('mount.unmount');
168
- },
169
152
  }, { log: false });
170
153
  })
171
154
  // by waiting, we delaying test execution for the next tick of event loop
@@ -252,637 +235,21 @@ const createMount = (defaultOptions) => {
252
235
  // @see npm/react/cypress/component/advanced/set-timeout-example/loading-indicator-spec.js
253
236
  setupHooks(preMountCleanup);
254
237
 
255
- const debug = (
256
- typeof process === 'object' &&
257
- process.env &&
258
- process.env.NODE_DEBUG &&
259
- /\bsemver\b/i.test(process.env.NODE_DEBUG)
260
- ) ? (...args) => console.error('SEMVER', ...args)
261
- : () => {};
262
-
263
- var debug_1 = debug;
264
-
265
- // Note: this is the semver.org version of the spec that it implements
266
- // Not necessarily the package version of this code.
267
- const SEMVER_SPEC_VERSION = '2.0.0';
268
-
269
- const MAX_LENGTH$1 = 256;
270
- const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER ||
271
- /* istanbul ignore next */ 9007199254740991;
272
-
273
- // Max safe segment length for coercion.
274
- const MAX_SAFE_COMPONENT_LENGTH = 16;
275
-
276
- // Max safe length for a build identifier. The max length minus 6 characters for
277
- // the shortest version with a build 0.0.0+BUILD.
278
- const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH$1 - 6;
279
-
280
- const RELEASE_TYPES = [
281
- 'major',
282
- 'premajor',
283
- 'minor',
284
- 'preminor',
285
- 'patch',
286
- 'prepatch',
287
- 'prerelease',
288
- ];
289
-
290
- var constants = {
291
- MAX_LENGTH: MAX_LENGTH$1,
292
- MAX_SAFE_COMPONENT_LENGTH,
293
- MAX_SAFE_BUILD_LENGTH,
294
- MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
295
- RELEASE_TYPES,
296
- SEMVER_SPEC_VERSION,
297
- FLAG_INCLUDE_PRERELEASE: 0b001,
298
- FLAG_LOOSE: 0b010,
299
- };
300
-
301
- function createCommonjsModule(fn) {
302
- var module = { exports: {} };
303
- return fn(module, module.exports), module.exports;
304
- }
305
-
306
- var re_1 = createCommonjsModule(function (module, exports) {
307
- const {
308
- MAX_SAFE_COMPONENT_LENGTH,
309
- MAX_SAFE_BUILD_LENGTH,
310
- MAX_LENGTH,
311
- } = constants;
312
-
313
- exports = module.exports = {};
314
-
315
- // The actual regexps go on exports.re
316
- const re = exports.re = [];
317
- const safeRe = exports.safeRe = [];
318
- const src = exports.src = [];
319
- const t = exports.t = {};
320
- let R = 0;
321
-
322
- const LETTERDASHNUMBER = '[a-zA-Z0-9-]';
323
-
324
- // Replace some greedy regex tokens to prevent regex dos issues. These regex are
325
- // used internally via the safeRe object since all inputs in this library get
326
- // normalized first to trim and collapse all extra whitespace. The original
327
- // regexes are exported for userland consumption and lower level usage. A
328
- // future breaking change could export the safer regex only with a note that
329
- // all input should have extra whitespace removed.
330
- const safeRegexReplacements = [
331
- ['\\s', 1],
332
- ['\\d', MAX_LENGTH],
333
- [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],
334
- ];
335
-
336
- const makeSafeRegex = (value) => {
337
- for (const [token, max] of safeRegexReplacements) {
338
- value = value
339
- .split(`${token}*`).join(`${token}{0,${max}}`)
340
- .split(`${token}+`).join(`${token}{1,${max}}`);
341
- }
342
- return value
343
- };
344
-
345
- const createToken = (name, value, isGlobal) => {
346
- const safe = makeSafeRegex(value);
347
- const index = R++;
348
- debug_1(name, index, value);
349
- t[name] = index;
350
- src[index] = value;
351
- re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
352
- safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined);
353
- };
354
-
355
- // The following Regular Expressions can be used for tokenizing,
356
- // validating, and parsing SemVer version strings.
357
-
358
- // ## Numeric Identifier
359
- // A single `0`, or a non-zero digit followed by zero or more digits.
360
-
361
- createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
362
- createToken('NUMERICIDENTIFIERLOOSE', '\\d+');
363
-
364
- // ## Non-numeric Identifier
365
- // Zero or more digits, followed by a letter or hyphen, and then zero or
366
- // more letters, digits, or hyphens.
367
-
368
- createToken('NONNUMERICIDENTIFIER', `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
369
-
370
- // ## Main Version
371
- // Three dot-separated numeric identifiers.
372
-
373
- createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
374
- `(${src[t.NUMERICIDENTIFIER]})\\.` +
375
- `(${src[t.NUMERICIDENTIFIER]})`);
376
-
377
- createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
378
- `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
379
- `(${src[t.NUMERICIDENTIFIERLOOSE]})`);
380
-
381
- // ## Pre-release Version Identifier
382
- // A numeric identifier, or a non-numeric identifier.
383
-
384
- createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
385
- }|${src[t.NONNUMERICIDENTIFIER]})`);
386
-
387
- createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
388
- }|${src[t.NONNUMERICIDENTIFIER]})`);
389
-
390
- // ## Pre-release Version
391
- // Hyphen, followed by one or more dot-separated pre-release version
392
- // identifiers.
393
-
394
- createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
395
- }(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
396
-
397
- createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
398
- }(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
399
-
400
- // ## Build Metadata Identifier
401
- // Any combination of digits, letters, or hyphens.
402
-
403
- createToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`);
404
-
405
- // ## Build Metadata
406
- // Plus sign, followed by one or more period-separated build metadata
407
- // identifiers.
408
-
409
- createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
410
- }(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
411
-
412
- // ## Full Version String
413
- // A main version, followed optionally by a pre-release version and
414
- // build metadata.
415
-
416
- // Note that the only major, minor, patch, and pre-release sections of
417
- // the version string are capturing groups. The build metadata is not a
418
- // capturing group, because it should not ever be used in version
419
- // comparison.
420
-
421
- createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
422
- }${src[t.PRERELEASE]}?${
423
- src[t.BUILD]}?`);
424
-
425
- createToken('FULL', `^${src[t.FULLPLAIN]}$`);
426
-
427
- // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
428
- // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
429
- // common in the npm registry.
430
- createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
431
- }${src[t.PRERELEASELOOSE]}?${
432
- src[t.BUILD]}?`);
433
-
434
- createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
435
-
436
- createToken('GTLT', '((?:<|>)?=?)');
437
-
438
- // Something like "2.*" or "1.2.x".
439
- // Note that "x.x" is a valid xRange identifer, meaning "any version"
440
- // Only the first item is strictly required.
441
- createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
442
- createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
443
-
444
- createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
445
- `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
446
- `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
447
- `(?:${src[t.PRERELEASE]})?${
448
- src[t.BUILD]}?` +
449
- `)?)?`);
450
-
451
- createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
452
- `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
453
- `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
454
- `(?:${src[t.PRERELEASELOOSE]})?${
455
- src[t.BUILD]}?` +
456
- `)?)?`);
457
-
458
- createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
459
- createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
460
-
461
- // Coercion.
462
- // Extract anything that could conceivably be a part of a valid semver
463
- createToken('COERCEPLAIN', `${'(^|[^\\d])' +
464
- '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
465
- `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
466
- `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
467
- createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
468
- createToken('COERCEFULL', src[t.COERCEPLAIN] +
469
- `(?:${src[t.PRERELEASE]})?` +
470
- `(?:${src[t.BUILD]})?` +
471
- `(?:$|[^\\d])`);
472
- createToken('COERCERTL', src[t.COERCE], true);
473
- createToken('COERCERTLFULL', src[t.COERCEFULL], true);
474
-
475
- // Tilde ranges.
476
- // Meaning is "reasonably at or greater than"
477
- createToken('LONETILDE', '(?:~>?)');
478
-
479
- createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
480
- exports.tildeTrimReplace = '$1~';
481
-
482
- createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
483
- createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
484
-
485
- // Caret ranges.
486
- // Meaning is "at least and backwards compatible with"
487
- createToken('LONECARET', '(?:\\^)');
488
-
489
- createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
490
- exports.caretTrimReplace = '$1^';
491
-
492
- createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
493
- createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
494
-
495
- // A simple gt/lt/eq thing, or just "" to indicate "any version"
496
- createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
497
- createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
498
-
499
- // An expression to strip any whitespace between the gtlt and the thing
500
- // it modifies, so that `> 1.2.3` ==> `>1.2.3`
501
- createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
502
- }\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
503
- exports.comparatorTrimReplace = '$1$2$3';
504
-
505
- // Something like `1.2.3 - 1.2.4`
506
- // Note that these all use the loose form, because they'll be
507
- // checked against either the strict or loose comparator form
508
- // later.
509
- createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
510
- `\\s+-\\s+` +
511
- `(${src[t.XRANGEPLAIN]})` +
512
- `\\s*$`);
513
-
514
- createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
515
- `\\s+-\\s+` +
516
- `(${src[t.XRANGEPLAINLOOSE]})` +
517
- `\\s*$`);
518
-
519
- // Star ranges basically just allow anything at all.
520
- createToken('STAR', '(<|>)?=?\\s*\\*');
521
- // >=0.0.0 is like a star
522
- createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
523
- createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
524
- });
525
-
526
- // parse out just the options we care about
527
- const looseOption = Object.freeze({ loose: true });
528
- const emptyOpts = Object.freeze({ });
529
- const parseOptions = options => {
530
- if (!options) {
531
- return emptyOpts
532
- }
533
-
534
- if (typeof options !== 'object') {
535
- return looseOption
536
- }
537
-
538
- return options
539
- };
540
- var parseOptions_1 = parseOptions;
541
-
542
- const numeric = /^[0-9]+$/;
543
- const compareIdentifiers$1 = (a, b) => {
544
- const anum = numeric.test(a);
545
- const bnum = numeric.test(b);
546
-
547
- if (anum && bnum) {
548
- a = +a;
549
- b = +b;
550
- }
551
-
552
- return a === b ? 0
553
- : (anum && !bnum) ? -1
554
- : (bnum && !anum) ? 1
555
- : a < b ? -1
556
- : 1
557
- };
558
-
559
- const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
560
-
561
- var identifiers = {
562
- compareIdentifiers: compareIdentifiers$1,
563
- rcompareIdentifiers,
564
- };
565
-
566
- const { MAX_LENGTH, MAX_SAFE_INTEGER } = constants;
567
- const { safeRe: re, t } = re_1;
568
-
569
-
570
- const { compareIdentifiers } = identifiers;
571
- class SemVer {
572
- constructor (version, options) {
573
- options = parseOptions_1(options);
574
-
575
- if (version instanceof SemVer) {
576
- if (version.loose === !!options.loose &&
577
- version.includePrerelease === !!options.includePrerelease) {
578
- return version
579
- } else {
580
- version = version.version;
581
- }
582
- } else if (typeof version !== 'string') {
583
- throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`)
584
- }
585
-
586
- if (version.length > MAX_LENGTH) {
587
- throw new TypeError(
588
- `version is longer than ${MAX_LENGTH} characters`
589
- )
590
- }
591
-
592
- debug_1('SemVer', version, options);
593
- this.options = options;
594
- this.loose = !!options.loose;
595
- // this isn't actually relevant for versions, but keep it so that we
596
- // don't run into trouble passing this.options around.
597
- this.includePrerelease = !!options.includePrerelease;
598
-
599
- const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
600
-
601
- if (!m) {
602
- throw new TypeError(`Invalid Version: ${version}`)
603
- }
604
-
605
- this.raw = version;
606
-
607
- // these are actually numbers
608
- this.major = +m[1];
609
- this.minor = +m[2];
610
- this.patch = +m[3];
611
-
612
- if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
613
- throw new TypeError('Invalid major version')
614
- }
615
-
616
- if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
617
- throw new TypeError('Invalid minor version')
618
- }
619
-
620
- if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
621
- throw new TypeError('Invalid patch version')
622
- }
623
-
624
- // numberify any prerelease numeric ids
625
- if (!m[4]) {
626
- this.prerelease = [];
627
- } else {
628
- this.prerelease = m[4].split('.').map((id) => {
629
- if (/^[0-9]+$/.test(id)) {
630
- const num = +id;
631
- if (num >= 0 && num < MAX_SAFE_INTEGER) {
632
- return num
633
- }
634
- }
635
- return id
636
- });
637
- }
638
-
639
- this.build = m[5] ? m[5].split('.') : [];
640
- this.format();
641
- }
642
-
643
- format () {
644
- this.version = `${this.major}.${this.minor}.${this.patch}`;
645
- if (this.prerelease.length) {
646
- this.version += `-${this.prerelease.join('.')}`;
647
- }
648
- return this.version
649
- }
650
-
651
- toString () {
652
- return this.version
653
- }
654
-
655
- compare (other) {
656
- debug_1('SemVer.compare', this.version, this.options, other);
657
- if (!(other instanceof SemVer)) {
658
- if (typeof other === 'string' && other === this.version) {
659
- return 0
660
- }
661
- other = new SemVer(other, this.options);
662
- }
663
-
664
- if (other.version === this.version) {
665
- return 0
666
- }
667
-
668
- return this.compareMain(other) || this.comparePre(other)
669
- }
670
-
671
- compareMain (other) {
672
- if (!(other instanceof SemVer)) {
673
- other = new SemVer(other, this.options);
674
- }
675
-
676
- return (
677
- compareIdentifiers(this.major, other.major) ||
678
- compareIdentifiers(this.minor, other.minor) ||
679
- compareIdentifiers(this.patch, other.patch)
680
- )
681
- }
682
-
683
- comparePre (other) {
684
- if (!(other instanceof SemVer)) {
685
- other = new SemVer(other, this.options);
686
- }
687
-
688
- // NOT having a prerelease is > having one
689
- if (this.prerelease.length && !other.prerelease.length) {
690
- return -1
691
- } else if (!this.prerelease.length && other.prerelease.length) {
692
- return 1
693
- } else if (!this.prerelease.length && !other.prerelease.length) {
694
- return 0
695
- }
696
-
697
- let i = 0;
698
- do {
699
- const a = this.prerelease[i];
700
- const b = other.prerelease[i];
701
- debug_1('prerelease compare', i, a, b);
702
- if (a === undefined && b === undefined) {
703
- return 0
704
- } else if (b === undefined) {
705
- return 1
706
- } else if (a === undefined) {
707
- return -1
708
- } else if (a === b) {
709
- continue
710
- } else {
711
- return compareIdentifiers(a, b)
712
- }
713
- } while (++i)
714
- }
715
-
716
- compareBuild (other) {
717
- if (!(other instanceof SemVer)) {
718
- other = new SemVer(other, this.options);
719
- }
720
-
721
- let i = 0;
722
- do {
723
- const a = this.build[i];
724
- const b = other.build[i];
725
- debug_1('build compare', i, a, b);
726
- if (a === undefined && b === undefined) {
727
- return 0
728
- } else if (b === undefined) {
729
- return 1
730
- } else if (a === undefined) {
731
- return -1
732
- } else if (a === b) {
733
- continue
734
- } else {
735
- return compareIdentifiers(a, b)
736
- }
737
- } while (++i)
738
- }
739
-
740
- // preminor will bump the version up to the next minor release, and immediately
741
- // down to pre-release. premajor and prepatch work the same way.
742
- inc (release, identifier, identifierBase) {
743
- switch (release) {
744
- case 'premajor':
745
- this.prerelease.length = 0;
746
- this.patch = 0;
747
- this.minor = 0;
748
- this.major++;
749
- this.inc('pre', identifier, identifierBase);
750
- break
751
- case 'preminor':
752
- this.prerelease.length = 0;
753
- this.patch = 0;
754
- this.minor++;
755
- this.inc('pre', identifier, identifierBase);
756
- break
757
- case 'prepatch':
758
- // If this is already a prerelease, it will bump to the next version
759
- // drop any prereleases that might already exist, since they are not
760
- // relevant at this point.
761
- this.prerelease.length = 0;
762
- this.inc('patch', identifier, identifierBase);
763
- this.inc('pre', identifier, identifierBase);
764
- break
765
- // If the input is a non-prerelease version, this acts the same as
766
- // prepatch.
767
- case 'prerelease':
768
- if (this.prerelease.length === 0) {
769
- this.inc('patch', identifier, identifierBase);
770
- }
771
- this.inc('pre', identifier, identifierBase);
772
- break
773
-
774
- case 'major':
775
- // If this is a pre-major version, bump up to the same major version.
776
- // Otherwise increment major.
777
- // 1.0.0-5 bumps to 1.0.0
778
- // 1.1.0 bumps to 2.0.0
779
- if (
780
- this.minor !== 0 ||
781
- this.patch !== 0 ||
782
- this.prerelease.length === 0
783
- ) {
784
- this.major++;
785
- }
786
- this.minor = 0;
787
- this.patch = 0;
788
- this.prerelease = [];
789
- break
790
- case 'minor':
791
- // If this is a pre-minor version, bump up to the same minor version.
792
- // Otherwise increment minor.
793
- // 1.2.0-5 bumps to 1.2.0
794
- // 1.2.1 bumps to 1.3.0
795
- if (this.patch !== 0 || this.prerelease.length === 0) {
796
- this.minor++;
797
- }
798
- this.patch = 0;
799
- this.prerelease = [];
800
- break
801
- case 'patch':
802
- // If this is not a pre-release version, it will increment the patch.
803
- // If it is a pre-release it will bump up to the same patch version.
804
- // 1.2.0-5 patches to 1.2.0
805
- // 1.2.0 patches to 1.2.1
806
- if (this.prerelease.length === 0) {
807
- this.patch++;
808
- }
809
- this.prerelease = [];
810
- break
811
- // This probably shouldn't be used publicly.
812
- // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
813
- case 'pre': {
814
- const base = Number(identifierBase) ? 1 : 0;
815
-
816
- if (!identifier && identifierBase === false) {
817
- throw new Error('invalid increment argument: identifier is empty')
818
- }
819
-
820
- if (this.prerelease.length === 0) {
821
- this.prerelease = [base];
822
- } else {
823
- let i = this.prerelease.length;
824
- while (--i >= 0) {
825
- if (typeof this.prerelease[i] === 'number') {
826
- this.prerelease[i]++;
827
- i = -2;
828
- }
829
- }
830
- if (i === -1) {
831
- // didn't increment anything
832
- if (identifier === this.prerelease.join('.') && identifierBase === false) {
833
- throw new Error('invalid increment argument: identifier already exists')
834
- }
835
- this.prerelease.push(base);
836
- }
837
- }
838
- if (identifier) {
839
- // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
840
- // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
841
- let prerelease = [identifier, base];
842
- if (identifierBase === false) {
843
- prerelease = [identifier];
844
- }
845
- if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
846
- if (isNaN(this.prerelease[1])) {
847
- this.prerelease = prerelease;
848
- }
849
- } else {
850
- this.prerelease = prerelease;
851
- }
852
- }
853
- break
854
- }
855
- default:
856
- throw new Error(`invalid increment argument: ${release}`)
857
- }
858
- this.raw = this.format();
859
- if (this.build.length) {
860
- this.raw += `+${this.build.join('.')}`;
861
- }
862
- return this
863
- }
864
- }
865
-
866
- var semver = SemVer;
867
-
868
- const major = (a, loose) => new semver(a, loose).major;
869
- var major_1 = major;
870
-
871
- let lastReactDom;
238
+ let root;
872
239
  const cleanup = () => {
873
- if (lastReactDom) {
874
- const root = getContainerEl();
875
- lastReactDom.unmountComponentAtNode(root);
240
+ if (root) {
241
+ root.unmount();
242
+ root = null;
876
243
  return true;
877
244
  }
878
245
  return false;
879
246
  };
880
247
  /**
881
248
  * Mounts a React component into the DOM.
882
- * @param jsx {React.ReactNode} The React component to mount.
883
- * @param options {MountOptions} [options={}] options to pass to the mount function.
884
- * @param rerenderKey {string} [rerenderKey] A key to use to force a rerender.
885
- * @see {@link https://on.cypress.io/mounting-react} for more details.
249
+ * @param {import('react').JSX.Element} jsx The React component to mount.
250
+ * @param {MountOptions} options Options to pass to the mount function.
251
+ * @param {string} rerenderKey A key to use to force a rerender.
252
+ *
886
253
  * @example
887
254
  * import { mount } from '@cypress/react'
888
255
  * import { Stepper } from './Stepper'
@@ -892,57 +259,35 @@ const cleanup = () => {
892
259
  * cy.get('[data-cy=increment]').click()
893
260
  * cy.get('[data-cy=counter]').should('have.text', '1')
894
261
  * }
262
+ *
263
+ * @see {@link https://on.cypress.io/mounting-react} for more details.
264
+ *
265
+ * @returns {Cypress.Chainable<MountReturn>} The mounted component.
895
266
  */
896
267
  function mount(jsx, options = {}, rerenderKey) {
897
- if (major_1(React.version) === 18) {
898
- 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.';
899
- console.error(message);
900
- Cypress.log({ name: 'warning', message });
901
- }
902
268
  // Remove last mounted component if cy.mount is called more than once in a test
269
+ // React by default removes the last component when calling render, but we should remove the root
270
+ // to wipe away any state
903
271
  cleanup();
904
272
  const internalOptions = {
905
273
  reactDom: ReactDOM,
906
- render: (reactComponent, el, reactDomToUse) => {
907
- lastReactDom = (reactDomToUse || ReactDOM);
908
- return lastReactDom.render(reactComponent, el);
274
+ render: (reactComponent, el) => {
275
+ if (!root) {
276
+ root = ReactDOM.createRoot(el);
277
+ }
278
+ return root.render(reactComponent);
909
279
  },
910
280
  unmount: internalUnmount,
911
281
  cleanup,
912
282
  };
913
283
  return makeMountFn('mount', jsx, Object.assign({ ReactDom: ReactDOM }, options), rerenderKey, internalOptions);
914
284
  }
915
- /**
916
- * Unmounts the component from the DOM.
917
- * @internal
918
- * @param options - Options for unmounting.
919
- */
920
285
  function internalUnmount(options = { log: true }) {
921
286
  return makeUnmountFn(options);
922
287
  }
923
- /**
924
- * Removed as of Cypress 11.0.0.
925
- * @see https://on.cypress.io/migration-11-0-0-component-testing-updates
926
- */
927
- function unmount(options = { log: true }) {
928
- // @ts-expect-error - undocumented API
929
- Cypress.utils.throwErrByPath('mount.unmount');
930
- }
931
-
932
- /**
933
- * Mounts a React hook function in a test component for testing.
934
- * Removed as of Cypress 11.0.0.
935
- * @see https://on.cypress.io/migration-11-0-0-component-testing-updates
936
- */
937
- const mountHook = (hookFn) => {
938
- // @ts-expect-error - internal API
939
- Cypress.utils.throwErrByPath('mount.mount_hook');
940
- };
941
288
 
942
289
  exports.createMount = createMount;
943
290
  exports.getContainerEl = getContainerEl;
944
291
  exports.makeMountFn = makeMountFn;
945
292
  exports.makeUnmountFn = makeUnmountFn;
946
293
  exports.mount = mount;
947
- exports.mountHook = mountHook;
948
- exports.unmount = unmount;