cypress 13.2.0 → 13.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. package/angular/angular/README.md +10 -0
  2. package/angular/angular/dist/index.d.ts +128 -0
  3. package/angular/angular/dist/index.js +333 -0
  4. package/angular/angular/package.json +77 -0
  5. package/angular/package.json +9 -1
  6. package/lib/exec/spawn.js +1 -1
  7. package/lib/util.js +1 -1
  8. package/mount-utils/mount-utils/README.md +140 -0
  9. package/mount-utils/mount-utils/dist/index.d.ts +40 -0
  10. package/mount-utils/mount-utils/dist/index.js +68 -0
  11. package/mount-utils/mount-utils/package.json +46 -0
  12. package/mount-utils/package.json +10 -1
  13. package/package.json +20 -4
  14. package/react/package.json +13 -0
  15. package/react/react/README.md +14 -0
  16. package/react/react/dist/cypress-react.cjs.js +943 -0
  17. package/react/react/dist/cypress-react.esm-bundler.js +917 -0
  18. package/react/react/dist/index.d.ts +111 -0
  19. package/react/react/package.json +111 -0
  20. package/react18/package.json +10 -0
  21. package/react18/react18/README.md +7 -0
  22. package/react18/react18/dist/cypress-react.cjs.js +592 -0
  23. package/react18/react18/dist/cypress-react.esm-bundler.js +569 -0
  24. package/react18/react18/dist/index.d.ts +78 -0
  25. package/react18/react18/package.json +71 -0
  26. package/svelte/package.json +13 -1
  27. package/svelte/svelte/README.md +15 -0
  28. package/svelte/svelte/dist/cypress-svelte.cjs.js +122 -0
  29. package/svelte/svelte/dist/cypress-svelte.esm-bundler.js +120 -0
  30. package/svelte/svelte/dist/index.d.ts +201 -0
  31. package/svelte/svelte/package.json +56 -0
  32. package/types/cypress.d.ts +2 -2
  33. package/vue/package.json +13 -1
  34. package/vue/vue/README.md +14 -0
  35. package/vue/vue/dist/cypress-vue.cjs.js +8582 -0
  36. package/vue/vue/dist/cypress-vue.esm-bundler.js +8560 -0
  37. package/vue/vue/dist/index.d.ts +1392 -0
  38. package/vue/vue/package.json +96 -0
  39. package/vue2/dist/cypress-vue2.cjs.js +1 -1
  40. package/vue2/dist/cypress-vue2.esm-bundler.js +1 -1
  41. package/vue2/package.json +13 -1
  42. package/vue2/vue2/README.md +7 -0
  43. package/vue2/vue2/dist/cypress-vue2.cjs.js +20045 -0
  44. package/vue2/vue2/dist/cypress-vue2.esm-bundler.js +20042 -0
  45. package/vue2/vue2/dist/index.d.ts +364 -0
  46. package/vue2/vue2/package.json +65 -0
