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,592 @@
1
+
2
+ /**
3
+ * @cypress/react18 v0.0.0-development
4
+ * (c) 2023 Cypress.io
5
+ * Released under the MIT License
6
+ */
7
+
8
+ 'use strict';
9
+
10
+ var ReactDOM = require('react-dom/client');
11
+ var React = require('react');
12
+ require('react-dom');
13
+
14
+ function _interopNamespaceDefault(e) {
15
+ var n = Object.create(null);
16
+ if (e) {
17
+ Object.keys(e).forEach(function (k) {
18
+ if (k !== 'default') {
19
+ var d = Object.getOwnPropertyDescriptor(e, k);
20
+ Object.defineProperty(n, k, d.get ? d : {
21
+ enumerable: true,
22
+ get: function () { return e[k]; }
23
+ });
24
+ }
25
+ });
26
+ }
27
+ n.default = e;
28
+ return Object.freeze(n);
29
+ }
30
+
31
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
32
+
33
+ const ROOT_SELECTOR$1 = '[data-cy-root]';
34
+ /**
35
+ * Gets the root element used to mount the component.
36
+ * @returns {HTMLElement} The root element
37
+ * @throws {Error} If the root element is not found
38
+ */
39
+ const getContainerEl$1 = () => {
40
+ const el = document.querySelector(ROOT_SELECTOR$1);
41
+ if (el) {
42
+ return el;
43
+ }
44
+ throw Error(`No element found that matches selector ${ROOT_SELECTOR$1}. 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.`);
45
+ };
46
+
47
+ /**
48
+ * Gets the display name of the component when possible.
49
+ * @param type {JSX} The type object returned from creating the react element.
50
+ * @param fallbackName {string} The alias, or fallback name to use when the name cannot be derived.
51
+ * @link https://github.com/facebook/react-devtools/blob/master/backend/getDisplayName.js
52
+ */
53
+ function getDisplayName(node, fallbackName = 'Unknown') {
54
+ const type = node === null || node === void 0 ? void 0 : node.type;
55
+ if (!type) {
56
+ return fallbackName;
57
+ }
58
+ let displayName = null;
59
+ // The displayName property is not guaranteed to be a string.
60
+ // It's only safe to use for our purposes if it's a string.
61
+ // github.com/facebook/react-devtools/issues/803
62
+ if (typeof type.displayName === 'string') {
63
+ displayName = type.displayName;
64
+ }
65
+ if (!displayName) {
66
+ displayName = type.name || fallbackName;
67
+ }
68
+ // Facebook-specific hack to turn "Image [from Image.react]" into just "Image".
69
+ // We need displayName with module name for error reports but it clutters the DevTools.
70
+ const match = displayName.match(/^(.*) \[from (.*)\]$/);
71
+ if (match) {
72
+ const componentName = match[1];
73
+ const moduleName = match[2];
74
+ if (componentName && moduleName) {
75
+ if (moduleName === componentName ||
76
+ moduleName.startsWith(`${componentName}.`)) {
77
+ displayName = componentName;
78
+ }
79
+ }
80
+ }
81
+ return displayName;
82
+ }
83
+
84
+ const ROOT_SELECTOR = '[data-cy-root]';
85
+ /**
86
+ * Gets the root element used to mount the component.
87
+ * @returns {HTMLElement} The root element
88
+ * @throws {Error} If the root element is not found
89
+ */
90
+ const getContainerEl = () => {
91
+ const el = document.querySelector(ROOT_SELECTOR);
92
+ if (el) {
93
+ return el;
94
+ }
95
+ 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.`);
96
+ };
97
+ function checkForRemovedStyleOptions(mountingOptions) {
98
+ for (const key of ['cssFile', 'cssFiles', 'style', 'styles', 'stylesheet', 'stylesheets']) {
99
+ if (mountingOptions[key]) {
100
+ Cypress.utils.throwErrByPath('mount.removed_style_mounting_options', key);
101
+ }
102
+ }
103
+ }
104
+ /**
105
+ * Utility function to register CT side effects and run cleanup code during the "test:before:run" Cypress hook
106
+ * @param optionalCallback Callback to be called before the next test runs
107
+ */
108
+ function setupHooks(optionalCallback) {
109
+ // We don't want CT side effects to run when e2e
110
+ // testing so we early return.
111
+ // System test to verify CT side effects do not pollute e2e: system-tests/test/e2e_with_mount_import_spec.ts
112
+ if (Cypress.testingType !== 'component') {
113
+ return;
114
+ }
115
+ // When running component specs, we cannot allow "cy.visit"
116
+ // because it will wipe out our preparation work, and does not make much sense
117
+ // thus we overwrite "cy.visit" to throw an error
118
+ Cypress.Commands.overwrite('visit', () => {
119
+ throw new Error('cy.visit from a component spec is not allowed');
120
+ });
121
+ Cypress.Commands.overwrite('session', () => {
122
+ throw new Error('cy.session from a component spec is not allowed');
123
+ });
124
+ Cypress.Commands.overwrite('origin', () => {
125
+ throw new Error('cy.origin from a component spec is not allowed');
126
+ });
127
+ // @ts-ignore
128
+ Cypress.on('test:before:after:run:async', () => {
129
+ optionalCallback === null || optionalCallback === void 0 ? void 0 : optionalCallback();
130
+ });
131
+ }
132
+
133
+ let mountCleanup;
134
+ /**
135
+ * Create an `mount` function. Performs all the non-React-version specific
136
+ * behavior related to mounting. The React-version-specific code
137
+ * is injected. This helps us to maintain a consistent public API
138
+ * and handle breaking changes in React's rendering API.
139
+ *
140
+ * This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
141
+ * or people writing adapters for third-party, custom adapters.
142
+ */
143
+ const makeMountFn = (type, jsx, options = {}, rerenderKey, internalMountOptions) => {
144
+ if (!internalMountOptions) {
145
+ throw Error('internalMountOptions must be provided with `render` and `reactDom` parameters');
146
+ }
147
+ // @ts-expect-error - this is removed but we want to check if a user is passing it, and error if they are.
148
+ if (options.alias) {
149
+ // @ts-expect-error
150
+ Cypress.utils.throwErrByPath('mount.alias', options.alias);
151
+ }
152
+ checkForRemovedStyleOptions(options);
153
+ mountCleanup = internalMountOptions.cleanup;
154
+ return cy
155
+ .then(() => {
156
+ var _a, _b, _c;
157
+ const reactDomToUse = internalMountOptions.reactDom;
158
+ const el = getContainerEl();
159
+ if (!el) {
160
+ throw new Error([
161
+ `[@cypress/react] 🔥 Hmm, cannot find root element to mount the component. Searched for ${ROOT_SELECTOR}`,
162
+ ].join(' '));
163
+ }
164
+ const key = rerenderKey !== null && rerenderKey !== void 0 ? rerenderKey :
165
+ // @ts-ignore provide unique key to the the wrapped component to make sure we are rerendering between tests
166
+ (((_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();
167
+ const props = {
168
+ key,
169
+ };
170
+ const reactComponent = React__namespace.createElement(options.strict ? React__namespace.StrictMode : React__namespace.Fragment, props, jsx);
171
+ // since we always surround the component with a fragment
172
+ // let's get back the original component
173
+ const userComponent = reactComponent.props.children;
174
+ internalMountOptions.render(reactComponent, el, reactDomToUse);
175
+ return (cy.wrap(userComponent, { log: false })
176
+ .then(() => {
177
+ return cy.wrap({
178
+ component: userComponent,
179
+ rerender: (newComponent) => makeMountFn('rerender', newComponent, options, key, internalMountOptions),
180
+ unmount: () => {
181
+ // @ts-expect-error - undocumented API
182
+ Cypress.utils.throwErrByPath('mount.unmount');
183
+ },
184
+ }, { log: false });
185
+ })
186
+ // by waiting, we delaying test execution for the next tick of event loop
187
+ // and letting hooks and component lifecycle methods to execute mount
188
+ // https://github.com/bahmutov/cypress-react-unit-test/issues/200
189
+ .wait(0, { log: false })
190
+ .then(() => {
191
+ if (options.log !== false) {
192
+ // Get the display name property via the component constructor
193
+ // @ts-ignore FIXME
194
+ const componentName = getDisplayName(jsx);
195
+ const jsxComponentName = `<${componentName} ... />`;
196
+ Cypress.log({
197
+ name: type,
198
+ type: 'parent',
199
+ message: [jsxComponentName],
200
+ // @ts-ignore
201
+ $el: el.children.item(0),
202
+ consoleProps: () => {
203
+ return {
204
+ // @ts-ignore protect the use of jsx functional components use ReactNode
205
+ props: jsx === null || jsx === void 0 ? void 0 : jsx.props,
206
+ description: type === 'mount' ? 'Mounts React component' : 'Rerenders mounted React component',
207
+ home: 'https://github.com/cypress-io/cypress',
208
+ };
209
+ },
210
+ });
211
+ }
212
+ }));
213
+ // Bluebird types are terrible. I don't think the return type can be carried without this cast
214
+ });
215
+ };
216
+ /**
217
+ * Create an `unmount` function. Performs all the non-React-version specific
218
+ * behavior related to unmounting.
219
+ *
220
+ * This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
221
+ * or people writing adapters for third-party, custom adapters.
222
+ *
223
+ * @param {UnmountArgs} options used during unmounting
224
+ */
225
+ const makeUnmountFn = (options) => {
226
+ return cy.then(() => {
227
+ var _a;
228
+ const wasUnmounted = mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
229
+ if (wasUnmounted && options.log) {
230
+ Cypress.log({
231
+ name: 'unmount',
232
+ type: 'parent',
233
+ message: [(_a = options.boundComponentMessage) !== null && _a !== void 0 ? _a : 'Unmounted component'],
234
+ consoleProps: () => {
235
+ return {
236
+ description: 'Unmounts React component',
237
+ parent: getContainerEl().parentNode,
238
+ home: 'https://github.com/cypress-io/cypress',
239
+ };
240
+ },
241
+ });
242
+ }
243
+ });
244
+ };
245
+ // Cleanup before each run
246
+ // NOTE: we cannot use unmount here because
247
+ // we are not in the context of a test
248
+ const preMountCleanup = () => {
249
+ mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
250
+ };
251
+ // Side effects from "import { mount } from '@cypress/<my-framework>'" are annoying, we should avoid doing this
252
+ // by creating an explicit function/import that the user can register in their 'component.js' support file,
253
+ // such as:
254
+ // import 'cypress/<my-framework>/support'
255
+ // or
256
+ // import { registerCT } from 'cypress/<my-framework>'
257
+ // registerCT()
258
+ // Note: This would be a breaking change
259
+ // it is required to unmount component in beforeEach hook in order to provide a clean state inside test
260
+ // because `mount` can be called after some preparation that can side effect unmount
261
+ // @see npm/react/cypress/component/advanced/set-timeout-example/loading-indicator-spec.js
262
+ setupHooks(preMountCleanup);
263
+
264
+ const debug = (
265
+ typeof process === 'object' &&
266
+ process.env &&
267
+ process.env.NODE_DEBUG &&
268
+ /\bsemver\b/i.test(process.env.NODE_DEBUG)
269
+ ) ? (...args) => console.error('SEMVER', ...args)
270
+ : () => {};
271
+
272
+ var debug_1 = debug;
273
+
274
+ // Note: this is the semver.org version of the spec that it implements
275
+ // Not necessarily the package version of this code.
276
+ const SEMVER_SPEC_VERSION = '2.0.0';
277
+
278
+ const MAX_LENGTH$1 = 256;
279
+ const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER ||
280
+ /* istanbul ignore next */ 9007199254740991;
281
+
282
+ // Max safe segment length for coercion.
283
+ const MAX_SAFE_COMPONENT_LENGTH = 16;
284
+
285
+ // Max safe length for a build identifier. The max length minus 6 characters for
286
+ // the shortest version with a build 0.0.0+BUILD.
287
+ const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH$1 - 6;
288
+
289
+ const RELEASE_TYPES = [
290
+ 'major',
291
+ 'premajor',
292
+ 'minor',
293
+ 'preminor',
294
+ 'patch',
295
+ 'prepatch',
296
+ 'prerelease',
297
+ ];
298
+
299
+ var constants = {
300
+ MAX_LENGTH: MAX_LENGTH$1,
301
+ MAX_SAFE_COMPONENT_LENGTH,
302
+ MAX_SAFE_BUILD_LENGTH,
303
+ MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
304
+ RELEASE_TYPES,
305
+ SEMVER_SPEC_VERSION,
306
+ FLAG_INCLUDE_PRERELEASE: 0b001,
307
+ FLAG_LOOSE: 0b010,
308
+ };
309
+
310
+ function createCommonjsModule(fn) {
311
+ var module = { exports: {} };
312
+ return fn(module, module.exports), module.exports;
313
+ }
314
+
315
+ createCommonjsModule(function (module, exports) {
316
+ const {
317
+ MAX_SAFE_COMPONENT_LENGTH,
318
+ MAX_SAFE_BUILD_LENGTH,
319
+ MAX_LENGTH,
320
+ } = constants;
321
+
322
+ exports = module.exports = {};
323
+
324
+ // The actual regexps go on exports.re
325
+ const re = exports.re = [];
326
+ const safeRe = exports.safeRe = [];
327
+ const src = exports.src = [];
328
+ const t = exports.t = {};
329
+ let R = 0;
330
+
331
+ const LETTERDASHNUMBER = '[a-zA-Z0-9-]';
332
+
333
+ // Replace some greedy regex tokens to prevent regex dos issues. These regex are
334
+ // used internally via the safeRe object since all inputs in this library get
335
+ // normalized first to trim and collapse all extra whitespace. The original
336
+ // regexes are exported for userland consumption and lower level usage. A
337
+ // future breaking change could export the safer regex only with a note that
338
+ // all input should have extra whitespace removed.
339
+ const safeRegexReplacements = [
340
+ ['\\s', 1],
341
+ ['\\d', MAX_LENGTH],
342
+ [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],
343
+ ];
344
+
345
+ const makeSafeRegex = (value) => {
346
+ for (const [token, max] of safeRegexReplacements) {
347
+ value = value
348
+ .split(`${token}*`).join(`${token}{0,${max}}`)
349
+ .split(`${token}+`).join(`${token}{1,${max}}`);
350
+ }
351
+ return value
352
+ };
353
+
354
+ const createToken = (name, value, isGlobal) => {
355
+ const safe = makeSafeRegex(value);
356
+ const index = R++;
357
+ debug_1(name, index, value);
358
+ t[name] = index;
359
+ src[index] = value;
360
+ re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
361
+ safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined);
362
+ };
363
+
364
+ // The following Regular Expressions can be used for tokenizing,
365
+ // validating, and parsing SemVer version strings.
366
+
367
+ // ## Numeric Identifier
368
+ // A single `0`, or a non-zero digit followed by zero or more digits.
369
+
370
+ createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
371
+ createToken('NUMERICIDENTIFIERLOOSE', '\\d+');
372
+
373
+ // ## Non-numeric Identifier
374
+ // Zero or more digits, followed by a letter or hyphen, and then zero or
375
+ // more letters, digits, or hyphens.
376
+
377
+ createToken('NONNUMERICIDENTIFIER', `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`);
378
+
379
+ // ## Main Version
380
+ // Three dot-separated numeric identifiers.
381
+
382
+ createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
383
+ `(${src[t.NUMERICIDENTIFIER]})\\.` +
384
+ `(${src[t.NUMERICIDENTIFIER]})`);
385
+
386
+ createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
387
+ `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
388
+ `(${src[t.NUMERICIDENTIFIERLOOSE]})`);
389
+
390
+ // ## Pre-release Version Identifier
391
+ // A numeric identifier, or a non-numeric identifier.
392
+
393
+ createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
394
+ }|${src[t.NONNUMERICIDENTIFIER]})`);
395
+
396
+ createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
397
+ }|${src[t.NONNUMERICIDENTIFIER]})`);
398
+
399
+ // ## Pre-release Version
400
+ // Hyphen, followed by one or more dot-separated pre-release version
401
+ // identifiers.
402
+
403
+ createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
404
+ }(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
405
+
406
+ createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
407
+ }(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
408
+
409
+ // ## Build Metadata Identifier
410
+ // Any combination of digits, letters, or hyphens.
411
+
412
+ createToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`);
413
+
414
+ // ## Build Metadata
415
+ // Plus sign, followed by one or more period-separated build metadata
416
+ // identifiers.
417
+
418
+ createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
419
+ }(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
420
+
421
+ // ## Full Version String
422
+ // A main version, followed optionally by a pre-release version and
423
+ // build metadata.
424
+
425
+ // Note that the only major, minor, patch, and pre-release sections of
426
+ // the version string are capturing groups. The build metadata is not a
427
+ // capturing group, because it should not ever be used in version
428
+ // comparison.
429
+
430
+ createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
431
+ }${src[t.PRERELEASE]}?${
432
+ src[t.BUILD]}?`);
433
+
434
+ createToken('FULL', `^${src[t.FULLPLAIN]}$`);
435
+
436
+ // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
437
+ // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
438
+ // common in the npm registry.
439
+ createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
440
+ }${src[t.PRERELEASELOOSE]}?${
441
+ src[t.BUILD]}?`);
442
+
443
+ createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
444
+
445
+ createToken('GTLT', '((?:<|>)?=?)');
446
+
447
+ // Something like "2.*" or "1.2.x".
448
+ // Note that "x.x" is a valid xRange identifer, meaning "any version"
449
+ // Only the first item is strictly required.
450
+ createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
451
+ createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
452
+
453
+ createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
454
+ `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
455
+ `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
456
+ `(?:${src[t.PRERELEASE]})?${
457
+ src[t.BUILD]}?` +
458
+ `)?)?`);
459
+
460
+ createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
461
+ `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
462
+ `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
463
+ `(?:${src[t.PRERELEASELOOSE]})?${
464
+ src[t.BUILD]}?` +
465
+ `)?)?`);
466
+
467
+ createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
468
+ createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
469
+
470
+ // Coercion.
471
+ // Extract anything that could conceivably be a part of a valid semver
472
+ createToken('COERCE', `${'(^|[^\\d])' +
473
+ '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
474
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
475
+ `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
476
+ `(?:$|[^\\d])`);
477
+ createToken('COERCERTL', src[t.COERCE], true);
478
+
479
+ // Tilde ranges.
480
+ // Meaning is "reasonably at or greater than"
481
+ createToken('LONETILDE', '(?:~>?)');
482
+
483
+ createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
484
+ exports.tildeTrimReplace = '$1~';
485
+
486
+ createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
487
+ createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
488
+
489
+ // Caret ranges.
490
+ // Meaning is "at least and backwards compatible with"
491
+ createToken('LONECARET', '(?:\\^)');
492
+
493
+ createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
494
+ exports.caretTrimReplace = '$1^';
495
+
496
+ createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
497
+ createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
498
+
499
+ // A simple gt/lt/eq thing, or just "" to indicate "any version"
500
+ createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
501
+ createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
502
+
503
+ // An expression to strip any whitespace between the gtlt and the thing
504
+ // it modifies, so that `> 1.2.3` ==> `>1.2.3`
505
+ createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
506
+ }\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
507
+ exports.comparatorTrimReplace = '$1$2$3';
508
+
509
+ // Something like `1.2.3 - 1.2.4`
510
+ // Note that these all use the loose form, because they'll be
511
+ // checked against either the strict or loose comparator form
512
+ // later.
513
+ createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
514
+ `\\s+-\\s+` +
515
+ `(${src[t.XRANGEPLAIN]})` +
516
+ `\\s*$`);
517
+
518
+ createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
519
+ `\\s+-\\s+` +
520
+ `(${src[t.XRANGEPLAINLOOSE]})` +
521
+ `\\s*$`);
522
+
523
+ // Star ranges basically just allow anything at all.
524
+ createToken('STAR', '(<|>)?=?\\s*\\*');
525
+ // >=0.0.0 is like a star
526
+ createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
527
+ createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
528
+ });
529
+
530
+ // @ts-expect-error
531
+ let root;
532
+ const cleanup = () => {
533
+ if (root) {
534
+ root.unmount();
535
+ root = null;
536
+ return true;
537
+ }
538
+ return false;
539
+ };
540
+ /**
541
+ * Mounts a React component into the DOM.
542
+ * @param {import('react').JSX.Element} jsx The React component to mount.
543
+ * @param {MountOptions} options Options to pass to the mount function.
544
+ * @param {string} rerenderKey A key to use to force a rerender.
545
+ *
546
+ * @example
547
+ * import { mount } from '@cypress/react'
548
+ * import { Stepper } from './Stepper'
549
+ *
550
+ * it('mounts', () => {
551
+ * mount(<StepperComponent />)
552
+ * cy.get('[data-cy=increment]').click()
553
+ * cy.get('[data-cy=counter]').should('have.text', '1')
554
+ * }
555
+ *
556
+ * @see {@link https://on.cypress.io/mounting-react} for more details.
557
+ *
558
+ * @returns {Cypress.Chainable<MountReturn>} The mounted component.
559
+ */
560
+ function mount(jsx, options = {}, rerenderKey) {
561
+ // Remove last mounted component if cy.mount is called more than once in a test
562
+ // React by default removes the last component when calling render, but we should remove the root
563
+ // to wipe away any state
564
+ cleanup();
565
+ const internalOptions = {
566
+ reactDom: ReactDOM,
567
+ render: (reactComponent, el) => {
568
+ if (!root) {
569
+ root = ReactDOM.createRoot(el);
570
+ }
571
+ return root.render(reactComponent);
572
+ },
573
+ unmount: internalUnmount,
574
+ cleanup,
575
+ };
576
+ return makeMountFn('mount', jsx, Object.assign({ ReactDom: ReactDOM }, options), rerenderKey, internalOptions);
577
+ }
578
+ function internalUnmount(options = { log: true }) {
579
+ return makeUnmountFn(options);
580
+ }
581
+ /**
582
+ * Removed as of Cypress 11.0.0.
583
+ * @see https://on.cypress.io/migration-11-0-0-component-testing-updates
584
+ */
585
+ function unmount(options = { log: true }) {
586
+ // @ts-expect-error - undocumented API
587
+ Cypress.utils.throwErrByPath('mount.unmount');
588
+ }
589
+
590
+ exports.getContainerEl = getContainerEl$1;
591
+ exports.mount = mount;
592
+ exports.unmount = unmount;