cypress 13.17.0 → 14.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/angular/README.md +5 -0
- package/angular/angular/README.md +5 -0
- package/angular/angular/dist/index.d.ts +11 -2
- package/angular/angular/dist/index.js +944 -4
- package/angular/angular/package.json +16 -9
- package/angular/dist/index.d.ts +11 -2
- package/angular/dist/index.js +944 -4
- package/angular/package.json +16 -9
- package/lib/cli.js +1 -30
- package/lib/exec/spawn.js +17 -7
- package/mount-utils/dist/index.d.ts +0 -28
- package/mount-utils/dist/index.js +0 -27
- package/mount-utils/mount-utils/dist/index.d.ts +0 -28
- package/mount-utils/mount-utils/dist/index.js +0 -27
- package/package.json +5 -23
- package/react/README.md +5 -0
- package/react/dist/cypress-react.cjs.js +21 -676
- package/react/dist/cypress-react.esm-bundler.js +22 -676
- package/react/dist/index.d.ts +13 -30
- package/react/package.json +13 -15
- package/react/react/README.md +5 -0
- package/react/react/dist/cypress-react.cjs.js +21 -676
- package/react/react/dist/cypress-react.esm-bundler.js +22 -676
- package/react/react/dist/index.d.ts +13 -30
- package/react/react/package.json +13 -15
- package/svelte/README.md +6 -2
- package/svelte/dist/cypress-svelte.cjs.js +12 -12
- package/svelte/dist/cypress-svelte.esm-bundler.js +12 -12
- package/svelte/dist/index.d.ts +8 -179
- package/svelte/package.json +2 -2
- package/svelte/svelte/README.md +6 -2
- package/svelte/svelte/dist/cypress-svelte.cjs.js +12 -12
- package/svelte/svelte/dist/cypress-svelte.esm-bundler.js +12 -12
- package/svelte/svelte/dist/index.d.ts +8 -179
- package/svelte/svelte/package.json +2 -2
- package/types/cypress.d.ts +32 -49
- package/types/net-stubbing.d.ts +2 -7
- package/vue/dist/cypress-vue.cjs.js +380 -275
- package/vue/dist/cypress-vue.esm-bundler.js +382 -276
- package/vue/dist/index.d.ts +61 -78
- package/vue/package.json +2 -5
- package/vue/vue/dist/cypress-vue.cjs.js +380 -275
- package/vue/vue/dist/cypress-vue.esm-bundler.js +382 -276
- package/vue/vue/dist/index.d.ts +61 -78
- package/vue/vue/package.json +2 -5
- package/angular-signals/README.md +0 -11
- package/angular-signals/angular-signals/README.md +0 -11
- package/angular-signals/angular-signals/dist/index.d.ts +0 -136
- package/angular-signals/angular-signals/dist/index.js +0 -1861
- package/angular-signals/angular-signals/package.json +0 -74
- package/angular-signals/dist/index.d.ts +0 -136
- package/angular-signals/dist/index.js +0 -1861
- package/angular-signals/package.json +0 -74
- package/react18/README.md +0 -7
- package/react18/dist/cypress-react.cjs.js +0 -597
- package/react18/dist/cypress-react.esm-bundler.js +0 -574
- package/react18/dist/index.d.ts +0 -78
- package/react18/package.json +0 -71
- package/react18/react18/README.md +0 -7
- package/react18/react18/dist/cypress-react.cjs.js +0 -597
- package/react18/react18/dist/cypress-react.esm-bundler.js +0 -574
- package/react18/react18/dist/index.d.ts +0 -78
- package/react18/react18/package.json +0 -71
- package/vue2/README.md +0 -7
- package/vue2/dist/cypress-vue2.cjs.js +0 -20045
- package/vue2/dist/cypress-vue2.esm-bundler.js +0 -20042
- package/vue2/dist/index.d.ts +0 -207
- package/vue2/package.json +0 -65
- package/vue2/vue2/README.md +0 -7
- package/vue2/vue2/dist/cypress-vue2.cjs.js +0 -20045
- package/vue2/vue2/dist/cypress-vue2.esm-bundler.js +0 -20042
- package/vue2/vue2/dist/index.d.ts +0 -207
- package/vue2/vue2/package.json +0 -65
@@ -1,13 +1,12 @@
|
|
1
1
|
|
2
2
|
/**
|
3
3
|
* @cypress/react v0.0.0-development
|
4
|
-
* (c)
|
4
|
+
* (c) 2025 Cypress.io
|
5
5
|
* Released under the MIT License
|
6
6
|
*/
|
7
7
|
|
8
8
|
import * as React from 'react';
|
9
|
-
import
|
10
|
-
import ReactDOM from 'react-dom';
|
9
|
+
import ReactDOM from 'react-dom/client';
|
11
10
|
|
12
11
|
/**
|
13
12
|
* Gets the display name of the component when possible.
|
@@ -59,13 +58,6 @@ const getContainerEl = () => {
|
|
59
58
|
}
|
60
59
|
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
60
|
};
|
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
61
|
/**
|
70
62
|
* Utility function to register CT side effects and run cleanup code during the "test:before:run" Cypress hook
|
71
63
|
* @param optionalCallback Callback to be called before the next test runs
|
@@ -109,12 +101,6 @@ const makeMountFn = (type, jsx, options = {}, rerenderKey, internalMountOptions)
|
|
109
101
|
if (!internalMountOptions) {
|
110
102
|
throw Error('internalMountOptions must be provided with `render` and `reactDom` parameters');
|
111
103
|
}
|
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
104
|
mountCleanup = internalMountOptions.cleanup;
|
119
105
|
return cy
|
120
106
|
.then(() => {
|
@@ -142,10 +128,6 @@ const makeMountFn = (type, jsx, options = {}, rerenderKey, internalMountOptions)
|
|
142
128
|
return cy.wrap({
|
143
129
|
component: userComponent,
|
144
130
|
rerender: (newComponent) => makeMountFn('rerender', newComponent, options, key, internalMountOptions),
|
145
|
-
unmount: () => {
|
146
|
-
// @ts-expect-error - undocumented API
|
147
|
-
Cypress.utils.throwErrByPath('mount.unmount');
|
148
|
-
},
|
149
131
|
}, { log: false });
|
150
132
|
})
|
151
133
|
// by waiting, we delaying test execution for the next tick of event loop
|
@@ -232,637 +214,21 @@ const createMount = (defaultOptions) => {
|
|
232
214
|
// @see npm/react/cypress/component/advanced/set-timeout-example/loading-indicator-spec.js
|
233
215
|
setupHooks(preMountCleanup);
|
234
216
|
|
235
|
-
|
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('COERCEPLAIN', `${'(^|[^\\d])' +
|
444
|
-
'(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
|
445
|
-
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
|
446
|
-
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`);
|
447
|
-
createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`);
|
448
|
-
createToken('COERCEFULL', src[t.COERCEPLAIN] +
|
449
|
-
`(?:${src[t.PRERELEASE]})?` +
|
450
|
-
`(?:${src[t.BUILD]})?` +
|
451
|
-
`(?:$|[^\\d])`);
|
452
|
-
createToken('COERCERTL', src[t.COERCE], true);
|
453
|
-
createToken('COERCERTLFULL', src[t.COERCEFULL], true);
|
454
|
-
|
455
|
-
// Tilde ranges.
|
456
|
-
// Meaning is "reasonably at or greater than"
|
457
|
-
createToken('LONETILDE', '(?:~>?)');
|
458
|
-
|
459
|
-
createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
460
|
-
exports.tildeTrimReplace = '$1~';
|
461
|
-
|
462
|
-
createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
463
|
-
createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
464
|
-
|
465
|
-
// Caret ranges.
|
466
|
-
// Meaning is "at least and backwards compatible with"
|
467
|
-
createToken('LONECARET', '(?:\\^)');
|
468
|
-
|
469
|
-
createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
470
|
-
exports.caretTrimReplace = '$1^';
|
471
|
-
|
472
|
-
createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
473
|
-
createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
474
|
-
|
475
|
-
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
476
|
-
createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
477
|
-
createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
478
|
-
|
479
|
-
// An expression to strip any whitespace between the gtlt and the thing
|
480
|
-
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
481
|
-
createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
|
482
|
-
}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
483
|
-
exports.comparatorTrimReplace = '$1$2$3';
|
484
|
-
|
485
|
-
// Something like `1.2.3 - 1.2.4`
|
486
|
-
// Note that these all use the loose form, because they'll be
|
487
|
-
// checked against either the strict or loose comparator form
|
488
|
-
// later.
|
489
|
-
createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
|
490
|
-
`\\s+-\\s+` +
|
491
|
-
`(${src[t.XRANGEPLAIN]})` +
|
492
|
-
`\\s*$`);
|
493
|
-
|
494
|
-
createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
|
495
|
-
`\\s+-\\s+` +
|
496
|
-
`(${src[t.XRANGEPLAINLOOSE]})` +
|
497
|
-
`\\s*$`);
|
498
|
-
|
499
|
-
// Star ranges basically just allow anything at all.
|
500
|
-
createToken('STAR', '(<|>)?=?\\s*\\*');
|
501
|
-
// >=0.0.0 is like a star
|
502
|
-
createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
|
503
|
-
createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
|
504
|
-
});
|
505
|
-
|
506
|
-
// parse out just the options we care about
|
507
|
-
const looseOption = Object.freeze({ loose: true });
|
508
|
-
const emptyOpts = Object.freeze({ });
|
509
|
-
const parseOptions = options => {
|
510
|
-
if (!options) {
|
511
|
-
return emptyOpts
|
512
|
-
}
|
513
|
-
|
514
|
-
if (typeof options !== 'object') {
|
515
|
-
return looseOption
|
516
|
-
}
|
517
|
-
|
518
|
-
return options
|
519
|
-
};
|
520
|
-
var parseOptions_1 = parseOptions;
|
521
|
-
|
522
|
-
const numeric = /^[0-9]+$/;
|
523
|
-
const compareIdentifiers$1 = (a, b) => {
|
524
|
-
const anum = numeric.test(a);
|
525
|
-
const bnum = numeric.test(b);
|
526
|
-
|
527
|
-
if (anum && bnum) {
|
528
|
-
a = +a;
|
529
|
-
b = +b;
|
530
|
-
}
|
531
|
-
|
532
|
-
return a === b ? 0
|
533
|
-
: (anum && !bnum) ? -1
|
534
|
-
: (bnum && !anum) ? 1
|
535
|
-
: a < b ? -1
|
536
|
-
: 1
|
537
|
-
};
|
538
|
-
|
539
|
-
const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
|
540
|
-
|
541
|
-
var identifiers = {
|
542
|
-
compareIdentifiers: compareIdentifiers$1,
|
543
|
-
rcompareIdentifiers,
|
544
|
-
};
|
545
|
-
|
546
|
-
const { MAX_LENGTH, MAX_SAFE_INTEGER } = constants;
|
547
|
-
const { safeRe: re, t } = re_1;
|
548
|
-
|
549
|
-
|
550
|
-
const { compareIdentifiers } = identifiers;
|
551
|
-
class SemVer {
|
552
|
-
constructor (version, options) {
|
553
|
-
options = parseOptions_1(options);
|
554
|
-
|
555
|
-
if (version instanceof SemVer) {
|
556
|
-
if (version.loose === !!options.loose &&
|
557
|
-
version.includePrerelease === !!options.includePrerelease) {
|
558
|
-
return version
|
559
|
-
} else {
|
560
|
-
version = version.version;
|
561
|
-
}
|
562
|
-
} else if (typeof version !== 'string') {
|
563
|
-
throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`)
|
564
|
-
}
|
565
|
-
|
566
|
-
if (version.length > MAX_LENGTH) {
|
567
|
-
throw new TypeError(
|
568
|
-
`version is longer than ${MAX_LENGTH} characters`
|
569
|
-
)
|
570
|
-
}
|
571
|
-
|
572
|
-
debug_1('SemVer', version, options);
|
573
|
-
this.options = options;
|
574
|
-
this.loose = !!options.loose;
|
575
|
-
// this isn't actually relevant for versions, but keep it so that we
|
576
|
-
// don't run into trouble passing this.options around.
|
577
|
-
this.includePrerelease = !!options.includePrerelease;
|
578
|
-
|
579
|
-
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
580
|
-
|
581
|
-
if (!m) {
|
582
|
-
throw new TypeError(`Invalid Version: ${version}`)
|
583
|
-
}
|
584
|
-
|
585
|
-
this.raw = version;
|
586
|
-
|
587
|
-
// these are actually numbers
|
588
|
-
this.major = +m[1];
|
589
|
-
this.minor = +m[2];
|
590
|
-
this.patch = +m[3];
|
591
|
-
|
592
|
-
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
593
|
-
throw new TypeError('Invalid major version')
|
594
|
-
}
|
595
|
-
|
596
|
-
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
597
|
-
throw new TypeError('Invalid minor version')
|
598
|
-
}
|
599
|
-
|
600
|
-
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
601
|
-
throw new TypeError('Invalid patch version')
|
602
|
-
}
|
603
|
-
|
604
|
-
// numberify any prerelease numeric ids
|
605
|
-
if (!m[4]) {
|
606
|
-
this.prerelease = [];
|
607
|
-
} else {
|
608
|
-
this.prerelease = m[4].split('.').map((id) => {
|
609
|
-
if (/^[0-9]+$/.test(id)) {
|
610
|
-
const num = +id;
|
611
|
-
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
612
|
-
return num
|
613
|
-
}
|
614
|
-
}
|
615
|
-
return id
|
616
|
-
});
|
617
|
-
}
|
618
|
-
|
619
|
-
this.build = m[5] ? m[5].split('.') : [];
|
620
|
-
this.format();
|
621
|
-
}
|
622
|
-
|
623
|
-
format () {
|
624
|
-
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
625
|
-
if (this.prerelease.length) {
|
626
|
-
this.version += `-${this.prerelease.join('.')}`;
|
627
|
-
}
|
628
|
-
return this.version
|
629
|
-
}
|
630
|
-
|
631
|
-
toString () {
|
632
|
-
return this.version
|
633
|
-
}
|
634
|
-
|
635
|
-
compare (other) {
|
636
|
-
debug_1('SemVer.compare', this.version, this.options, other);
|
637
|
-
if (!(other instanceof SemVer)) {
|
638
|
-
if (typeof other === 'string' && other === this.version) {
|
639
|
-
return 0
|
640
|
-
}
|
641
|
-
other = new SemVer(other, this.options);
|
642
|
-
}
|
643
|
-
|
644
|
-
if (other.version === this.version) {
|
645
|
-
return 0
|
646
|
-
}
|
647
|
-
|
648
|
-
return this.compareMain(other) || this.comparePre(other)
|
649
|
-
}
|
650
|
-
|
651
|
-
compareMain (other) {
|
652
|
-
if (!(other instanceof SemVer)) {
|
653
|
-
other = new SemVer(other, this.options);
|
654
|
-
}
|
655
|
-
|
656
|
-
return (
|
657
|
-
compareIdentifiers(this.major, other.major) ||
|
658
|
-
compareIdentifiers(this.minor, other.minor) ||
|
659
|
-
compareIdentifiers(this.patch, other.patch)
|
660
|
-
)
|
661
|
-
}
|
662
|
-
|
663
|
-
comparePre (other) {
|
664
|
-
if (!(other instanceof SemVer)) {
|
665
|
-
other = new SemVer(other, this.options);
|
666
|
-
}
|
667
|
-
|
668
|
-
// NOT having a prerelease is > having one
|
669
|
-
if (this.prerelease.length && !other.prerelease.length) {
|
670
|
-
return -1
|
671
|
-
} else if (!this.prerelease.length && other.prerelease.length) {
|
672
|
-
return 1
|
673
|
-
} else if (!this.prerelease.length && !other.prerelease.length) {
|
674
|
-
return 0
|
675
|
-
}
|
676
|
-
|
677
|
-
let i = 0;
|
678
|
-
do {
|
679
|
-
const a = this.prerelease[i];
|
680
|
-
const b = other.prerelease[i];
|
681
|
-
debug_1('prerelease compare', i, a, b);
|
682
|
-
if (a === undefined && b === undefined) {
|
683
|
-
return 0
|
684
|
-
} else if (b === undefined) {
|
685
|
-
return 1
|
686
|
-
} else if (a === undefined) {
|
687
|
-
return -1
|
688
|
-
} else if (a === b) {
|
689
|
-
continue
|
690
|
-
} else {
|
691
|
-
return compareIdentifiers(a, b)
|
692
|
-
}
|
693
|
-
} while (++i)
|
694
|
-
}
|
695
|
-
|
696
|
-
compareBuild (other) {
|
697
|
-
if (!(other instanceof SemVer)) {
|
698
|
-
other = new SemVer(other, this.options);
|
699
|
-
}
|
700
|
-
|
701
|
-
let i = 0;
|
702
|
-
do {
|
703
|
-
const a = this.build[i];
|
704
|
-
const b = other.build[i];
|
705
|
-
debug_1('build compare', i, a, b);
|
706
|
-
if (a === undefined && b === undefined) {
|
707
|
-
return 0
|
708
|
-
} else if (b === undefined) {
|
709
|
-
return 1
|
710
|
-
} else if (a === undefined) {
|
711
|
-
return -1
|
712
|
-
} else if (a === b) {
|
713
|
-
continue
|
714
|
-
} else {
|
715
|
-
return compareIdentifiers(a, b)
|
716
|
-
}
|
717
|
-
} while (++i)
|
718
|
-
}
|
719
|
-
|
720
|
-
// preminor will bump the version up to the next minor release, and immediately
|
721
|
-
// down to pre-release. premajor and prepatch work the same way.
|
722
|
-
inc (release, identifier, identifierBase) {
|
723
|
-
switch (release) {
|
724
|
-
case 'premajor':
|
725
|
-
this.prerelease.length = 0;
|
726
|
-
this.patch = 0;
|
727
|
-
this.minor = 0;
|
728
|
-
this.major++;
|
729
|
-
this.inc('pre', identifier, identifierBase);
|
730
|
-
break
|
731
|
-
case 'preminor':
|
732
|
-
this.prerelease.length = 0;
|
733
|
-
this.patch = 0;
|
734
|
-
this.minor++;
|
735
|
-
this.inc('pre', identifier, identifierBase);
|
736
|
-
break
|
737
|
-
case 'prepatch':
|
738
|
-
// If this is already a prerelease, it will bump to the next version
|
739
|
-
// drop any prereleases that might already exist, since they are not
|
740
|
-
// relevant at this point.
|
741
|
-
this.prerelease.length = 0;
|
742
|
-
this.inc('patch', identifier, identifierBase);
|
743
|
-
this.inc('pre', identifier, identifierBase);
|
744
|
-
break
|
745
|
-
// If the input is a non-prerelease version, this acts the same as
|
746
|
-
// prepatch.
|
747
|
-
case 'prerelease':
|
748
|
-
if (this.prerelease.length === 0) {
|
749
|
-
this.inc('patch', identifier, identifierBase);
|
750
|
-
}
|
751
|
-
this.inc('pre', identifier, identifierBase);
|
752
|
-
break
|
753
|
-
|
754
|
-
case 'major':
|
755
|
-
// If this is a pre-major version, bump up to the same major version.
|
756
|
-
// Otherwise increment major.
|
757
|
-
// 1.0.0-5 bumps to 1.0.0
|
758
|
-
// 1.1.0 bumps to 2.0.0
|
759
|
-
if (
|
760
|
-
this.minor !== 0 ||
|
761
|
-
this.patch !== 0 ||
|
762
|
-
this.prerelease.length === 0
|
763
|
-
) {
|
764
|
-
this.major++;
|
765
|
-
}
|
766
|
-
this.minor = 0;
|
767
|
-
this.patch = 0;
|
768
|
-
this.prerelease = [];
|
769
|
-
break
|
770
|
-
case 'minor':
|
771
|
-
// If this is a pre-minor version, bump up to the same minor version.
|
772
|
-
// Otherwise increment minor.
|
773
|
-
// 1.2.0-5 bumps to 1.2.0
|
774
|
-
// 1.2.1 bumps to 1.3.0
|
775
|
-
if (this.patch !== 0 || this.prerelease.length === 0) {
|
776
|
-
this.minor++;
|
777
|
-
}
|
778
|
-
this.patch = 0;
|
779
|
-
this.prerelease = [];
|
780
|
-
break
|
781
|
-
case 'patch':
|
782
|
-
// If this is not a pre-release version, it will increment the patch.
|
783
|
-
// If it is a pre-release it will bump up to the same patch version.
|
784
|
-
// 1.2.0-5 patches to 1.2.0
|
785
|
-
// 1.2.0 patches to 1.2.1
|
786
|
-
if (this.prerelease.length === 0) {
|
787
|
-
this.patch++;
|
788
|
-
}
|
789
|
-
this.prerelease = [];
|
790
|
-
break
|
791
|
-
// This probably shouldn't be used publicly.
|
792
|
-
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
|
793
|
-
case 'pre': {
|
794
|
-
const base = Number(identifierBase) ? 1 : 0;
|
795
|
-
|
796
|
-
if (!identifier && identifierBase === false) {
|
797
|
-
throw new Error('invalid increment argument: identifier is empty')
|
798
|
-
}
|
799
|
-
|
800
|
-
if (this.prerelease.length === 0) {
|
801
|
-
this.prerelease = [base];
|
802
|
-
} else {
|
803
|
-
let i = this.prerelease.length;
|
804
|
-
while (--i >= 0) {
|
805
|
-
if (typeof this.prerelease[i] === 'number') {
|
806
|
-
this.prerelease[i]++;
|
807
|
-
i = -2;
|
808
|
-
}
|
809
|
-
}
|
810
|
-
if (i === -1) {
|
811
|
-
// didn't increment anything
|
812
|
-
if (identifier === this.prerelease.join('.') && identifierBase === false) {
|
813
|
-
throw new Error('invalid increment argument: identifier already exists')
|
814
|
-
}
|
815
|
-
this.prerelease.push(base);
|
816
|
-
}
|
817
|
-
}
|
818
|
-
if (identifier) {
|
819
|
-
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
820
|
-
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
821
|
-
let prerelease = [identifier, base];
|
822
|
-
if (identifierBase === false) {
|
823
|
-
prerelease = [identifier];
|
824
|
-
}
|
825
|
-
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
|
826
|
-
if (isNaN(this.prerelease[1])) {
|
827
|
-
this.prerelease = prerelease;
|
828
|
-
}
|
829
|
-
} else {
|
830
|
-
this.prerelease = prerelease;
|
831
|
-
}
|
832
|
-
}
|
833
|
-
break
|
834
|
-
}
|
835
|
-
default:
|
836
|
-
throw new Error(`invalid increment argument: ${release}`)
|
837
|
-
}
|
838
|
-
this.raw = this.format();
|
839
|
-
if (this.build.length) {
|
840
|
-
this.raw += `+${this.build.join('.')}`;
|
841
|
-
}
|
842
|
-
return this
|
843
|
-
}
|
844
|
-
}
|
845
|
-
|
846
|
-
var semver = SemVer;
|
847
|
-
|
848
|
-
const major = (a, loose) => new semver(a, loose).major;
|
849
|
-
var major_1 = major;
|
850
|
-
|
851
|
-
let lastReactDom;
|
217
|
+
let root;
|
852
218
|
const cleanup = () => {
|
853
|
-
if (
|
854
|
-
|
855
|
-
|
219
|
+
if (root) {
|
220
|
+
root.unmount();
|
221
|
+
root = null;
|
856
222
|
return true;
|
857
223
|
}
|
858
224
|
return false;
|
859
225
|
};
|
860
226
|
/**
|
861
227
|
* Mounts a React component into the DOM.
|
862
|
-
* @param
|
863
|
-
* @param
|
864
|
-
* @param
|
865
|
-
*
|
228
|
+
* @param {import('react').JSX.Element} jsx The React component to mount.
|
229
|
+
* @param {MountOptions} options Options to pass to the mount function.
|
230
|
+
* @param {string} rerenderKey A key to use to force a rerender.
|
231
|
+
*
|
866
232
|
* @example
|
867
233
|
* import { mount } from '@cypress/react'
|
868
234
|
* import { Stepper } from './Stepper'
|
@@ -872,51 +238,31 @@ const cleanup = () => {
|
|
872
238
|
* cy.get('[data-cy=increment]').click()
|
873
239
|
* cy.get('[data-cy=counter]').should('have.text', '1')
|
874
240
|
* }
|
241
|
+
*
|
242
|
+
* @see {@link https://on.cypress.io/mounting-react} for more details.
|
243
|
+
*
|
244
|
+
* @returns {Cypress.Chainable<MountReturn>} The mounted component.
|
875
245
|
*/
|
876
246
|
function mount(jsx, options = {}, rerenderKey) {
|
877
|
-
if (major_1(React__default.version) === 18) {
|
878
|
-
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.';
|
879
|
-
console.error(message);
|
880
|
-
Cypress.log({ name: 'warning', message });
|
881
|
-
}
|
882
247
|
// Remove last mounted component if cy.mount is called more than once in a test
|
248
|
+
// React by default removes the last component when calling render, but we should remove the root
|
249
|
+
// to wipe away any state
|
883
250
|
cleanup();
|
884
251
|
const internalOptions = {
|
885
252
|
reactDom: ReactDOM,
|
886
|
-
render: (reactComponent, el
|
887
|
-
|
888
|
-
|
253
|
+
render: (reactComponent, el) => {
|
254
|
+
if (!root) {
|
255
|
+
root = ReactDOM.createRoot(el);
|
256
|
+
}
|
257
|
+
return root.render(reactComponent);
|
889
258
|
},
|
890
259
|
unmount: internalUnmount,
|
891
260
|
cleanup,
|
892
261
|
};
|
893
262
|
return makeMountFn('mount', jsx, Object.assign({ ReactDom: ReactDOM }, options), rerenderKey, internalOptions);
|
894
263
|
}
|
895
|
-
/**
|
896
|
-
* Unmounts the component from the DOM.
|
897
|
-
* @internal
|
898
|
-
* @param options - Options for unmounting.
|
899
|
-
*/
|
900
264
|
function internalUnmount(options = { log: true }) {
|
901
265
|
return makeUnmountFn(options);
|
902
266
|
}
|
903
|
-
/**
|
904
|
-
* Removed as of Cypress 11.0.0.
|
905
|
-
* @see https://on.cypress.io/migration-11-0-0-component-testing-updates
|
906
|
-
*/
|
907
|
-
function unmount(options = { log: true }) {
|
908
|
-
// @ts-expect-error - undocumented API
|
909
|
-
Cypress.utils.throwErrByPath('mount.unmount');
|
910
|
-
}
|
911
|
-
|
912
|
-
/**
|
913
|
-
* Mounts a React hook function in a test component for testing.
|
914
|
-
* Removed as of Cypress 11.0.0.
|
915
|
-
* @see https://on.cypress.io/migration-11-0-0-component-testing-updates
|
916
|
-
*/
|
917
|
-
const mountHook = (hookFn) => {
|
918
|
-
// @ts-expect-error - internal API
|
919
|
-
Cypress.utils.throwErrByPath('mount.mount_hook');
|
920
|
-
};
|
921
267
|
|
922
|
-
export { createMount, getContainerEl, makeMountFn, makeUnmountFn, mount
|
268
|
+
export { createMount, getContainerEl, makeMountFn, makeUnmountFn, mount };
|