cypress 10.3.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.
Files changed (72) 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 +7 -2
  8. package/lib/exec/spawn.js +7 -2
  9. package/mount-utils/CHANGELOG.md +7 -1
  10. package/mount-utils/README.md +7 -0
  11. package/mount-utils/dist/index.js +8 -1
  12. package/mount-utils/package.json +1 -0
  13. package/package.json +26 -10
  14. package/react/CHANGELOG.md +13 -19
  15. package/react/README.md +28 -323
  16. package/react/dist/createMount.d.ts +28 -0
  17. package/react/dist/cypress-react.cjs.js +643 -99
  18. package/react/dist/cypress-react.esm-bundler.js +640 -100
  19. package/react/dist/getDisplayName.d.ts +1 -1
  20. package/react/dist/index.d.ts +2 -0
  21. package/react/dist/mount.d.ts +5 -141
  22. package/react/dist/types.d.ts +44 -0
  23. package/react/package.json +3 -5
  24. package/react18/CHANGELOG.md +6 -0
  25. package/react18/dist/cypress-react.cjs.js +633 -0
  26. package/react18/dist/cypress-react.esm-bundler.js +605 -0
  27. package/react18/dist/index.d.ts +5 -0
  28. package/react18/package.json +59 -0
  29. package/types/cypress.d.ts +24 -3
  30. package/types/index.d.ts +1 -1
  31. package/types/{net-stubbing.ts → net-stubbing.d.ts} +0 -0
  32. package/vue/CHANGELOG.md +16 -17
  33. package/vue/README.md +17 -607
  34. package/vue/dist/@vue/test-utils/baseWrapper.d.ts +63 -0
  35. package/vue/dist/@vue/test-utils/components/RouterLinkStub.d.ts +21 -0
  36. package/vue/dist/@vue/test-utils/config.d.ts +30 -0
  37. package/vue/dist/@vue/test-utils/constants/dom-events.d.ts +900 -0
  38. package/vue/dist/@vue/test-utils/createDomEvent.d.ts +9 -0
  39. package/vue/dist/@vue/test-utils/domWrapper.d.ts +18 -0
  40. package/vue/dist/@vue/test-utils/emit.d.ts +5 -0
  41. package/vue/dist/@vue/test-utils/errorWrapper.d.ts +1 -0
  42. package/vue/dist/@vue/test-utils/index.d.ts +11 -0
  43. package/vue/dist/@vue/test-utils/interfaces/wrapperLike.d.ts +56 -0
  44. package/vue/dist/@vue/test-utils/mount.d.ts +35 -0
  45. package/vue/dist/@vue/test-utils/stubs.d.ts +22 -0
  46. package/vue/dist/@vue/test-utils/types.d.ts +125 -0
  47. package/vue/dist/@vue/test-utils/utils/autoUnmount.d.ts +5 -0
  48. package/vue/dist/@vue/test-utils/utils/compileSlots.d.ts +2 -0
  49. package/vue/dist/@vue/test-utils/utils/componentName.d.ts +4 -0
  50. package/vue/dist/@vue/test-utils/utils/find.d.ts +10 -0
  51. package/vue/dist/@vue/test-utils/utils/flushPromises.d.ts +1 -0
  52. package/vue/dist/@vue/test-utils/utils/getRootNodes.d.ts +2 -0
  53. package/vue/dist/@vue/test-utils/utils/isElement.d.ts +1 -0
  54. package/vue/dist/@vue/test-utils/utils/isElementVisible.d.ts +6 -0
  55. package/vue/dist/@vue/test-utils/utils/matchName.d.ts +1 -0
  56. package/vue/dist/@vue/test-utils/utils/stringifyNode.d.ts +1 -0
  57. package/vue/dist/@vue/test-utils/utils/vueCompatSupport.d.ts +8 -0
  58. package/vue/dist/@vue/test-utils/utils/vueShared.d.ts +3 -0
  59. package/vue/dist/@vue/test-utils/utils.d.ts +13 -0
  60. package/vue/dist/@vue/test-utils/vueWrapper.d.ts +35 -0
  61. package/vue/dist/@vue/test-utils/wrapperFactory.d.ts +14 -0
  62. package/vue/dist/cypress-vue.cjs.js +5585 -5211
  63. package/vue/dist/cypress-vue.esm-bundler.js +5586 -5213
  64. package/vue/dist/index.d.ts +35 -3
  65. package/vue/package.json +11 -8
  66. package/vue2/CHANGELOG.md +7 -0
  67. package/vue2/README.md +11 -627
  68. package/vue2/dist/cypress-vue2.browser.js +267 -261
  69. package/vue2/dist/cypress-vue2.cjs.js +266 -260
  70. package/vue2/dist/cypress-vue2.esm-bundler.js +264 -258
  71. package/vue2/package.json +1 -1
  72. package/react/dist/cypress-react.browser.js +0 -497
