cypress 13.3.0 → 13.3.2

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 +19 -3
  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,917 @@
1
+
2
+ /**
3
+ * @cypress/react v0.0.0-development
4
+ * (c) 2023 Cypress.io
5
+ * Released under the MIT License
6
+ */
7
+
8
+ import * as React from 'react';
9
+ import React__default from 'react';
10
+ import ReactDOM from 'react-dom';
11
+
12
+ /**
13
+ * Gets the display name of the component when possible.
14
+ * @param type {JSX} The type object returned from creating the react element.
15
+ * @param fallbackName {string} The alias, or fallback name to use when the name cannot be derived.
16
+ * @link https://github.com/facebook/react-devtools/blob/master/backend/getDisplayName.js
17
+ */
18
+ function getDisplayName(node, fallbackName = 'Unknown') {
19
+ const type = node === null || node === void 0 ? void 0 : node.type;
20
+ if (!type) {
21
+ return fallbackName;
22
+ }
23
+ let displayName = null;
24
+ // The displayName property is not guaranteed to be a string.
25
+ // It's only safe to use for our purposes if it's a string.
26
+ // github.com/facebook/react-devtools/issues/803
27
+ if (typeof type.displayName === 'string') {
28
+ displayName = type.displayName;
29
+ }
30
+ if (!displayName) {
31
+ displayName = type.name || fallbackName;
32
+ }
33
+ // Facebook-specific hack to turn "Image [from Image.react]" into just "Image".
34
+ // We need displayName with module name for error reports but it clutters the DevTools.
35
+ const match = displayName.match(/^(.*) \[from (.*)\]$/);
36
+ if (match) {
37
+ const componentName = match[1];
38
+ const moduleName = match[2];
39
+ if (componentName && moduleName) {
40
+ if (moduleName === componentName ||
41
+ moduleName.startsWith(`${componentName}.`)) {
42
+ displayName = componentName;
43
+ }
44
+ }
45
+ }
46
+ return displayName;
47
+ }
48
+
49
+ const ROOT_SELECTOR = '[data-cy-root]';
50
+ /**
51
+ * Gets the root element used to mount the component.
52
+ * @returns {HTMLElement} The root element
53
+ * @throws {Error} If the root element is not found
54
+ */
55
+ const getContainerEl = () => {
56
+ const el = document.querySelector(ROOT_SELECTOR);
57
+ if (el) {
58
+ return el;
59
+ }
60
+ 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.`);
61
+ };
62
+ function checkForRemovedStyleOptions(mountingOptions) {
63
+ for (const key of ['cssFile', 'cssFiles', 'style', 'styles', 'stylesheet', 'stylesheets']) {
64
+ if (mountingOptions[key]) {
65
+ Cypress.utils.throwErrByPath('mount.removed_style_mounting_options', key);
66
+ }
67
+ }
68
+ }
69
+ /**
70
+ * Utility function to register CT side effects and run cleanup code during the "test:before:run" Cypress hook
71
+ * @param optionalCallback Callback to be called before the next test runs
72
+ */
73
+ function setupHooks(optionalCallback) {
74
+ // We don't want CT side effects to run when e2e
75
+ // testing so we early return.
76
+ // System test to verify CT side effects do not pollute e2e: system-tests/test/e2e_with_mount_import_spec.ts
77
+ if (Cypress.testingType !== 'component') {
78
+ return;
79
+ }
80
+ // When running component specs, we cannot allow "cy.visit"
81
+ // because it will wipe out our preparation work, and does not make much sense
82
+ // thus we overwrite "cy.visit" to throw an error
83
+ Cypress.Commands.overwrite('visit', () => {
84
+ throw new Error('cy.visit from a component spec is not allowed');
85
+ });
86
+ Cypress.Commands.overwrite('session', () => {
87
+ throw new Error('cy.session from a component spec is not allowed');
88
+ });
89
+ Cypress.Commands.overwrite('origin', () => {
90
+ throw new Error('cy.origin from a component spec is not allowed');
91
+ });
92
+ // @ts-ignore
93
+ Cypress.on('test:before:after:run:async', () => {
94
+ optionalCallback === null || optionalCallback === void 0 ? void 0 : optionalCallback();
95
+ });
96
+ }
97
+
98
+ let mountCleanup;
99
+ /**
100
+ * Create an `mount` function. Performs all the non-React-version specific
101
+ * behavior related to mounting. The React-version-specific code
102
+ * is injected. This helps us to maintain a consistent public API
103
+ * and handle breaking changes in React's rendering API.
104
+ *
105
+ * This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
106
+ * or people writing adapters for third-party, custom adapters.
107
+ */
108
+ const makeMountFn = (type, jsx, options = {}, rerenderKey, internalMountOptions) => {
109
+ if (!internalMountOptions) {
110
+ throw Error('internalMountOptions must be provided with `render` and `reactDom` parameters');
111
+ }
112
+ // @ts-expect-error - this is removed but we want to check if a user is passing it, and error if they are.
113
+ if (options.alias) {
114
+ // @ts-expect-error
115
+ Cypress.utils.throwErrByPath('mount.alias', options.alias);
116
+ }
117
+ checkForRemovedStyleOptions(options);
118
+ mountCleanup = internalMountOptions.cleanup;
119
+ return cy
120
+ .then(() => {
121
+ var _a, _b, _c;
122
+ const reactDomToUse = internalMountOptions.reactDom;
123
+ const el = getContainerEl();
124
+ if (!el) {
125
+ throw new Error([
126
+ `[@cypress/react] 🔥 Hmm, cannot find root element to mount the component. Searched for ${ROOT_SELECTOR}`,
127
+ ].join(' '));
128
+ }
129
+ const key = rerenderKey !== null && rerenderKey !== void 0 ? rerenderKey :
130
+ // @ts-ignore provide unique key to the the wrapped component to make sure we are rerendering between tests
131
+ (((_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();
132
+ const props = {
133
+ key,
134
+ };
135
+ const reactComponent = React.createElement(options.strict ? React.StrictMode : React.Fragment, props, jsx);
136
+ // since we always surround the component with a fragment
137
+ // let's get back the original component
138
+ const userComponent = reactComponent.props.children;
139
+ internalMountOptions.render(reactComponent, el, reactDomToUse);
140
+ return (cy.wrap(userComponent, { log: false })
141
+ .then(() => {
142
+ return cy.wrap({
143
+ component: userComponent,
144
+ rerender: (newComponent) => makeMountFn('rerender', newComponent, options, key, internalMountOptions),
145
+ unmount: () => {
146
+ // @ts-expect-error - undocumented API
147
+ Cypress.utils.throwErrByPath('mount.unmount');
148
+ },
149
+ }, { log: false });
150
+ })
151
+ // by waiting, we delaying test execution for the next tick of event loop
152
+ // and letting hooks and component lifecycle methods to execute mount
153
+ // https://github.com/bahmutov/cypress-react-unit-test/issues/200
154
+ .wait(0, { log: false })
155
+ .then(() => {
156
+ if (options.log !== false) {
157
+ // Get the display name property via the component constructor
158
+ // @ts-ignore FIXME
159
+ const componentName = getDisplayName(jsx);
160
+ const jsxComponentName = `<${componentName} ... />`;
161
+ Cypress.log({
162
+ name: type,
163
+ type: 'parent',
164
+ message: [jsxComponentName],
165
+ // @ts-ignore
166
+ $el: el.children.item(0),
167
+ consoleProps: () => {
168
+ return {
169
+ // @ts-ignore protect the use of jsx functional components use ReactNode
170
+ props: jsx === null || jsx === void 0 ? void 0 : jsx.props,
171
+ description: type === 'mount' ? 'Mounts React component' : 'Rerenders mounted React component',
172
+ home: 'https://github.com/cypress-io/cypress',
173
+ };
174
+ },
175
+ });
176
+ }
177
+ }));
178
+ // Bluebird types are terrible. I don't think the return type can be carried without this cast
179
+ });
180
+ };
181
+ /**
182
+ * Create an `unmount` function. Performs all the non-React-version specific
183
+ * behavior related to unmounting.
184
+ *
185
+ * This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
186
+ * or people writing adapters for third-party, custom adapters.
187
+ *
188
+ * @param {UnmountArgs} options used during unmounting
189
+ */
190
+ const makeUnmountFn = (options) => {
191
+ return cy.then(() => {
192
+ var _a;
193
+ const wasUnmounted = mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
194
+ if (wasUnmounted && options.log) {
195
+ Cypress.log({
196
+ name: 'unmount',
197
+ type: 'parent',
198
+ message: [(_a = options.boundComponentMessage) !== null && _a !== void 0 ? _a : 'Unmounted component'],
199
+ consoleProps: () => {
200
+ return {
201
+ description: 'Unmounts React component',
202
+ parent: getContainerEl().parentNode,
203
+ home: 'https://github.com/cypress-io/cypress',
204
+ };
205
+ },
206
+ });
207
+ }
208
+ });
209
+ };
210
+ // Cleanup before each run
211
+ // NOTE: we cannot use unmount here because
212
+ // we are not in the context of a test
213
+ const preMountCleanup = () => {
214
+ mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
215
+ };
216
+ const _mount = (jsx, options = {}) => makeMountFn('mount', jsx, options);
217
+ const createMount = (defaultOptions) => {
218
+ return (element, options) => {
219
+ return _mount(element, Object.assign(Object.assign({}, defaultOptions), options));
220
+ };
221
+ };
222
+ // Side effects from "import { mount } from '@cypress/<my-framework>'" are annoying, we should avoid doing this
223
+ // by creating an explicit function/import that the user can register in their 'component.js' support file,
224
+ // such as:
225
+ // import 'cypress/<my-framework>/support'
226
+ // or
227
+ // import { registerCT } from 'cypress/<my-framework>'
228
+ // registerCT()
229
+ // Note: This would be a breaking change
230
+ // it is required to unmount component in beforeEach hook in order to provide a clean state inside test
231
+ // because `mount` can be called after some preparation that can side effect unmount
232
+ // @see npm/react/cypress/component/advanced/set-timeout-example/loading-indicator-spec.js
233
+ setupHooks(preMountCleanup);
234
+
235
+ const debug = (
236
+ typeof process === 'object' &&
237
+ process.env &&
238
+ process.env.NODE_DEBUG &&
239
+ /\bsemver\b/i.test(process.env.NODE_DEBUG)
240
+ ) ? (...args) => console.error('SEMVER', ...args)
241
+ : () => {};
242
+
243
+ var debug_1 = debug;
244
+
245
+ // Note: this is the semver.org version of the spec that it implements
246
+ // Not necessarily the package version of this code.
247
+ const SEMVER_SPEC_VERSION = '2.0.0';
248
+
249
+ const MAX_LENGTH$1 = 256;
250
+ const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER ||
251
+ /* istanbul ignore next */ 9007199254740991;
252
+
253
+ // Max safe segment length for coercion.
254
+ const MAX_SAFE_COMPONENT_LENGTH = 16;
255
+
256
+ // Max safe length for a build identifier. The max length minus 6 characters for
257
+ // the shortest version with a build 0.0.0+BUILD.
258
+ const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH$1 - 6;
259
+
260
+ const RELEASE_TYPES = [
261
+ 'major',
262
+ 'premajor',
263
+ 'minor',
264
+ 'preminor',
265
+ 'patch',
266
+ 'prepatch',
267
+ 'prerelease',
268
+ ];
269
+
270
+ var constants = {
271
+ MAX_LENGTH: MAX_LENGTH$1,
272
+ MAX_SAFE_COMPONENT_LENGTH,
273
+ MAX_SAFE_BUILD_LENGTH,
274
+ MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
275
+ RELEASE_TYPES,
276
+ SEMVER_SPEC_VERSION,
277
+ FLAG_INCLUDE_PRERELEASE: 0b001,
278
+ FLAG_LOOSE: 0b010,
279
+ };
280
+
281
+ function createCommonjsModule(fn) {
282
+ var module = { exports: {} };
283
+ return fn(module, module.exports), module.exports;
284
+ }
285
+
286
+ var re_1 = createCommonjsModule(function (module, exports) {
287
+ const {
288
+ MAX_SAFE_COMPONENT_LENGTH,
289
+ MAX_SAFE_BUILD_LENGTH,
290
+ MAX_LENGTH,
291
+ } = constants;
292
+
293
+ exports = module.exports = {};
294
+
295
+ // The actual regexps go on exports.re
296
+ const re = exports.re = [];
297
+ const safeRe = exports.safeRe = [];
298
+ const src = exports.src = [];
299
+ const t = exports.t = {};
300
+ let R = 0;
301
+
302
+ const LETTERDASHNUMBER = '[a-zA-Z0-9-]';
303
+
304
+ // Replace some greedy regex tokens to prevent regex dos issues. These regex are
305
+ // used internally via the safeRe object since all inputs in this library get
306
+ // normalized first to trim and collapse all extra whitespace. The original
307
+ // regexes are exported for userland consumption and lower level usage. A
308
+ // future breaking change could export the safer regex only with a note that
309
+ // all input should have extra whitespace removed.
310
+ const safeRegexReplacements = [
311
+ ['\\s', 1],
312
+ ['\\d', MAX_LENGTH],
313
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],
314
+ ];
315
+
316
+ const makeSafeRegex = (value) => {
317
+ for (const [token, max] of safeRegexReplacements) {
318
+ value = value
319
+ .split(`${token}*`).join(`${token}{0,${max}}`)
320
+ .split(`${token}+`).join(`${token}{1,${max}}`);
321
+ }
322
+ return value
323
+ };
324
+
325
+ const createToken = (name, value, isGlobal) => {
326
+ const safe = makeSafeRegex(value);
327
+ const index = R++;
328
+ debug_1(name, index, value);
329
+ t[name] = index;
330
+ src[index] = value;
331
+ re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
332
+ safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined);
333
+ };
334
+
335
+ // The following Regular Expressions can be used for tokenizing,
336
+ // validating, and parsing SemVer version strings.
337
+
338
+ // ## Numeric Identifier
339
+ // A single `0`, or a non-zero digit followed by zero or more digits.
340
+
341
+ createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
342
+ createToken('NUMERICIDENTIFIERLOOSE', '\\d+');
343
+
344
+ // ## Non-numeric Identifier
345
+ // Zero or more digits, followed by a letter or hyphen, and then zero or
346
+ // more letters, digits, or hyphens.
347
+
348
+ createToken('NONNUMERICIDENTIFIER', `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
349
+
350
+ // ## Main Version
351
+ // Three dot-separated numeric identifiers.
352
+
353
+ createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
354
+ `(${src[t.NUMERICIDENTIFIER]})\\.` +
355
+ `(${src[t.NUMERICIDENTIFIER]})`);
356
+
357
+ createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
358
+ `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
359
+ `(${src[t.NUMERICIDENTIFIERLOOSE]})`);
360
+
361
+ // ## Pre-release Version Identifier
362
+ // A numeric identifier, or a non-numeric identifier.
363
+
364
+ createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
365
+ }|${src[t.NONNUMERICIDENTIFIER]})`);
366
+
367
+ createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
368
+ }|${src[t.NONNUMERICIDENTIFIER]})`);
369
+
370
+ // ## Pre-release Version
371
+ // Hyphen, followed by one or more dot-separated pre-release version
372
+ // identifiers.
373
+
374
+ createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
375
+ }(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
376
+
377
+ createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
378
+ }(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
379
+
380
+ // ## Build Metadata Identifier
381
+ // Any combination of digits, letters, or hyphens.
382
+
383
+ createToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`);
384
+
385
+ // ## Build Metadata
386
+ // Plus sign, followed by one or more period-separated build metadata
387
+ // identifiers.
388
+
389
+ createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
390
+ }(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
391
+
392
+ // ## Full Version String
393
+ // A main version, followed optionally by a pre-release version and
394
+ // build metadata.
395
+
396
+ // Note that the only major, minor, patch, and pre-release sections of
397
+ // the version string are capturing groups. The build metadata is not a
398
+ // capturing group, because it should not ever be used in version
399
+ // comparison.
400
+
401
+ createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
402
+ }${src[t.PRERELEASE]}?${
403
+ src[t.BUILD]}?`);
404
+
405
+ createToken('FULL', `^${src[t.FULLPLAIN]}$`);
406
+
407
+ // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
408
+ // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
409
+ // common in the npm registry.
410
+ createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
411
+ }${src[t.PRERELEASELOOSE]}?${
412
+ src[t.BUILD]}?`);
413
+
414
+ createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
415
+
416
+ createToken('GTLT', '((?:<|>)?=?)');
417
+
418
+ // Something like "2.*" or "1.2.x".
419
+ // Note that "x.x" is a valid xRange identifer, meaning "any version"
420
+ // Only the first item is strictly required.
421
+ createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
422
+ createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
423
+
424
+ createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
425
+ `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
426
+ `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
427
+ `(?:${src[t.PRERELEASE]})?${
428
+ src[t.BUILD]}?` +
429
+ `)?)?`);
430
+
431
+ createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
432
+ `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
433
+ `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
434
+ `(?:${src[t.PRERELEASELOOSE]})?${
435
+ src[t.BUILD]}?` +
436
+ `)?)?`);
437
+
438
+ createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
439
+ createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
440
+
441
+ // Coercion.
442
+ // Extract anything that could conceivably be a part of a valid semver
443
+ createToken('COERCE', `${'(^|[^\\d])' +
444
+ '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
445
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
446
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
447
+ `(?:$|[^\\d])`);
448
+ createToken('COERCERTL', src[t.COERCE], true);
449
+
450
+ // Tilde ranges.
451
+ // Meaning is "reasonably at or greater than"
452
+ createToken('LONETILDE', '(?:~>?)');
453
+
454
+ createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
455
+ exports.tildeTrimReplace = '$1~';
456
+
457
+ createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
458
+ createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
459
+
460
+ // Caret ranges.
461
+ // Meaning is "at least and backwards compatible with"
462
+ createToken('LONECARET', '(?:\\^)');
463
+
464
+ createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
465
+ exports.caretTrimReplace = '$1^';
466
+
467
+ createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
468
+ createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
469
+
470
+ // A simple gt/lt/eq thing, or just "" to indicate "any version"
471
+ createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
472
+ createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
473
+
474
+ // An expression to strip any whitespace between the gtlt and the thing
475
+ // it modifies, so that `> 1.2.3` ==> `>1.2.3`
476
+ createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
477
+ }\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
478
+ exports.comparatorTrimReplace = '$1$2$3';
479
+
480
+ // Something like `1.2.3 - 1.2.4`
481
+ // Note that these all use the loose form, because they'll be
482
+ // checked against either the strict or loose comparator form
483
+ // later.
484
+ createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
485
+ `\\s+-\\s+` +
486
+ `(${src[t.XRANGEPLAIN]})` +
487
+ `\\s*$`);
488
+
489
+ createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
490
+ `\\s+-\\s+` +
491
+ `(${src[t.XRANGEPLAINLOOSE]})` +
492
+ `\\s*$`);
493
+
494
+ // Star ranges basically just allow anything at all.
495
+ createToken('STAR', '(<|>)?=?\\s*\\*');
496
+ // >=0.0.0 is like a star
497
+ createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
498
+ createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
499
+ });
500
+
501
+ // parse out just the options we care about
502
+ const looseOption = Object.freeze({ loose: true });
503
+ const emptyOpts = Object.freeze({ });
504
+ const parseOptions = options => {
505
+ if (!options) {
506
+ return emptyOpts
507
+ }
508
+
509
+ if (typeof options !== 'object') {
510
+ return looseOption
511
+ }
512
+
513
+ return options
514
+ };
515
+ var parseOptions_1 = parseOptions;
516
+
517
+ const numeric = /^[0-9]+$/;
518
+ const compareIdentifiers$1 = (a, b) => {
519
+ const anum = numeric.test(a);
520
+ const bnum = numeric.test(b);
521
+
522
+ if (anum && bnum) {
523
+ a = +a;
524
+ b = +b;
525
+ }
526
+
527
+ return a === b ? 0
528
+ : (anum && !bnum) ? -1
529
+ : (bnum && !anum) ? 1
530
+ : a < b ? -1
531
+ : 1
532
+ };
533
+
534
+ const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
535
+
536
+ var identifiers = {
537
+ compareIdentifiers: compareIdentifiers$1,
538
+ rcompareIdentifiers,
539
+ };
540
+
541
+ const { MAX_LENGTH, MAX_SAFE_INTEGER } = constants;
542
+ const { safeRe: re, t } = re_1;
543
+
544
+
545
+ const { compareIdentifiers } = identifiers;
546
+ class SemVer {
547
+ constructor (version, options) {
548
+ options = parseOptions_1(options);
549
+
550
+ if (version instanceof SemVer) {
551
+ if (version.loose === !!options.loose &&
552
+ version.includePrerelease === !!options.includePrerelease) {
553
+ return version
554
+ } else {
555
+ version = version.version;
556
+ }
557
+ } else if (typeof version !== 'string') {
558
+ throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`)
559
+ }
560
+
561
+ if (version.length > MAX_LENGTH) {
562
+ throw new TypeError(
563
+ `version is longer than ${MAX_LENGTH} characters`
564
+ )
565
+ }
566
+
567
+ debug_1('SemVer', version, options);
568
+ this.options = options;
569
+ this.loose = !!options.loose;
570
+ // this isn't actually relevant for versions, but keep it so that we
571
+ // don't run into trouble passing this.options around.
572
+ this.includePrerelease = !!options.includePrerelease;
573
+
574
+ const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
575
+
576
+ if (!m) {
577
+ throw new TypeError(`Invalid Version: ${version}`)
578
+ }
579
+
580
+ this.raw = version;
581
+
582
+ // these are actually numbers
583
+ this.major = +m[1];
584
+ this.minor = +m[2];
585
+ this.patch = +m[3];
586
+
587
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
588
+ throw new TypeError('Invalid major version')
589
+ }
590
+
591
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
592
+ throw new TypeError('Invalid minor version')
593
+ }
594
+
595
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
596
+ throw new TypeError('Invalid patch version')
597
+ }
598
+
599
+ // numberify any prerelease numeric ids
600
+ if (!m[4]) {
601
+ this.prerelease = [];
602
+ } else {
603
+ this.prerelease = m[4].split('.').map((id) => {
604
+ if (/^[0-9]+$/.test(id)) {
605
+ const num = +id;
606
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
607
+ return num
608
+ }
609
+ }
610
+ return id
611
+ });
612
+ }
613
+
614
+ this.build = m[5] ? m[5].split('.') : [];
615
+ this.format();
616
+ }
617
+
618
+ format () {
619
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
620
+ if (this.prerelease.length) {
621
+ this.version += `-${this.prerelease.join('.')}`;
622
+ }
623
+ return this.version
624
+ }
625
+
626
+ toString () {
627
+ return this.version
628
+ }
629
+
630
+ compare (other) {
631
+ debug_1('SemVer.compare', this.version, this.options, other);
632
+ if (!(other instanceof SemVer)) {
633
+ if (typeof other === 'string' && other === this.version) {
634
+ return 0
635
+ }
636
+ other = new SemVer(other, this.options);
637
+ }
638
+
639
+ if (other.version === this.version) {
640
+ return 0
641
+ }
642
+
643
+ return this.compareMain(other) || this.comparePre(other)
644
+ }
645
+
646
+ compareMain (other) {
647
+ if (!(other instanceof SemVer)) {
648
+ other = new SemVer(other, this.options);
649
+ }
650
+
651
+ return (
652
+ compareIdentifiers(this.major, other.major) ||
653
+ compareIdentifiers(this.minor, other.minor) ||
654
+ compareIdentifiers(this.patch, other.patch)
655
+ )
656
+ }
657
+
658
+ comparePre (other) {
659
+ if (!(other instanceof SemVer)) {
660
+ other = new SemVer(other, this.options);
661
+ }
662
+
663
+ // NOT having a prerelease is > having one
664
+ if (this.prerelease.length && !other.prerelease.length) {
665
+ return -1
666
+ } else if (!this.prerelease.length && other.prerelease.length) {
667
+ return 1
668
+ } else if (!this.prerelease.length && !other.prerelease.length) {
669
+ return 0
670
+ }
671
+
672
+ let i = 0;
673
+ do {
674
+ const a = this.prerelease[i];
675
+ const b = other.prerelease[i];
676
+ debug_1('prerelease compare', i, a, b);
677
+ if (a === undefined && b === undefined) {
678
+ return 0
679
+ } else if (b === undefined) {
680
+ return 1
681
+ } else if (a === undefined) {
682
+ return -1
683
+ } else if (a === b) {
684
+ continue
685
+ } else {
686
+ return compareIdentifiers(a, b)
687
+ }
688
+ } while (++i)
689
+ }
690
+
691
+ compareBuild (other) {
692
+ if (!(other instanceof SemVer)) {
693
+ other = new SemVer(other, this.options);
694
+ }
695
+
696
+ let i = 0;
697
+ do {
698
+ const a = this.build[i];
699
+ const b = other.build[i];
700
+ debug_1('prerelease compare', i, a, b);
701
+ if (a === undefined && b === undefined) {
702
+ return 0
703
+ } else if (b === undefined) {
704
+ return 1
705
+ } else if (a === undefined) {
706
+ return -1
707
+ } else if (a === b) {
708
+ continue
709
+ } else {
710
+ return compareIdentifiers(a, b)
711
+ }
712
+ } while (++i)
713
+ }
714
+
715
+ // preminor will bump the version up to the next minor release, and immediately
716
+ // down to pre-release. premajor and prepatch work the same way.
717
+ inc (release, identifier, identifierBase) {
718
+ switch (release) {
719
+ case 'premajor':
720
+ this.prerelease.length = 0;
721
+ this.patch = 0;
722
+ this.minor = 0;
723
+ this.major++;
724
+ this.inc('pre', identifier, identifierBase);
725
+ break
726
+ case 'preminor':
727
+ this.prerelease.length = 0;
728
+ this.patch = 0;
729
+ this.minor++;
730
+ this.inc('pre', identifier, identifierBase);
731
+ break
732
+ case 'prepatch':
733
+ // If this is already a prerelease, it will bump to the next version
734
+ // drop any prereleases that might already exist, since they are not
735
+ // relevant at this point.
736
+ this.prerelease.length = 0;
737
+ this.inc('patch', identifier, identifierBase);
738
+ this.inc('pre', identifier, identifierBase);
739
+ break
740
+ // If the input is a non-prerelease version, this acts the same as
741
+ // prepatch.
742
+ case 'prerelease':
743
+ if (this.prerelease.length === 0) {
744
+ this.inc('patch', identifier, identifierBase);
745
+ }
746
+ this.inc('pre', identifier, identifierBase);
747
+ break
748
+
749
+ case 'major':
750
+ // If this is a pre-major version, bump up to the same major version.
751
+ // Otherwise increment major.
752
+ // 1.0.0-5 bumps to 1.0.0
753
+ // 1.1.0 bumps to 2.0.0
754
+ if (
755
+ this.minor !== 0 ||
756
+ this.patch !== 0 ||
757
+ this.prerelease.length === 0
758
+ ) {
759
+ this.major++;
760
+ }
761
+ this.minor = 0;
762
+ this.patch = 0;
763
+ this.prerelease = [];
764
+ break
765
+ case 'minor':
766
+ // If this is a pre-minor version, bump up to the same minor version.
767
+ // Otherwise increment minor.
768
+ // 1.2.0-5 bumps to 1.2.0
769
+ // 1.2.1 bumps to 1.3.0
770
+ if (this.patch !== 0 || this.prerelease.length === 0) {
771
+ this.minor++;
772
+ }
773
+ this.patch = 0;
774
+ this.prerelease = [];
775
+ break
776
+ case 'patch':
777
+ // If this is not a pre-release version, it will increment the patch.
778
+ // If it is a pre-release it will bump up to the same patch version.
779
+ // 1.2.0-5 patches to 1.2.0
780
+ // 1.2.0 patches to 1.2.1
781
+ if (this.prerelease.length === 0) {
782
+ this.patch++;
783
+ }
784
+ this.prerelease = [];
785
+ break
786
+ // This probably shouldn't be used publicly.
787
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
788
+ case 'pre': {
789
+ const base = Number(identifierBase) ? 1 : 0;
790
+
791
+ if (!identifier && identifierBase === false) {
792
+ throw new Error('invalid increment argument: identifier is empty')
793
+ }
794
+
795
+ if (this.prerelease.length === 0) {
796
+ this.prerelease = [base];
797
+ } else {
798
+ let i = this.prerelease.length;
799
+ while (--i >= 0) {
800
+ if (typeof this.prerelease[i] === 'number') {
801
+ this.prerelease[i]++;
802
+ i = -2;
803
+ }
804
+ }
805
+ if (i === -1) {
806
+ // didn't increment anything
807
+ if (identifier === this.prerelease.join('.') && identifierBase === false) {
808
+ throw new Error('invalid increment argument: identifier already exists')
809
+ }
810
+ this.prerelease.push(base);
811
+ }
812
+ }
813
+ if (identifier) {
814
+ // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
815
+ // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
816
+ let prerelease = [identifier, base];
817
+ if (identifierBase === false) {
818
+ prerelease = [identifier];
819
+ }
820
+ if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
821
+ if (isNaN(this.prerelease[1])) {
822
+ this.prerelease = prerelease;
823
+ }
824
+ } else {
825
+ this.prerelease = prerelease;
826
+ }
827
+ }
828
+ break
829
+ }
830
+ default:
831
+ throw new Error(`invalid increment argument: ${release}`)
832
+ }
833
+ this.raw = this.format();
834
+ if (this.build.length) {
835
+ this.raw += `+${this.build.join('.')}`;
836
+ }
837
+ return this
838
+ }
839
+ }
840
+
841
+ var semver = SemVer;
842
+
843
+ const major = (a, loose) => new semver(a, loose).major;
844
+ var major_1 = major;
845
+
846
+ let lastReactDom;
847
+ const cleanup = () => {
848
+ if (lastReactDom) {
849
+ const root = getContainerEl();
850
+ lastReactDom.unmountComponentAtNode(root);
851
+ return true;
852
+ }
853
+ return false;
854
+ };
855
+ /**
856
+ * Mounts a React component into the DOM.
857
+ * @param jsx {React.ReactNode} The React component to mount.
858
+ * @param options {MountOptions} [options={}] options to pass to the mount function.
859
+ * @param rerenderKey {string} [rerenderKey] A key to use to force a rerender.
860
+ * @see {@link https://on.cypress.io/mounting-react} for more details.
861
+ * @example
862
+ * import { mount } from '@cypress/react'
863
+ * import { Stepper } from './Stepper'
864
+ *
865
+ * it('mounts', () => {
866
+ * mount(<StepperComponent />)
867
+ * cy.get('[data-cy=increment]').click()
868
+ * cy.get('[data-cy=counter]').should('have.text', '1')
869
+ * }
870
+ */
871
+ function mount(jsx, options = {}, rerenderKey) {
872
+ if (major_1(React__default.version) === 18) {
873
+ 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.';
874
+ console.error(message);
875
+ Cypress.log({ name: 'warning', message });
876
+ }
877
+ // Remove last mounted component if cy.mount is called more than once in a test
878
+ cleanup();
879
+ const internalOptions = {
880
+ reactDom: ReactDOM,
881
+ render: (reactComponent, el, reactDomToUse) => {
882
+ lastReactDom = (reactDomToUse || ReactDOM);
883
+ return lastReactDom.render(reactComponent, el);
884
+ },
885
+ unmount: internalUnmount,
886
+ cleanup,
887
+ };
888
+ return makeMountFn('mount', jsx, Object.assign({ ReactDom: ReactDOM }, options), rerenderKey, internalOptions);
889
+ }
890
+ /**
891
+ * Unmounts the component from the DOM.
892
+ * @internal
893
+ * @param options - Options for unmounting.
894
+ */
895
+ function internalUnmount(options = { log: true }) {
896
+ return makeUnmountFn(options);
897
+ }
898
+ /**
899
+ * Removed as of Cypress 11.0.0.
900
+ * @see https://on.cypress.io/migration-11-0-0-component-testing-updates
901
+ */
902
+ function unmount(options = { log: true }) {
903
+ // @ts-expect-error - undocumented API
904
+ Cypress.utils.throwErrByPath('mount.unmount');
905
+ }
906
+
907
+ /**
908
+ * Mounts a React hook function in a test component for testing.
909
+ * Removed as of Cypress 11.0.0.
910
+ * @see https://on.cypress.io/migration-11-0-0-component-testing-updates
911
+ */
912
+ const mountHook = (hookFn) => {
913
+ // @ts-expect-error - internal API
914
+ Cypress.utils.throwErrByPath('mount.mount_hook');
915
+ };
916
+
917
+ export { createMount, getContainerEl, makeMountFn, makeUnmountFn, mount, mountHook, unmount };