cypress 10.3.1 → 10.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. package/angular/CHANGELOG.md +55 -0
  2. package/angular/README.md +154 -0
  3. package/angular/dist/index.d.ts +1 -0
  4. package/angular/dist/index.js +263 -0
  5. package/angular/dist/mount.d.ts +111 -0
  6. package/angular/package.json +70 -0
  7. package/lib/exec/open.js +6 -0
  8. package/lib/tasks/download.js +4 -3
  9. package/mount-utils/CHANGELOG.md +7 -1
  10. package/mount-utils/README.md +7 -0
  11. package/package.json +16 -5
  12. package/react/CHANGELOG.md +20 -19
  13. package/react/README.md +28 -323
  14. package/react/dist/createMount.d.ts +28 -0
  15. package/react/dist/cypress-react.cjs.js +627 -98
  16. package/react/dist/cypress-react.esm-bundler.js +624 -99
  17. package/react/dist/getDisplayName.d.ts +1 -1
  18. package/react/dist/index.d.ts +2 -0
  19. package/react/dist/mount.d.ts +5 -141
  20. package/react/dist/types.d.ts +44 -0
  21. package/react/package.json +3 -5
  22. package/react18/CHANGELOG.md +13 -0
  23. package/react18/dist/cypress-react.cjs.js +633 -0
  24. package/react18/dist/cypress-react.esm-bundler.js +605 -0
  25. package/react18/dist/index.d.ts +5 -0
  26. package/react18/package.json +59 -0
  27. package/types/cypress.d.ts +28 -2
  28. package/types/index.d.ts +1 -1
  29. package/types/{net-stubbing.ts → net-stubbing.d.ts} +0 -0
  30. package/vue/CHANGELOG.md +16 -17
  31. package/vue/README.md +17 -608
  32. package/vue/dist/@vue/test-utils/baseWrapper.d.ts +3 -1
  33. package/vue/dist/@vue/test-utils/config.d.ts +4 -2
  34. package/vue/dist/@vue/test-utils/emit.d.ts +1 -0
  35. package/vue/dist/@vue/test-utils/index.d.ts +2 -1
  36. package/vue/dist/@vue/test-utils/interfaces/wrapperLike.d.ts +2 -2
  37. package/vue/dist/@vue/test-utils/mount.d.ts +2 -0
  38. package/vue/dist/@vue/test-utils/stubs.d.ts +2 -6
  39. package/vue/dist/@vue/test-utils/types.d.ts +1 -1
  40. package/vue/dist/@vue/test-utils/vueWrapper.d.ts +2 -1
  41. package/vue/dist/cypress-vue.cjs.js +5379 -5090
  42. package/vue/dist/cypress-vue.esm-bundler.js +5380 -5091
  43. package/vue/dist/index.d.ts +1 -0
  44. package/vue/package.json +2 -3
  45. package/vue2/CHANGELOG.md +7 -0
  46. package/vue2/README.md +11 -627
  47. package/vue2/dist/cypress-vue2.browser.js +251 -260
  48. package/vue2/dist/cypress-vue2.cjs.js +250 -259
  49. package/vue2/dist/cypress-vue2.esm-bundler.js +248 -257
  50. package/react/dist/cypress-react.browser.js +0 -512
@@ -6,7 +6,8 @@
6
6
  */
7
7
 
8
8
  import * as React from 'react';
9
- import * as ReactDOM from 'react-dom';
9
+ import React__default from 'react';
10
+ import ReactDOM from 'react-dom';
10
11
 