@@ -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.
@@ -85,7 +86,7 @@ const getContainerEl = () => {
85
86
  if (el) {
86
87
  return el;
87
88
  }
88
- throw Error(`No element found that matches selector ${ROOT_SELECTOR}. Please use the mount utils to mount it properly`);
89
+ 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.`);
89
90
  };
90
91
  /**
91
92
  * Remove any style or extra link elements from the iframe placeholder
@@ -201,6 +202,13 @@ const injectStylesBeforeElement = (options, document, el) => {
201
202
  return insertLocalCssFiles(cssFiles, document, el, options.log);
202
203
  };
203
204
  function setupHooks(optionalCallback) {
205
+ // Consumed by the framework "mount" libs. A user might register their own mount in the scaffolded 'commands.js'
206
+ // file that is imported by e2e and component support files by default. We don't want CT side effects to run when e2e
207
+ // testing so we early return.
208
+ // System test to verify CT side effects do not pollute e2e: system-tests/test/e2e_with_mount_import_spec.ts
209
+ if (Cypress.testingType !== 'component') {
210
+ return;
211
+ }
204
212
  // When running component specs, we cannot allow "cy.visit"
205
213
  // because it will wipe out our preparation work, and does not make much sense
206
214
  // thus we overwrite "cy.visit" to throw an error
@@ -223,37 +231,22 @@ var injectStyles = function (options) {
223
231
  return injectStylesBeforeElement(options, document, el);
224
232
  };
225
233
  };
234
+ var mountCleanup;
226
235
  /**
227
- * Mount a React component in a blank document; register it as an alias
228
- * To access: use an alias or original component reference
229
- * @function mount
230
- * @param {React.ReactElement} jsx - component to mount
231
- * @param {MountOptions} [options] - options, like alias, styles
232
- * @see https://github.com/bahmutov/@cypress/react
233
- * @see https://glebbahmutov.com/blog/my-vision-for-component-tests/
234
- * @example
235
- ```
236
- import Hello from './hello.jsx'
237
- import { mount } from '@cypress/react'
238
- it('works', () => {
239
- mount(<Hello onClick={cy.stub()} />)
240
- // use Cypress commands
241
- cy.contains('Hello').click()
242
- })
243
- ```
244
- **/
245
- var mount = function (jsx, options) {
246
- if (options === void 0) { options = {}; }
247
- return _mount('mount', jsx, options);
248
- };
249
- var lastMountedReactDom;
250
- /**
251
- * @see `mount`
252
- * @param type The type of mount executed
253
- * @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.
254
243
  */
255
- var _mount = function (type, jsx, options, rerenderKey) {
244
+ var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOptions) {
256
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;
257
250
  // Get the display name property via the component constructor
258
251
  // @ts-ignore FIXME
259
252
  var componentName = getDisplayName(jsx.type, options.alias);
@@ -266,8 +259,7 @@ var _mount = function (type, jsx, options, rerenderKey) {
266
259
  .then(injectStyles(options))
267
260
  .then(function () {
268
261
  var _a, _b, _c;
269
- var reactDomToUse = options.ReactDom || ReactDOM;
270
- lastMountedReactDom = reactDomToUse;
262
+ var reactDomToUse = internalMountOptions.reactDom;
271
263
  var el = getContainerEl();
272
264
  if (!el) {
273
265
  throw new Error([
@@ -284,7 +276,7 @@ var _mount = function (type, jsx, options, rerenderKey) {
284
276
  // since we always surround the component with a fragment
285
277
  // let's get back the original component
286
278
  var userComponent = reactComponent.props.children;
287
- reactDomToUse.render(reactComponent, el);
279
+ internalMountOptions.render(reactComponent, el, reactDomToUse);
288
280
  if (options.log !== false) {
289
281
  Cypress.log({
290
282
  name: type,
@@ -309,8 +301,8 @@ var _mount = function (type, jsx, options, rerenderKey) {
309
301
  .then(function () {
310
302
  return cy.wrap({
311
303
  component: userComponent,
312
- rerender: function (newComponent) { return _mount('rerender', newComponent, options, key); },
313
- unmount: function () { return _unmount({ boundComponentMessage: jsxComponentName, log: true }); },
304
+ rerender: function (newComponent) { return makeMountFn('rerender', newComponent, options, key, internalMountOptions); },
305
+ unmount: internalMountOptions.unmount,
314
306
  }, { log: false });
315
307
  })
316
308
  // by waiting, we delaying test execution for the next tick of event loop
@@ -321,88 +313,636 @@ var _mount = function (type, jsx, options, rerenderKey) {
321
313
  });
322
314
  };
323
315
  /**
324
- * Removes the mounted component. Notice this command automatically
325
- * queues up the `unmount` into Cypress chain, thus you don't need `.then`
326
- * to call it.
327
- * @see https://github.com/cypress-io/cypress/tree/develop/npm/react/cypress/component/basic/unmount
328
- * @example
329
- ```
330
- import { mount, unmount } from '@cypress/react'
331
- it('works', () => {
332
- mount(...)
333
- // interact with the component using Cypress commands
334
- // whenever you want to unmount
335
- unmount()
336
- })
337
- ```
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.
338
321
  */
339
- // @ts-ignore
340
- var unmount = function (options) {
341
- if (options === void 0) { options = { log: true }; }
342
- return _unmount(options);
343
- };
344
- var _unmount = function (options) {
322
+ var makeUnmountFn = function (options) {
345
323
  return cy.then(function () {
346
- return cy.get(ROOT_SELECTOR, { log: false }).then(function ($el) {
347
- var _a;
348
- if (lastMountedReactDom) {
349
- var wasUnmounted = lastMountedReactDom.unmountComponentAtNode($el[0]);
350
- if (wasUnmounted && options.log) {
351
- Cypress.log({
352
- name: 'unmount',
353
- type: 'parent',
354
- message: [(_a = options.boundComponentMessage) !== null && _a !== void 0 ? _a : 'Unmounted component'],
355
- consoleProps: function () {
356
- return {
357
- description: 'Unmounts React component',
358
- parent: $el[0],
359
- home: 'https://github.com/cypress-io/cypress',
360
- };
361
- },
362
- });
363
- }
364
- }
365
- });
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
+ }
366
340
  });
367
341
  };
368
342
  // Cleanup before each run
369
343
  // NOTE: we cannot use unmount here because
370
344
  // we are not in the context of a test
371
345
  var preMountCleanup = function () {
372
- var el = getContainerEl();
373
- if (el && lastMountedReactDom) {
374
- lastMountedReactDom.unmountComponentAtNode(el);
375
- }
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);
376
351
  };
377
- /**
378
- * Creates new instance of `mount` function with default options
379
- * @function createMount
380
- * @param {MountOptions} [defaultOptions] - defaultOptions for returned `mount` function
381
- * @returns new instance of `mount` with assigned options
382
- * @example
383
- * ```
384
- * import Hello from './hello.jsx'
385
- * import { createMount } from '@cypress/react'
386
- *
387
- * const mount = createMount({ strict: true, cssFile: 'path/to/any/css/file.css' })
388
- *
389
- * it('works', () => {
390
- * mount(<Hello />)
391
- * // use Cypress commands
392
- * cy.get('button').should('have.css', 'color', 'rgb(124, 12, 109)')
393
- * })
394
- ```
395
- **/
396
352
  var createMount = function (defaultOptions) {
397
353
  return function (element, options) {
398
- return mount(element, __assign(__assign({}, defaultOptions), options));
354
+ return _mount(element, __assign(__assign({}, defaultOptions), options));
399
355
  };
400
356
  };
357
+ // Side effects from "import { mount } from '@cypress/<my-framework>'" are annoying, we should avoid doing this
358
+ // by creating an explicit function/import that the user can register in their 'component.js' support file,
359
+ // such as:
360
+ // import 'cypress/<my-framework>/support'
361
+ // or
362
+ // import { registerCT } from 'cypress/<my-framework>'
363
+ // registerCT()
364
+ // Note: This would be a breaking change
401
365
  // it is required to unmount component in beforeEach hook in order to provide a clean state inside test
402
366
  // because `mount` can be called after some preparation that can side effect unmount
403
367
  // @see npm/react/cypress/component/advanced/set-timeout-example/loading-indicator-spec.js
404
368
  setupHooks(preMountCleanup);
405
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
+
406
946
  // mounting hooks inside a test component mostly copied from
407
947
  // https://github.com/testing-library/react-hooks-testing-library/blob/master/src/pure.js
408
948
  function resultContainer() {
@@ -464,4 +1004,4 @@ var mountHook = function (hookFn) {
464
1004
  return mount(componentTest).then(function () { return result; });
465
1005
  };
466
1006
 
467
- export { createMount, mount, mountHook, unmount };
1007
+ export { createMount, makeMountFn, makeUnmountFn, mount, mountHook, unmount };