@@ -0,0 +1,943 @@
1
+
2
+ /**
3
+ * @cypress/react v0.0.0-development
4
+ * (c) 2023 Cypress.io
5
+ * Released under the MIT License
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ var React = require('react');
11
+ var ReactDOM = require('react-dom');
12
+
13
+ function _interopNamespaceDefault(e) {
14
+ var n = Object.create(null);
15
+ if (e) {
16
+ Object.keys(e).forEach(function (k) {
17
+ if (k !== 'default') {
18
+ var d = Object.getOwnPropertyDescriptor(e, k);
19
+ Object.defineProperty(n, k, d.get ? d : {
20
+ enumerable: true,
21
+ get: function () { return e[k]; }
22
+ });
23
+ }
24
+ });
25
+ }
26
+ n.default = e;
27
+ return Object.freeze(n);
28
+ }
29
+
30
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
31
+
32
+ /**
33
+ * Gets the display name of the component when possible.
34
+ * @param type {JSX} The type object returned from creating the react element.
35
+ * @param fallbackName {string} The alias, or fallback name to use when the name cannot be derived.
36
+ * @link https://github.com/facebook/react-devtools/blob/master/backend/getDisplayName.js
37
+ */
38
+ function getDisplayName(node, fallbackName = 'Unknown') {
39
+ const type = node === null || node === void 0 ? void 0 : node.type;
40
+ if (!type) {
41
+ return fallbackName;
42
+ }
43
+ let displayName = null;
44
+ // The displayName property is not guaranteed to be a string.
45
+ // It's only safe to use for our purposes if it's a string.
46
+ // github.com/facebook/react-devtools/issues/803
47
+ if (typeof type.displayName === 'string') {
48
+ displayName = type.displayName;
49
+ }
50
+ if (!displayName) {
51
+ displayName = type.name || fallbackName;
52
+ }
53
+ // Facebook-specific hack to turn "Image [from Image.react]" into just "Image".
54
+ // We need displayName with module name for error reports but it clutters the DevTools.
55
+ const match = displayName.match(/^(.*) \[from (.*)\]$/);
56
+ if (match) {
57
+ const componentName = match[1];
58
+ const moduleName = match[2];
59
+ if (componentName && moduleName) {
60
+ if (moduleName === componentName ||
61
+ moduleName.startsWith(`${componentName}.`)) {
62
+ displayName = componentName;
63
+ }
64
+ }
65
+ }
66
+ return displayName;
67
+ }
68
+
69
+ const ROOT_SELECTOR = '[data-cy-root]';
70
+ /**
71
+ * Gets the root element used to mount the component.
72
+ * @returns {HTMLElement} The root element
73
+ * @throws {Error} If the root element is not found
74
+ */
75
+ const getContainerEl = () => {
76
+ const el = document.querySelector(ROOT_SELECTOR);
77
+ if (el) {
78
+ return el;
79
+ }
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
+ };
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
+ /**
90
+ * Utility function to register CT side effects and run cleanup code during the "test:before:run" Cypress hook
91
+ * @param optionalCallback Callback to be called before the next test runs
92
+ */
93
+ function setupHooks(optionalCallback) {
94
+ // We don't want CT side effects to run when e2e
95
+ // testing so we early return.
96
+ // System test to verify CT side effects do not pollute e2e: system-tests/test/e2e_with_mount_import_spec.ts
97
+ if (Cypress.testingType !== 'component') {
98
+ return;
99
+ }
100
+ // When running component specs, we cannot allow "cy.visit"
101
+ // because it will wipe out our preparation work, and does not make much sense
102
+ // thus we overwrite "cy.visit" to throw an error
103
+ Cypress.Commands.overwrite('visit', () => {
104
+ throw new Error('cy.visit from a component spec is not allowed');
105
+ });
106
+ Cypress.Commands.overwrite('session', () => {
107
+ throw new Error('cy.session from a component spec is not allowed');
108
+ });
109
+ Cypress.Commands.overwrite('origin', () => {
110
+ throw new Error('cy.origin from a component spec is not allowed');
111
+ });
112
+ // @ts-ignore
113
+ Cypress.on('test:before:after:run:async', () => {
114
+ optionalCallback === null || optionalCallback === void 0 ? void 0 : optionalCallback();
115
+ });
116
+ }
117
+
118
+ let mountCleanup;
119
+ /**
120
+ * Create an `mount` function. Performs all the non-React-version specific
121
+ * behavior related to mounting. The React-version-specific code
122
+ * is injected. This helps us to maintain a consistent public API
123
+ * and handle breaking changes in React's rendering API.
124
+ *
125
+ * This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
126
+ * or people writing adapters for third-party, custom adapters.
127
+ */
128
+ const makeMountFn = (type, jsx, options = {}, rerenderKey, internalMountOptions) => {
129
+ if (!internalMountOptions) {
130
+ throw Error('internalMountOptions must be provided with `render` and `reactDom` parameters');
131
+ }
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
+ mountCleanup = internalMountOptions.cleanup;
139
+ return cy
140
+ .then(() => {
141
+ var _a, _b, _c;
142
+ const reactDomToUse = internalMountOptions.reactDom;
143
+ const el = getContainerEl();
144
+ if (!el) {
145
+ throw new Error([
146
+ `[@cypress/react] 🔥 Hmm, cannot find root element to mount the component. Searched for ${ROOT_SELECTOR}`,
147
+ ].join(' '));
148
+ }
149
+ const key = rerenderKey !== null && rerenderKey !== void 0 ? rerenderKey :
150
+ // @ts-ignore provide unique key to the the wrapped component to make sure we are rerendering between tests
151
+ (((_c = (_b = (_a = Cypress === null || Cypress === void 0 ? void 0 : Cypress.mocha) === null || _a === void 0 ? void 0 : _a.getRunner()) === null || _b === void 0 ? void 0 : _b.test) === null || _c === void 0 ? void 0 : _c.title) || '') + Math.random();
152
+ const props = {
153
+ key,
154
+ };
155
+ const reactComponent = React__namespace.createElement(options.strict ? React__namespace.StrictMode : React__namespace.Fragment, props, jsx);
156
+ // since we always surround the component with a fragment
157
+ // let's get back the original component
158
+ const userComponent = reactComponent.props.children;
159
+ internalMountOptions.render(reactComponent, el, reactDomToUse);
160
+ return (cy.wrap(userComponent, { log: false })
161
+ .then(() => {
162
+ return cy.wrap({
163
+ component: userComponent,
164
+ rerender: (newComponent) => makeMountFn('rerender', newComponent, options, key, internalMountOptions),
165
+ unmount: () => {
166
+ // @ts-expect-error - undocumented API
167
+ Cypress.utils.throwErrByPath('mount.unmount');
168
+ },
169
+ }, { log: false });
170
+ })
171
+ // by waiting, we delaying test execution for the next tick of event loop
172
+ // and letting hooks and component lifecycle methods to execute mount
173
+ // https://github.com/bahmutov/cypress-react-unit-test/issues/200
174
+ .wait(0, { log: false })
175
+ .then(() => {
176
+ if (options.log !== false) {
177
+ // Get the display name property via the component constructor
178
+ // @ts-ignore FIXME
179
+ const componentName = getDisplayName(jsx);
180
+ const jsxComponentName = `<${componentName} ... />`;
181
+ Cypress.log({
182
+ name: type,
183
+ type: 'parent',
184
+ message: [jsxComponentName],
185
+ // @ts-ignore
186
+ $el: el.children.item(0),
187
+ consoleProps: () => {
188
+ return {
189
+ // @ts-ignore protect the use of jsx functional components use ReactNode
190
+ props: jsx === null || jsx === void 0 ? void 0 : jsx.props,
191
+ description: type === 'mount' ? 'Mounts React component' : 'Rerenders mounted React component',
192
+ home: 'https://github.com/cypress-io/cypress',
193
+ };
194
+ },
195
+ });
196
+ }
197
+ }));
198
+ // Bluebird types are terrible. I don't think the return type can be carried without this cast
199
+ });
200
+ };
201
+ /**
202
+ * Create an `unmount` function. Performs all the non-React-version specific
203
+ * behavior related to unmounting.
204
+ *
205
+ * This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
206
+ * or people writing adapters for third-party, custom adapters.
207
+ *
208
+ * @param {UnmountArgs} options used during unmounting
209
+ */
210
+ const makeUnmountFn = (options) => {
211
+ return cy.then(() => {
212
+ var _a;
213
+ const wasUnmounted = mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
214
+ if (wasUnmounted && options.log) {
215
+ Cypress.log({
216
+ name: 'unmount',
217
+ type: 'parent',
218
+ message: [(_a = options.boundComponentMessage) !== null && _a !== void 0 ? _a : 'Unmounted component'],
219
+ consoleProps: () => {
220
+ return {
221
+ description: 'Unmounts React component',
222
+ parent: getContainerEl().parentNode,
223
+ home: 'https://github.com/cypress-io/cypress',
224
+ };
225
+ },
226
+ });
227
+ }
228
+ });
229
+ };
230
+ // Cleanup before each run
231
+ // NOTE: we cannot use unmount here because
232
+ // we are not in the context of a test
233
+ const preMountCleanup = () => {
234
+ mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
235
+ };
236
+ const _mount = (jsx, options = {}) => makeMountFn('mount', jsx, options);
237
+ const createMount = (defaultOptions) => {
238
+ return (element, options) => {
239
+ return _mount(element, Object.assign(Object.assign({}, defaultOptions), options));
240
+ };
241
+ };
242
+ // Side effects from "import { mount } from '@cypress/<my-framework>'" are annoying, we should avoid doing this
243
+ // by creating an explicit function/import that the user can register in their 'component.js' support file,
244
+ // such as:
245
+ // import 'cypress/<my-framework>/support'
246
+ // or
247
+ // import { registerCT } from 'cypress/<my-framework>'
248
+ // registerCT()
249
+ // Note: This would be a breaking change
250
+ // it is required to unmount component in beforeEach hook in order to provide a clean state inside test
251
+ // because `mount` can be called after some preparation that can side effect unmount
252
+ // @see npm/react/cypress/component/advanced/set-timeout-example/loading-indicator-spec.js
253
+ setupHooks(preMountCleanup);
254
+
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('COERCE', `${'(^|[^\\d])' +
464
+ '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
465
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
466
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
467
+ `(?:$|[^\\d])`);
468
+ createToken('COERCERTL', src[t.COERCE], true);
469
+
470
+ // Tilde ranges.
471
+ // Meaning is "reasonably at or greater than"
472
+ createToken('LONETILDE', '(?:~>?)');
473
+
474
+ createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
475
+ exports.tildeTrimReplace = '$1~';
476
+
477
+ createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
478
+ createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
479
+
480
+ // Caret ranges.
481
+ // Meaning is "at least and backwards compatible with"
482
+ createToken('LONECARET', '(?:\\^)');
483
+
484
+ createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
485
+ exports.caretTrimReplace = '$1^';
486
+
487
+ createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
488
+ createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
489
+
490
+ // A simple gt/lt/eq thing, or just "" to indicate "any version"
491
+ createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
492
+ createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
493
+
494
+ // An expression to strip any whitespace between the gtlt and the thing
495
+ // it modifies, so that `> 1.2.3` ==> `>1.2.3`
496
+ createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
497
+ }\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
498
+ exports.comparatorTrimReplace = '$1$2$3';
499
+
500
+ // Something like `1.2.3 - 1.2.4`
501
+ // Note that these all use the loose form, because they'll be
502
+ // checked against either the strict or loose comparator form
503
+ // later.
504
+ createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
505
+ `\\s+-\\s+` +
506
+ `(${src[t.XRANGEPLAIN]})` +
507
+ `\\s*$`);
508
+
509
+ createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
510
+ `\\s+-\\s+` +
511
+ `(${src[t.XRANGEPLAINLOOSE]})` +
512
+ `\\s*$`);
513
+
514
+ // Star ranges basically just allow anything at all.
515
+ createToken('STAR', '(<|>)?=?\\s*\\*');
516
+ // >=0.0.0 is like a star
517
+ createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
518
+ createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
519
+ });
520
+
521
+ // parse out just the options we care about
522
+ const looseOption = Object.freeze({ loose: true });
523
+ const emptyOpts = Object.freeze({ });
524
+ const parseOptions = options => {
525
+ if (!options) {
526
+ return emptyOpts
527
+ }
528
+
529
+ if (typeof options !== 'object') {
530
+ return looseOption
531
+ }
532
+
533
+ return options
534
+ };
535
+ var parseOptions_1 = parseOptions;
536
+
537
+ const numeric = /^[0-9]+$/;
538
+ const compareIdentifiers$1 = (a, b) => {
539
+ const anum = numeric.test(a);
540
+ const bnum = numeric.test(b);
541
+
542
+ if (anum && bnum) {
543
+ a = +a;
544
+ b = +b;
545
+ }
546
+
547
+ return a === b ? 0
548
+ : (anum && !bnum) ? -1
549
+ : (bnum && !anum) ? 1
550
+ : a < b ? -1
551
+ : 1
552
+ };
553
+
554
+ const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
555
+
556
+ var identifiers = {
557
+ compareIdentifiers: compareIdentifiers$1,
558
+ rcompareIdentifiers,
559
+ };
560
+
561
+ const { MAX_LENGTH, MAX_SAFE_INTEGER } = constants;
562
+ const { safeRe: re, t } = re_1;
563
+
564
+
565
+ const { compareIdentifiers } = identifiers;
566
+ class SemVer {
567
+ constructor (version, options) {
568
+ options = parseOptions_1(options);
569
+
570
+ if (version instanceof SemVer) {
571
+ if (version.loose === !!options.loose &&
572
+ version.includePrerelease === !!options.includePrerelease) {
573
+ return version
574
+ } else {
575
+ version = version.version;
576
+ }
577
+ } else if (typeof version !== 'string') {
578
+ throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`)
579
+ }
580
+
581
+ if (version.length > MAX_LENGTH) {
582
+ throw new TypeError(
583
+ `version is longer than ${MAX_LENGTH} characters`
584
+ )
585
+ }
586
+
587
+ debug_1('SemVer', version, options);
588
+ this.options = options;
589
+ this.loose = !!options.loose;
590
+ // this isn't actually relevant for versions, but keep it so that we
591
+ // don't run into trouble passing this.options around.
592
+ this.includePrerelease = !!options.includePrerelease;
593
+
594
+ const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
595
+
596
+ if (!m) {
597
+ throw new TypeError(`Invalid Version: ${version}`)
598
+ }
599
+
600
+ this.raw = version;
601
+
602
+ // these are actually numbers
603
+ this.major = +m[1];
604
+ this.minor = +m[2];
605
+ this.patch = +m[3];
606
+
607
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
608
+ throw new TypeError('Invalid major version')
609
+ }
610
+
611
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
612
+ throw new TypeError('Invalid minor version')
613
+ }
614
+
615
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
616
+ throw new TypeError('Invalid patch version')
617
+ }
618
+
619
+ // numberify any prerelease numeric ids
620
+ if (!m[4]) {
621
+ this.prerelease = [];
622
+ } else {
623
+ this.prerelease = m[4].split('.').map((id) => {
624
+ if (/^[0-9]+$/.test(id)) {
625
+ const num = +id;
626
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
627
+ return num
628
+ }
629
+ }
630
+ return id
631
+ });
632
+ }
633
+
634
+ this.build = m[5] ? m[5].split('.') : [];
635
+ this.format();
636
+ }
637
+
638
+ format () {
639
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
640
+ if (this.prerelease.length) {
641
+ this.version += `-${this.prerelease.join('.')}`;
642
+ }
643
+ return this.version
644
+ }
645
+
646
+ toString () {
647
+ return this.version
648
+ }
649
+
650
+ compare (other) {
651
+ debug_1('SemVer.compare', this.version, this.options, other);
652
+ if (!(other instanceof SemVer)) {
653
+ if (typeof other === 'string' && other === this.version) {
654
+ return 0
655
+ }
656
+ other = new SemVer(other, this.options);
657
+ }
658
+
659
+ if (other.version === this.version) {
660
+ return 0
661
+ }
662
+
663
+ return this.compareMain(other) || this.comparePre(other)
664
+ }
665
+
666
+ compareMain (other) {
667
+ if (!(other instanceof SemVer)) {
668
+ other = new SemVer(other, this.options);
669
+ }
670
+
671
+ return (
672
+ compareIdentifiers(this.major, other.major) ||
673
+ compareIdentifiers(this.minor, other.minor) ||
674
+ compareIdentifiers(this.patch, other.patch)
675
+ )
676
+ }
677
+
678
+ comparePre (other) {
679
+ if (!(other instanceof SemVer)) {
680
+ other = new SemVer(other, this.options);
681
+ }
682
+
683
+ // NOT having a prerelease is > having one
684
+ if (this.prerelease.length && !other.prerelease.length) {
685
+ return -1
686
+ } else if (!this.prerelease.length && other.prerelease.length) {
687
+ return 1
688
+ } else if (!this.prerelease.length && !other.prerelease.length) {
689
+ return 0
690
+ }
691
+
692
+ let i = 0;
693
+ do {
694
+ const a = this.prerelease[i];
695
+ const b = other.prerelease[i];
696
+ debug_1('prerelease compare', i, a, b);
697
+ if (a === undefined && b === undefined) {
698
+ return 0
699
+ } else if (b === undefined) {
700
+ return 1
701
+ } else if (a === undefined) {
702
+ return -1
703
+ } else if (a === b) {
704
+ continue
705
+ } else {
706
+ return compareIdentifiers(a, b)
707
+ }
708
+ } while (++i)
709
+ }
710
+
711
+ compareBuild (other) {
712
+ if (!(other instanceof SemVer)) {
713
+ other = new SemVer(other, this.options);
714
+ }
715
+
716
+ let i = 0;
717
+ do {
718
+ const a = this.build[i];
719
+ const b = other.build[i];
720
+ debug_1('prerelease compare', i, a, b);
721
+ if (a === undefined && b === undefined) {
722
+ return 0
723
+ } else if (b === undefined) {
724
+ return 1
725
+ } else if (a === undefined) {
726
+ return -1
727
+ } else if (a === b) {
728
+ continue
729
+ } else {
730
+ return compareIdentifiers(a, b)
731
+ }
732
+ } while (++i)
733
+ }
734
+
735
+ // preminor will bump the version up to the next minor release, and immediately
736
+ // down to pre-release. premajor and prepatch work the same way.
737
+ inc (release, identifier, identifierBase) {
738
+ switch (release) {
739
+ case 'premajor':
740
+ this.prerelease.length = 0;
741
+ this.patch = 0;
742
+ this.minor = 0;
743
+ this.major++;
744
+ this.inc('pre', identifier, identifierBase);
745
+ break
746
+ case 'preminor':
747
+ this.prerelease.length = 0;
748
+ this.patch = 0;
749
+ this.minor++;
750
+ this.inc('pre', identifier, identifierBase);
751
+ break
752
+ case 'prepatch':
753
+ // If this is already a prerelease, it will bump to the next version
754
+ // drop any prereleases that might already exist, since they are not
755
+ // relevant at this point.
756
+ this.prerelease.length = 0;
757
+ this.inc('patch', identifier, identifierBase);
758
+ this.inc('pre', identifier, identifierBase);
759
+ break
760
+ // If the input is a non-prerelease version, this acts the same as
761
+ // prepatch.
762
+ case 'prerelease':
763
+ if (this.prerelease.length === 0) {
764
+ this.inc('patch', identifier, identifierBase);
765
+ }
766
+ this.inc('pre', identifier, identifierBase);
767
+ break
768
+
769
+ case 'major':
770
+ // If this is a pre-major version, bump up to the same major version.
771
+ // Otherwise increment major.
772
+ // 1.0.0-5 bumps to 1.0.0
773
+ // 1.1.0 bumps to 2.0.0
774
+ if (
775
+ this.minor !== 0 ||
776
+ this.patch !== 0 ||
777
+ this.prerelease.length === 0
778
+ ) {
779
+ this.major++;
780
+ }
781
+ this.minor = 0;
782
+ this.patch = 0;
783
+ this.prerelease = [];
784
+ break
785
+ case 'minor':
786
+ // If this is a pre-minor version, bump up to the same minor version.
787
+ // Otherwise increment minor.
788
+ // 1.2.0-5 bumps to 1.2.0
789
+ // 1.2.1 bumps to 1.3.0
790
+ if (this.patch !== 0 || this.prerelease.length === 0) {
791
+ this.minor++;
792
+ }
793
+ this.patch = 0;
794
+ this.prerelease = [];
795
+ break
796
+ case 'patch':
797
+ // If this is not a pre-release version, it will increment the patch.
798
+ // If it is a pre-release it will bump up to the same patch version.
799
+ // 1.2.0-5 patches to 1.2.0
800
+ // 1.2.0 patches to 1.2.1
801
+ if (this.prerelease.length === 0) {
802
+ this.patch++;
803
+ }
804
+ this.prerelease = [];
805
+ break
806
+ // This probably shouldn't be used publicly.
807
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
808
+ case 'pre': {
809
+ const base = Number(identifierBase) ? 1 : 0;
810
+
811
+ if (!identifier && identifierBase === false) {
812
+ throw new Error('invalid increment argument: identifier is empty')
813
+ }
814
+
815
+ if (this.prerelease.length === 0) {
816
+ this.prerelease = [base];
817
+ } else {
818
+ let i = this.prerelease.length;
819
+ while (--i >= 0) {
820
+ if (typeof this.prerelease[i] === 'number') {
821
+ this.prerelease[i]++;
822
+ i = -2;
823
+ }
824
+ }
825
+ if (i === -1) {
826
+ // didn't increment anything
827
+ if (identifier === this.prerelease.join('.') && identifierBase === false) {
828
+ throw new Error('invalid increment argument: identifier already exists')
829
+ }
830
+ this.prerelease.push(base);
831
+ }
832
+ }
833
+ if (identifier) {
834
+ // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
835
+ // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
836
+ let prerelease = [identifier, base];
837
+ if (identifierBase === false) {
838
+ prerelease = [identifier];
839
+ }
840
+ if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
841
+ if (isNaN(this.prerelease[1])) {
842
+ this.prerelease = prerelease;
843
+ }
844
+ } else {
845
+ this.prerelease = prerelease;
846
+ }
847
+ }
848
+ break
849
+ }
850
+ default:
851
+ throw new Error(`invalid increment argument: ${release}`)
852
+ }
853
+ this.raw = this.format();
854
+ if (this.build.length) {
855
+ this.raw += `+${this.build.join('.')}`;
856
+ }
857
+ return this
858
+ }
859
+ }
860
+
861
+ var semver = SemVer;
862
+
863
+ const major = (a, loose) => new semver(a, loose).major;
864
+ var major_1 = major;
865
+
866
+ let lastReactDom;
867
+ const cleanup = () => {
868
+ if (lastReactDom) {
869
+ const root = getContainerEl();
870
+ lastReactDom.unmountComponentAtNode(root);
871
+ return true;
872
+ }
873
+ return false;
874
+ };
875
+ /**
876
+ * Mounts a React component into the DOM.
877
+ * @param jsx {React.ReactNode} The React component to mount.
878
+ * @param options {MountOptions} [options={}] options to pass to the mount function.
879
+ * @param rerenderKey {string} [rerenderKey] A key to use to force a rerender.
880
+ * @see {@link https://on.cypress.io/mounting-react} for more details.
881
+ * @example
882
+ * import { mount } from '@cypress/react'
883
+ * import { Stepper } from './Stepper'
884
+ *
885
+ * it('mounts', () => {
886
+ * mount(<StepperComponent />)
887
+ * cy.get('[data-cy=increment]').click()
888
+ * cy.get('[data-cy=counter]').should('have.text', '1')
889
+ * }
890
+ */
891
+ function mount(jsx, options = {}, rerenderKey) {
892
+ if (major_1(React.version) === 18) {
893
+ 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.';
894
+ console.error(message);
895
+ Cypress.log({ name: 'warning', message });
896
+ }
897
+ // Remove last mounted component if cy.mount is called more than once in a test
898
+ cleanup();
899
+ const internalOptions = {
900
+ reactDom: ReactDOM,
901
+ render: (reactComponent, el, reactDomToUse) => {
902
+ lastReactDom = (reactDomToUse || ReactDOM);
903
+ return lastReactDom.render(reactComponent, el);
904
+ },
905
+ unmount: internalUnmount,
906
+ cleanup,
907
+ };
908
+ return makeMountFn('mount', jsx, Object.assign({ ReactDom: ReactDOM }, options), rerenderKey, internalOptions);
909
+ }
910
+ /**
911
+ * Unmounts the component from the DOM.
912
+ * @internal
913
+ * @param options - Options for unmounting.
914
+ */
915
+ function internalUnmount(options = { log: true }) {
916
+ return makeUnmountFn(options);
917
+ }
918
+ /**
919
+ * Removed as of Cypress 11.0.0.
920
+ * @see https://on.cypress.io/migration-11-0-0-component-testing-updates
921
+ */
922
+ function unmount(options = { log: true }) {
923
+ // @ts-expect-error - undocumented API
924
+ Cypress.utils.throwErrByPath('mount.unmount');
925
+ }
926
+
927
+ /**
928
+ * Mounts a React hook function in a test component for testing.
929
+ * Removed as of Cypress 11.0.0.
930
+ * @see https://on.cypress.io/migration-11-0-0-component-testing-updates
931
+ */
932
+ const mountHook = (hookFn) => {
933
+ // @ts-expect-error - internal API
934
+ Cypress.utils.throwErrByPath('mount.mount_hook');
935
+ };
936
+
937
+ exports.createMount = createMount;
938
+ exports.getContainerEl = getContainerEl;
939
+ exports.makeMountFn = makeMountFn;
940
+ exports.makeUnmountFn = makeUnmountFn;
941
+ exports.mount = mount;
942
+ exports.mountHook = mountHook;
943
+ exports.unmount = unmount;