11
12
  /******************************************************************************
12
13
  Copyright (c) Microsoft Corporation.
@@ -230,37 +231,22 @@ var injectStyles = function (options) {
230
231
  return injectStylesBeforeElement(options, document, el);
231
232
  };
232
233
  };
234
+ var mountCleanup;
233
235
  /**
234
- * Mount a React component in a blank document; register it as an alias
235
- * To access: use an alias or original component reference
236
- * @function mount
237
- * @param {React.ReactElement} jsx - component to mount
238
- * @param {MountOptions} [options] - options, like alias, styles
239
- * @see https://github.com/bahmutov/@cypress/react
240
- * @see https://glebbahmutov.com/blog/my-vision-for-component-tests/
241
- * @example
242
- ```
243
- import Hello from './hello.jsx'
244
- import { mount } from '@cypress/react'
245
- it('works', () => {
246
- mount(<Hello onClick={cy.stub()} />)
247
- // use Cypress commands
248
- cy.contains('Hello').click()
249
- })
250
- ```
251
- **/
252
- var mount = function (jsx, options) {
253
- if (options === void 0) { options = {}; }
254
- return _mount('mount', jsx, options);
255
- };
256
- var lastMountedReactDom;
257
- /**
258
- * @see `mount`
259
- * @param type The type of mount executed
260
- * @param rerenderKey If specified, use the provided key rather than generating a new one
236
+ * Create an `mount` function. Performs all the non-React-version specific
237
+ * behavior related to mounting. The React-version-specific code
238
+ * is injected. This helps us to maintain a consistent public API
239
+ * and handle breaking changes in React's rendering API.
240
+ *
241
+ * This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
242
+ * or people writing adapters for third-party, custom adapters.
261
243
  */
262
- var _mount = function (type, jsx, options, rerenderKey) {
244
+ var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOptions) {
263
245
  if (options === void 0) { options = {}; }
246
+ if (!internalMountOptions) {
247
+ throw Error('internalMountOptions must be provided with `render` and `reactDom` parameters');
248
+ }
249
+ mountCleanup = internalMountOptions.cleanup;
264
250
  // Get the display name property via the component constructor
265
251
  // @ts-ignore FIXME
266
252
  var componentName = getDisplayName(jsx.type, options.alias);
@@ -273,8 +259,7 @@ var _mount = function (type, jsx, options, rerenderKey) {
273
259
  .then(injectStyles(options))
274
260
  .then(function () {
275
261
  var _a, _b, _c;
276
- var reactDomToUse = options.ReactDom || ReactDOM;
277
- lastMountedReactDom = reactDomToUse;
262
+ var reactDomToUse = internalMountOptions.reactDom;
278
263
  var el = getContainerEl();
279
264
  if (!el) {
280
265
  throw new Error([
@@ -291,7 +276,7 @@ var _mount = function (type, jsx, options, rerenderKey) {
291
276
  // since we always surround the component with a fragment
292
277
  // let's get back the original component
293
278
  var userComponent = reactComponent.props.children;
294
- reactDomToUse.render(reactComponent, el);
279
+ internalMountOptions.render(reactComponent, el, reactDomToUse);
295
280
  if (options.log !== false) {
296
281
  Cypress.log({
297
282
  name: type,
@@ -316,8 +301,8 @@ var _mount = function (type, jsx, options, rerenderKey) {
316
301
  .then(function () {
317
302
  return cy.wrap({
318
303
  component: userComponent,
319
- rerender: function (newComponent) { return _mount('rerender', newComponent, options, key); },
320
- unmount: function () { return _unmount({ boundComponentMessage: jsxComponentName, log: true }); },
304
+ rerender: function (newComponent) { return makeMountFn('rerender', newComponent, options, key, internalMountOptions); },
305
+ unmount: internalMountOptions.unmount,
321
306
  }, { log: false });
322
307
  })
323
308
  // by waiting, we delaying test execution for the next tick of event loop
@@ -328,81 +313,45 @@ var _mount = function (type, jsx, options, rerenderKey) {
328
313
  });
329
314
  };
330
315
  /**
331
- * Removes the mounted component. Notice this command automatically
332
- * queues up the `unmount` into Cypress chain, thus you don't need `.then`
333
- * to call it.
334
- * @see https://github.com/cypress-io/cypress/tree/develop/npm/react/cypress/component/basic/unmount
335
- * @example
336
- ```
337
- import { mount, unmount } from '@cypress/react'
338
- it('works', () => {
339
- mount(...)
340
- // interact with the component using Cypress commands
341
- // whenever you want to unmount
342
- unmount()
343
- })
344
- ```
316
+ * Create an `unmount` function. Performs all the non-React-version specific
317
+ * behavior related to unmounting.
318
+ *
319
+ * This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
320
+ * or people writing adapters for third-party, custom adapters.
345
321
  */
346
- // @ts-ignore
347
- var unmount = function (options) {
348
- if (options === void 0) { options = { log: true }; }
349
- return _unmount(options);
350
- };
351
- var _unmount = function (options) {
322
+ var makeUnmountFn = function (options) {
352
323
  return cy.then(function () {
353
- return cy.get(ROOT_SELECTOR, { log: false }).then(function ($el) {
354
- var _a;
355
- if (lastMountedReactDom) {
356
- var wasUnmounted = lastMountedReactDom.unmountComponentAtNode($el[0]);
357
- if (wasUnmounted && options.log) {
358
- Cypress.log({
359
- name: 'unmount',
360
- type: 'parent',
361
- message: [(_a = options.boundComponentMessage) !== null && _a !== void 0 ? _a : 'Unmounted component'],
362
- consoleProps: function () {
363
- return {
364
- description: 'Unmounts React component',
365
- parent: $el[0],
366
- home: 'https://github.com/cypress-io/cypress',
367
- };
368
- },
369
- });
370
- }
371
- }
372
- });
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
+ }
373
340
  });
374
341
  };
375
342
  // Cleanup before each run
376
343
  // NOTE: we cannot use unmount here because
377
344
  // we are not in the context of a test
378
345
  var preMountCleanup = function () {
379
- var el = getContainerEl();
380
- if (el && lastMountedReactDom) {
381
- lastMountedReactDom.unmountComponentAtNode(el);
382
- }
346
+ mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
347
+ };
348
+ var _mount = function (jsx, options) {
349
+ if (options === void 0) { options = {}; }
350
+ return makeMountFn('mount', jsx, options);
383
351
  };
384
- /**
385
- * Creates new instance of `mount` function with default options
386
- * @function createMount
387
- * @param {MountOptions} [defaultOptions] - defaultOptions for returned `mount` function
388
- * @returns new instance of `mount` with assigned options
389
- * @example
390
- * ```
391
- * import Hello from './hello.jsx'
392
- * import { createMount } from '@cypress/react'
393
- *
394
- * const mount = createMount({ strict: true, cssFile: 'path/to/any/css/file.css' })
395
- *
396
- * it('works', () => {
397
- * mount(<Hello />)
398
- * // use Cypress commands
399
- * cy.get('button').should('have.css', 'color', 'rgb(124, 12, 109)')
400
- * })
401
- ```
402
- **/
403
352
  var createMount = function (defaultOptions) {
404
353
  return function (element, options) {
405
- return mount(element, __assign(__assign({}, defaultOptions), options));
354
+ return _mount(element, __assign(__assign({}, defaultOptions), options));
406
355
  };
407
356
  };
408
357
  // Side effects from "import { mount } from '@cypress/<my-framework>'" are annoying, we should avoid doing this
@@ -418,6 +367,582 @@ var createMount = function (defaultOptions) {
418
367
  // @see npm/react/cypress/component/advanced/set-timeout-example/loading-indicator-spec.js
419
368
  setupHooks(preMountCleanup);
420
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
+ };
923
+ function mount(jsx, options, rerenderKey) {
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
+ }
930
+ var internalOptions = {
931
+ reactDom: ReactDOM,
932
+ render: function (reactComponent, el, reactDomToUse) {
933
+ lastReactDom = (reactDomToUse || ReactDOM);
934
+ return lastReactDom.render(reactComponent, el);
935
+ },
936
+ unmount: unmount,
937
+ cleanup: cleanup,
938
+ };
939
+ return makeMountFn('mount', jsx, __assign({ ReactDom: ReactDOM }, options), rerenderKey, internalOptions);
940
+ }
941
+ function unmount(options) {
942
+ if (options === void 0) { options = { log: true }; }
943
+ return makeUnmountFn(options);
944
+ }
945
+
421
946
  // mounting hooks inside a test component mostly copied from
422
947
  // https://github.com/testing-library/react-hooks-testing-library/blob/master/src/pure.js
423
948
  function resultContainer() {
@@ -479,4 +1004,4 @@ var mountHook = function (hookFn) {
479
1004
  return mount(componentTest).then(function () { return result; });
480
1005
  };
481
1006
 
482
- export { createMount, mount, mountHook, unmount };
1007
+ export { createMount, makeMountFn, makeUnmountFn, mount, mountHook, unmount };