cypress 10.4.0 → 10.7.0
Sign up to get free protection for your applications and to get access to all the features.
- package/angular/CHANGELOG.md +86 -0
- package/angular/README.md +85 -0
- package/angular/dist/index.d.ts +1 -0
- package/angular/dist/index.js +265 -0
- package/angular/dist/mount.d.ts +112 -0
- package/angular/package.json +68 -0
- package/lib/tasks/download.js +4 -3
- package/mount-utils/CHANGELOG.md +7 -0
- package/mount-utils/package.json +5 -1
- package/package.json +16 -4
- package/react/CHANGELOG.md +20 -0
- package/react/dist/createMount.d.ts +7 -6
- package/react/dist/cypress-react.cjs.js +653 -140
- package/react/dist/cypress-react.esm-bundler.js +640 -127
- package/react/dist/mount.d.ts +2 -1
- package/react/dist/mountHook.d.ts +1 -0
- package/react/dist/types.d.ts +2 -7
- package/react/package.json +4 -6
- package/react18/CHANGELOG.md +13 -0
- package/react18/dist/cypress-react.cjs.js +300 -118
- package/react18/dist/cypress-react.esm-bundler.js +286 -104
- package/react18/dist/index.d.ts +2 -1
- package/react18/package.json +2 -2
- package/svelte/CHANGELOG.md +0 -0
- package/svelte/README.md +83 -0
- package/svelte/dist/cypress-svelte.cjs.js +213 -0
- package/svelte/dist/cypress-svelte.esm-bundler.js +209 -0
- package/svelte/dist/index.d.ts +1 -0
- package/svelte/dist/mount.d.ts +30 -0
- package/svelte/package.json +43 -0
- package/types/cypress-type-helpers.d.ts +3 -1
- package/types/cypress.d.ts +61 -5
- package/vue/CHANGELOG.md +14 -0
- package/vue/dist/cypress-vue.cjs.js +30 -38
- package/vue/dist/cypress-vue.esm-bundler.js +30 -38
- package/vue/dist/index.d.ts +1 -0
- package/vue/package.json +2 -8
- package/vue2/CHANGELOG.md +7 -0
- package/vue2/dist/cypress-vue2.cjs.js +53 -84
- package/vue2/dist/cypress-vue2.esm-bundler.js +53 -84
- package/vue2/dist/index.d.ts +1 -0
- package/vue2/package.json +2 -5
- package/vue2/dist/cypress-vue2.browser.js +0 -20197
@@ -6,48 +6,22 @@
|
|
6
6
|
*/
|
7
7
|
|
8
8
|
import * as React from 'react';
|
9
|
+
import React__default from 'react';
|
9
10
|
import ReactDOM from 'react-dom';
|
10
11
|
|
11
|
-
|
12
|
-
Copyright (c) Microsoft Corporation.
|
13
|
-
|
14
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
15
|
-
purpose with or without fee is hereby granted.
|
16
|
-
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
18
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
19
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
20
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
21
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
22
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
23
|
-
PERFORMANCE OF THIS SOFTWARE.
|
24
|
-
***************************************************************************** */
|
25
|
-
|
26
|
-
var __assign = function() {
|
27
|
-
__assign = Object.assign || function __assign(t) {
|
28
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
29
|
-
s = arguments[i];
|
30
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
31
|
-
}
|
32
|
-
return t;
|
33
|
-
};
|
34
|
-
return __assign.apply(this, arguments);
|
35
|
-
};
|
36
|
-
|
37
|
-
var cachedDisplayNames = new WeakMap();
|
12
|
+
const cachedDisplayNames = new WeakMap();
|
38
13
|
/**
|
39
14
|
* Gets the display name of the component when possible.
|
40
15
|
* @param type {JSX} The type object returned from creating the react element.
|
41
16
|
* @param fallbackName {string} The alias, or fallback name to use when the name cannot be derived.
|
42
17
|
* @link https://github.com/facebook/react-devtools/blob/master/backend/getDisplayName.js
|
43
18
|
*/
|
44
|
-
function getDisplayName(type, fallbackName) {
|
45
|
-
|
46
|
-
var nameFromCache = cachedDisplayNames.get(type);
|
19
|
+
function getDisplayName(type, fallbackName = 'Unknown') {
|
20
|
+
const nameFromCache = cachedDisplayNames.get(type);
|
47
21
|
if (nameFromCache != null) {
|
48
22
|
return nameFromCache;
|
49
23
|
}
|
50
|
-
|
24
|
+
let displayName = null;
|
51
25
|
// The displayName property is not guaranteed to be a string.
|
52
26
|
// It's only safe to use for our purposes if it's a string.
|
53
27
|
// github.com/facebook/react-devtools/issues/803
|
@@ -59,13 +33,13 @@ function getDisplayName(type, fallbackName) {
|
|
59
33
|
}
|
60
34
|
// Facebook-specific hack to turn "Image [from Image.react]" into just "Image".
|
61
35
|
// We need displayName with module name for error reports but it clutters the DevTools.
|
62
|
-
|
36
|
+
const match = displayName.match(/^(.*) \[from (.*)\]$/);
|
63
37
|
if (match) {
|
64
|
-
|
65
|
-
|
38
|
+
const componentName = match[1];
|
39
|
+
const moduleName = match[2];
|
66
40
|
if (componentName && moduleName) {
|
67
41
|
if (moduleName === componentName ||
|
68
|
-
moduleName.startsWith(componentName
|
42
|
+
moduleName.startsWith(`${componentName}.`)) {
|
69
43
|
displayName = componentName;
|
70
44
|
}
|
71
45
|
}
|
@@ -224,13 +198,13 @@ function setupHooks(optionalCallback) {
|
|
224
198
|
/**
|
225
199
|
* Inject custom style text or CSS file or 3rd party style resources
|
226
200
|
*/
|
227
|
-
|
228
|
-
return
|
229
|
-
|
201
|
+
const injectStyles = (options) => {
|
202
|
+
return () => {
|
203
|
+
const el = getContainerEl();
|
230
204
|
return injectStylesBeforeElement(options, document, el);
|
231
205
|
};
|
232
206
|
};
|
233
|
-
|
207
|
+
let mountCleanup;
|
234
208
|
/**
|
235
209
|
* Create an `mount` function. Performs all the non-React-version specific
|
236
210
|
* behavior related to mounting. The React-version-specific code
|
@@ -240,41 +214,40 @@ var lastMountedReactDom;
|
|
240
214
|
* This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
|
241
215
|
* or people writing adapters for third-party, custom adapters.
|
242
216
|
*/
|
243
|
-
|
244
|
-
if (options === void 0) { options = {}; }
|
217
|
+
const makeMountFn = (type, jsx, options = {}, rerenderKey, internalMountOptions) => {
|
245
218
|
if (!internalMountOptions) {
|
246
219
|
throw Error('internalMountOptions must be provided with `render` and `reactDom` parameters');
|
247
220
|
}
|
221
|
+
mountCleanup = internalMountOptions.cleanup;
|
248
222
|
// Get the display name property via the component constructor
|
249
223
|
// @ts-ignore FIXME
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
? jsxComponentName
|
224
|
+
const componentName = getDisplayName(jsx.type, options.alias);
|
225
|
+
const displayName = options.alias || componentName;
|
226
|
+
const jsxComponentName = `<${componentName} ... />`;
|
227
|
+
const message = options.alias
|
228
|
+
? `${jsxComponentName} as "${options.alias}"`
|
255
229
|
: jsxComponentName;
|
256
230
|
return cy
|
257
231
|
.then(injectStyles(options))
|
258
|
-
.then(
|
232
|
+
.then(() => {
|
259
233
|
var _a, _b, _c;
|
260
|
-
|
261
|
-
|
262
|
-
var el = getContainerEl();
|
234
|
+
const reactDomToUse = internalMountOptions.reactDom;
|
235
|
+
const el = getContainerEl();
|
263
236
|
if (!el) {
|
264
237
|
throw new Error([
|
265
|
-
|
238
|
+
`[@cypress/react] 🔥 Hmm, cannot find root element to mount the component. Searched for ${ROOT_SELECTOR}`,
|
266
239
|
].join(' '));
|
267
240
|
}
|
268
|
-
|
241
|
+
const key = rerenderKey !== null && rerenderKey !== void 0 ? rerenderKey :
|
269
242
|
// @ts-ignore provide unique key to the the wrapped component to make sure we are rerendering between tests
|
270
243
|
(((_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();
|
271
|
-
|
272
|
-
key
|
244
|
+
const props = {
|
245
|
+
key,
|
273
246
|
};
|
274
|
-
|
247
|
+
const reactComponent = React.createElement(options.strict ? React.StrictMode : React.Fragment, props, jsx);
|
275
248
|
// since we always surround the component with a fragment
|
276
249
|
// let's get back the original component
|
277
|
-
|
250
|
+
const userComponent = reactComponent.props.children;
|
278
251
|
internalMountOptions.render(reactComponent, el, reactDomToUse);
|
279
252
|
if (options.log !== false) {
|
280
253
|
Cypress.log({
|
@@ -283,7 +256,7 @@ var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOption
|
|
283
256
|
message: [message],
|
284
257
|
// @ts-ignore
|
285
258
|
$el: el.children.item(0),
|
286
|
-
consoleProps:
|
259
|
+
consoleProps: () => {
|
287
260
|
return {
|
288
261
|
// @ts-ignore protect the use of jsx functional components use ReactNode
|
289
262
|
props: jsx.props,
|
@@ -297,10 +270,10 @@ var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOption
|
|
297
270
|
// Separate alias and returned value. Alias returns the component only, and the thenable returns the additional functions
|
298
271
|
cy.wrap(userComponent, { log: false })
|
299
272
|
.as(displayName)
|
300
|
-
.then(
|
273
|
+
.then(() => {
|
301
274
|
return cy.wrap({
|
302
275
|
component: userComponent,
|
303
|
-
rerender:
|
276
|
+
rerender: (newComponent) => makeMountFn('rerender', newComponent, options, key, internalMountOptions),
|
304
277
|
unmount: internalMountOptions.unmount,
|
305
278
|
}, { log: false });
|
306
279
|
})
|
@@ -318,47 +291,36 @@ var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOption
|
|
318
291
|
* This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
|
319
292
|
* or people writing adapters for third-party, custom adapters.
|
320
293
|
*/
|
321
|
-
|
322
|
-
return cy.then(
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
},
|
340
|
-
});
|
341
|
-
}
|
342
|
-
}
|
343
|
-
});
|
294
|
+
const makeUnmountFn = (options) => {
|
295
|
+
return cy.then(() => {
|
296
|
+
var _a;
|
297
|
+
const wasUnmounted = mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
|
298
|
+
if (wasUnmounted && options.log) {
|
299
|
+
Cypress.log({
|
300
|
+
name: 'unmount',
|
301
|
+
type: 'parent',
|
302
|
+
message: [(_a = options.boundComponentMessage) !== null && _a !== void 0 ? _a : 'Unmounted component'],
|
303
|
+
consoleProps: () => {
|
304
|
+
return {
|
305
|
+
description: 'Unmounts React component',
|
306
|
+
parent: getContainerEl().parentNode,
|
307
|
+
home: 'https://github.com/cypress-io/cypress',
|
308
|
+
};
|
309
|
+
},
|
310
|
+
});
|
311
|
+
}
|
344
312
|
});
|
345
313
|
};
|
346
314
|
// Cleanup before each run
|
347
315
|
// NOTE: we cannot use unmount here because
|
348
316
|
// we are not in the context of a test
|
349
|
-
|
350
|
-
|
351
|
-
if (el && lastMountedReactDom) {
|
352
|
-
lastMountedReactDom.unmountComponentAtNode(el);
|
353
|
-
}
|
354
|
-
};
|
355
|
-
var _mount = function (jsx, options) {
|
356
|
-
if (options === void 0) { options = {}; }
|
357
|
-
return makeMountFn('mount', jsx, options);
|
317
|
+
const preMountCleanup = () => {
|
318
|
+
mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
|
358
319
|
};
|
359
|
-
|
360
|
-
|
361
|
-
|
320
|
+
const _mount = (jsx, options = {}) => makeMountFn('mount', jsx, options);
|
321
|
+
const createMount = (defaultOptions) => {
|
322
|
+
return (element, options) => {
|
323
|
+
return _mount(element, Object.assign(Object.assign({}, defaultOptions), options));
|
362
324
|
};
|
363
325
|
};
|
364
326
|
// Side effects from "import { mount } from '@cypress/<my-framework>'" are annoying, we should avoid doing this
|
@@ -374,34 +336,587 @@ var createMount = function (defaultOptions) {
|
|
374
336
|
// @see npm/react/cypress/component/advanced/set-timeout-example/loading-indicator-spec.js
|
375
337
|
setupHooks(preMountCleanup);
|
376
338
|
|
377
|
-
|
378
|
-
|
379
|
-
|
339
|
+
const debug = (
|
340
|
+
typeof process === 'object' &&
|
341
|
+
process.env &&
|
342
|
+
process.env.NODE_DEBUG &&
|
343
|
+
/\bsemver\b/i.test(process.env.NODE_DEBUG)
|
344
|
+
) ? (...args) => console.error('SEMVER', ...args)
|
345
|
+
: () => {};
|
346
|
+
|
347
|
+
var debug_1 = debug;
|
348
|
+
|
349
|
+
// Note: this is the semver.org version of the spec that it implements
|
350
|
+
// Not necessarily the package version of this code.
|
351
|
+
const SEMVER_SPEC_VERSION = '2.0.0';
|
352
|
+
|
353
|
+
const MAX_LENGTH$1 = 256;
|
354
|
+
const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER ||
|
355
|
+
/* istanbul ignore next */ 9007199254740991;
|
356
|
+
|
357
|
+
// Max safe segment length for coercion.
|
358
|
+
const MAX_SAFE_COMPONENT_LENGTH = 16;
|
359
|
+
|
360
|
+
var constants = {
|
361
|
+
SEMVER_SPEC_VERSION,
|
362
|
+
MAX_LENGTH: MAX_LENGTH$1,
|
363
|
+
MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
|
364
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
365
|
+
};
|
366
|
+
|
367
|
+
function createCommonjsModule(fn) {
|
368
|
+
var module = { exports: {} };
|
369
|
+
return fn(module, module.exports), module.exports;
|
370
|
+
}
|
371
|
+
|
372
|
+
var re_1 = createCommonjsModule(function (module, exports) {
|
373
|
+
const { MAX_SAFE_COMPONENT_LENGTH } = constants;
|
374
|
+
|
375
|
+
exports = module.exports = {};
|
376
|
+
|
377
|
+
// The actual regexps go on exports.re
|
378
|
+
const re = exports.re = [];
|
379
|
+
const src = exports.src = [];
|
380
|
+
const t = exports.t = {};
|
381
|
+
let R = 0;
|
382
|
+
|
383
|
+
const createToken = (name, value, isGlobal) => {
|
384
|
+
const index = R++;
|
385
|
+
debug_1(name, index, value);
|
386
|
+
t[name] = index;
|
387
|
+
src[index] = value;
|
388
|
+
re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
|
389
|
+
};
|
390
|
+
|
391
|
+
// The following Regular Expressions can be used for tokenizing,
|
392
|
+
// validating, and parsing SemVer version strings.
|
393
|
+
|
394
|
+
// ## Numeric Identifier
|
395
|
+
// A single `0`, or a non-zero digit followed by zero or more digits.
|
396
|
+
|
397
|
+
createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
|
398
|
+
createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+');
|
399
|
+
|
400
|
+
// ## Non-numeric Identifier
|
401
|
+
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
402
|
+
// more letters, digits, or hyphens.
|
403
|
+
|
404
|
+
createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*');
|
405
|
+
|
406
|
+
// ## Main Version
|
407
|
+
// Three dot-separated numeric identifiers.
|
408
|
+
|
409
|
+
createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
|
410
|
+
`(${src[t.NUMERICIDENTIFIER]})\\.` +
|
411
|
+
`(${src[t.NUMERICIDENTIFIER]})`);
|
412
|
+
|
413
|
+
createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
414
|
+
`(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
415
|
+
`(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
416
|
+
|
417
|
+
// ## Pre-release Version Identifier
|
418
|
+
// A numeric identifier, or a non-numeric identifier.
|
419
|
+
|
420
|
+
createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
|
421
|
+
}|${src[t.NONNUMERICIDENTIFIER]})`);
|
422
|
+
|
423
|
+
createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
|
424
|
+
}|${src[t.NONNUMERICIDENTIFIER]})`);
|
425
|
+
|
426
|
+
// ## Pre-release Version
|
427
|
+
// Hyphen, followed by one or more dot-separated pre-release version
|
428
|
+
// identifiers.
|
429
|
+
|
430
|
+
createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
|
431
|
+
}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
432
|
+
|
433
|
+
createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
|
434
|
+
}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
435
|
+
|
436
|
+
// ## Build Metadata Identifier
|
437
|
+
// Any combination of digits, letters, or hyphens.
|
438
|
+
|
439
|
+
createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+');
|
440
|
+
|
441
|
+
// ## Build Metadata
|
442
|
+
// Plus sign, followed by one or more period-separated build metadata
|
443
|
+
// identifiers.
|
444
|
+
|
445
|
+
createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
|
446
|
+
}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
447
|
+
|
448
|
+
// ## Full Version String
|
449
|
+
// A main version, followed optionally by a pre-release version and
|
450
|
+
// build metadata.
|
451
|
+
|
452
|
+
// Note that the only major, minor, patch, and pre-release sections of
|
453
|
+
// the version string are capturing groups. The build metadata is not a
|
454
|
+
// capturing group, because it should not ever be used in version
|
455
|
+
// comparison.
|
456
|
+
|
457
|
+
createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
|
458
|
+
}${src[t.PRERELEASE]}?${
|
459
|
+
src[t.BUILD]}?`);
|
460
|
+
|
461
|
+
createToken('FULL', `^${src[t.FULLPLAIN]}$`);
|
462
|
+
|
463
|
+
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
464
|
+
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
465
|
+
// common in the npm registry.
|
466
|
+
createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
|
467
|
+
}${src[t.PRERELEASELOOSE]}?${
|
468
|
+
src[t.BUILD]}?`);
|
469
|
+
|
470
|
+
createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
|
471
|
+
|
472
|
+
createToken('GTLT', '((?:<|>)?=?)');
|
473
|
+
|
474
|
+
// Something like "2.*" or "1.2.x".
|
475
|
+
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
476
|
+
// Only the first item is strictly required.
|
477
|
+
createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
478
|
+
createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
479
|
+
|
480
|
+
createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
|
481
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
|
482
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
|
483
|
+
`(?:${src[t.PRERELEASE]})?${
|
484
|
+
src[t.BUILD]}?` +
|
485
|
+
`)?)?`);
|
486
|
+
|
487
|
+
createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
488
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
489
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
490
|
+
`(?:${src[t.PRERELEASELOOSE]})?${
|
491
|
+
src[t.BUILD]}?` +
|
492
|
+
`)?)?`);
|
493
|
+
|
494
|
+
createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
495
|
+
createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
496
|
+
|
497
|
+
// Coercion.
|
498
|
+
// Extract anything that could conceivably be a part of a valid semver
|
499
|
+
createToken('COERCE', `${'(^|[^\\d])' +
|
500
|
+
'(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
|
501
|
+
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
|
502
|
+
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
|
503
|
+
`(?:$|[^\\d])`);
|
504
|
+
createToken('COERCERTL', src[t.COERCE], true);
|
505
|
+
|
506
|
+
// Tilde ranges.
|
507
|
+
// Meaning is "reasonably at or greater than"
|
508
|
+
createToken('LONETILDE', '(?:~>?)');
|
509
|
+
|
510
|
+
createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
511
|
+
exports.tildeTrimReplace = '$1~';
|
512
|
+
|
513
|
+
createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
514
|
+
createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
515
|
+
|
516
|
+
// Caret ranges.
|
517
|
+
// Meaning is "at least and backwards compatible with"
|
518
|
+
createToken('LONECARET', '(?:\\^)');
|
519
|
+
|
520
|
+
createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
521
|
+
exports.caretTrimReplace = '$1^';
|
522
|
+
|
523
|
+
createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
524
|
+
createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
525
|
+
|
526
|
+
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
527
|
+
createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
528
|
+
createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
529
|
+
|
530
|
+
// An expression to strip any whitespace between the gtlt and the thing
|
531
|
+
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
532
|
+
createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
|
533
|
+
}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
534
|
+
exports.comparatorTrimReplace = '$1$2$3';
|
535
|
+
|
536
|
+
// Something like `1.2.3 - 1.2.4`
|
537
|
+
// Note that these all use the loose form, because they'll be
|
538
|
+
// checked against either the strict or loose comparator form
|
539
|
+
// later.
|
540
|
+
createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
|
541
|
+
`\\s+-\\s+` +
|
542
|
+
`(${src[t.XRANGEPLAIN]})` +
|
543
|
+
`\\s*$`);
|
544
|
+
|
545
|
+
createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
|
546
|
+
`\\s+-\\s+` +
|
547
|
+
`(${src[t.XRANGEPLAINLOOSE]})` +
|
548
|
+
`\\s*$`);
|
549
|
+
|
550
|
+
// Star ranges basically just allow anything at all.
|
551
|
+
createToken('STAR', '(<|>)?=?\\s*\\*');
|
552
|
+
// >=0.0.0 is like a star
|
553
|
+
createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
|
554
|
+
createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
|
555
|
+
});
|
556
|
+
|
557
|
+
// parse out just the options we care about so we always get a consistent
|
558
|
+
// obj with keys in a consistent order.
|
559
|
+
const opts = ['includePrerelease', 'loose', 'rtl'];
|
560
|
+
const parseOptions = options =>
|
561
|
+
!options ? {}
|
562
|
+
: typeof options !== 'object' ? { loose: true }
|
563
|
+
: opts.filter(k => options[k]).reduce((o, k) => {
|
564
|
+
o[k] = true;
|
565
|
+
return o
|
566
|
+
}, {});
|
567
|
+
var parseOptions_1 = parseOptions;
|
568
|
+
|
569
|
+
const numeric = /^[0-9]+$/;
|
570
|
+
const compareIdentifiers$1 = (a, b) => {
|
571
|
+
const anum = numeric.test(a);
|
572
|
+
const bnum = numeric.test(b);
|
573
|
+
|
574
|
+
if (anum && bnum) {
|
575
|
+
a = +a;
|
576
|
+
b = +b;
|
577
|
+
}
|
578
|
+
|
579
|
+
return a === b ? 0
|
580
|
+
: (anum && !bnum) ? -1
|
581
|
+
: (bnum && !anum) ? 1
|
582
|
+
: a < b ? -1
|
583
|
+
: 1
|
584
|
+
};
|
585
|
+
|
586
|
+
const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
|
587
|
+
|
588
|
+
var identifiers = {
|
589
|
+
compareIdentifiers: compareIdentifiers$1,
|
590
|
+
rcompareIdentifiers,
|
591
|
+
};
|
592
|
+
|
593
|
+
const { MAX_LENGTH, MAX_SAFE_INTEGER } = constants;
|
594
|
+
const { re, t } = re_1;
|
595
|
+
|
596
|
+
|
597
|
+
const { compareIdentifiers } = identifiers;
|
598
|
+
class SemVer {
|
599
|
+
constructor (version, options) {
|
600
|
+
options = parseOptions_1(options);
|
601
|
+
|
602
|
+
if (version instanceof SemVer) {
|
603
|
+
if (version.loose === !!options.loose &&
|
604
|
+
version.includePrerelease === !!options.includePrerelease) {
|
605
|
+
return version
|
606
|
+
} else {
|
607
|
+
version = version.version;
|
608
|
+
}
|
609
|
+
} else if (typeof version !== 'string') {
|
610
|
+
throw new TypeError(`Invalid Version: ${version}`)
|
611
|
+
}
|
612
|
+
|
613
|
+
if (version.length > MAX_LENGTH) {
|
614
|
+
throw new TypeError(
|
615
|
+
`version is longer than ${MAX_LENGTH} characters`
|
616
|
+
)
|
617
|
+
}
|
618
|
+
|
619
|
+
debug_1('SemVer', version, options);
|
620
|
+
this.options = options;
|
621
|
+
this.loose = !!options.loose;
|
622
|
+
// this isn't actually relevant for versions, but keep it so that we
|
623
|
+
// don't run into trouble passing this.options around.
|
624
|
+
this.includePrerelease = !!options.includePrerelease;
|
625
|
+
|
626
|
+
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
627
|
+
|
628
|
+
if (!m) {
|
629
|
+
throw new TypeError(`Invalid Version: ${version}`)
|
630
|
+
}
|
631
|
+
|
632
|
+
this.raw = version;
|
633
|
+
|
634
|
+
// these are actually numbers
|
635
|
+
this.major = +m[1];
|
636
|
+
this.minor = +m[2];
|
637
|
+
this.patch = +m[3];
|
638
|
+
|
639
|
+
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
640
|
+
throw new TypeError('Invalid major version')
|
641
|
+
}
|
642
|
+
|
643
|
+
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
644
|
+
throw new TypeError('Invalid minor version')
|
645
|
+
}
|
646
|
+
|
647
|
+
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
648
|
+
throw new TypeError('Invalid patch version')
|
649
|
+
}
|
650
|
+
|
651
|
+
// numberify any prerelease numeric ids
|
652
|
+
if (!m[4]) {
|
653
|
+
this.prerelease = [];
|
654
|
+
} else {
|
655
|
+
this.prerelease = m[4].split('.').map((id) => {
|
656
|
+
if (/^[0-9]+$/.test(id)) {
|
657
|
+
const num = +id;
|
658
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
659
|
+
return num
|
660
|
+
}
|
661
|
+
}
|
662
|
+
return id
|
663
|
+
});
|
664
|
+
}
|
665
|
+
|
666
|
+
this.build = m[5] ? m[5].split('.') : [];
|
667
|
+
this.format();
|
668
|
+
}
|
669
|
+
|
670
|
+
format () {
|
671
|
+
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
672
|
+
if (this.prerelease.length) {
|
673
|
+
this.version += `-${this.prerelease.join('.')}`;
|
674
|
+
}
|
675
|
+
return this.version
|
676
|
+
}
|
677
|
+
|
678
|
+
toString () {
|
679
|
+
return this.version
|
680
|
+
}
|
681
|
+
|
682
|
+
compare (other) {
|
683
|
+
debug_1('SemVer.compare', this.version, this.options, other);
|
684
|
+
if (!(other instanceof SemVer)) {
|
685
|
+
if (typeof other === 'string' && other === this.version) {
|
686
|
+
return 0
|
687
|
+
}
|
688
|
+
other = new SemVer(other, this.options);
|
689
|
+
}
|
690
|
+
|
691
|
+
if (other.version === this.version) {
|
692
|
+
return 0
|
693
|
+
}
|
694
|
+
|
695
|
+
return this.compareMain(other) || this.comparePre(other)
|
696
|
+
}
|
697
|
+
|
698
|
+
compareMain (other) {
|
699
|
+
if (!(other instanceof SemVer)) {
|
700
|
+
other = new SemVer(other, this.options);
|
701
|
+
}
|
702
|
+
|
703
|
+
return (
|
704
|
+
compareIdentifiers(this.major, other.major) ||
|
705
|
+
compareIdentifiers(this.minor, other.minor) ||
|
706
|
+
compareIdentifiers(this.patch, other.patch)
|
707
|
+
)
|
708
|
+
}
|
709
|
+
|
710
|
+
comparePre (other) {
|
711
|
+
if (!(other instanceof SemVer)) {
|
712
|
+
other = new SemVer(other, this.options);
|
713
|
+
}
|
714
|
+
|
715
|
+
// NOT having a prerelease is > having one
|
716
|
+
if (this.prerelease.length && !other.prerelease.length) {
|
717
|
+
return -1
|
718
|
+
} else if (!this.prerelease.length && other.prerelease.length) {
|
719
|
+
return 1
|
720
|
+
} else if (!this.prerelease.length && !other.prerelease.length) {
|
721
|
+
return 0
|
722
|
+
}
|
723
|
+
|
724
|
+
let i = 0;
|
725
|
+
do {
|
726
|
+
const a = this.prerelease[i];
|
727
|
+
const b = other.prerelease[i];
|
728
|
+
debug_1('prerelease compare', i, a, b);
|
729
|
+
if (a === undefined && b === undefined) {
|
730
|
+
return 0
|
731
|
+
} else if (b === undefined) {
|
732
|
+
return 1
|
733
|
+
} else if (a === undefined) {
|
734
|
+
return -1
|
735
|
+
} else if (a === b) {
|
736
|
+
continue
|
737
|
+
} else {
|
738
|
+
return compareIdentifiers(a, b)
|
739
|
+
}
|
740
|
+
} while (++i)
|
741
|
+
}
|
742
|
+
|
743
|
+
compareBuild (other) {
|
744
|
+
if (!(other instanceof SemVer)) {
|
745
|
+
other = new SemVer(other, this.options);
|
746
|
+
}
|
747
|
+
|
748
|
+
let i = 0;
|
749
|
+
do {
|
750
|
+
const a = this.build[i];
|
751
|
+
const b = other.build[i];
|
752
|
+
debug_1('prerelease compare', i, a, b);
|
753
|
+
if (a === undefined && b === undefined) {
|
754
|
+
return 0
|
755
|
+
} else if (b === undefined) {
|
756
|
+
return 1
|
757
|
+
} else if (a === undefined) {
|
758
|
+
return -1
|
759
|
+
} else if (a === b) {
|
760
|
+
continue
|
761
|
+
} else {
|
762
|
+
return compareIdentifiers(a, b)
|
763
|
+
}
|
764
|
+
} while (++i)
|
765
|
+
}
|
766
|
+
|
767
|
+
// preminor will bump the version up to the next minor release, and immediately
|
768
|
+
// down to pre-release. premajor and prepatch work the same way.
|
769
|
+
inc (release, identifier) {
|
770
|
+
switch (release) {
|
771
|
+
case 'premajor':
|
772
|
+
this.prerelease.length = 0;
|
773
|
+
this.patch = 0;
|
774
|
+
this.minor = 0;
|
775
|
+
this.major++;
|
776
|
+
this.inc('pre', identifier);
|
777
|
+
break
|
778
|
+
case 'preminor':
|
779
|
+
this.prerelease.length = 0;
|
780
|
+
this.patch = 0;
|
781
|
+
this.minor++;
|
782
|
+
this.inc('pre', identifier);
|
783
|
+
break
|
784
|
+
case 'prepatch':
|
785
|
+
// If this is already a prerelease, it will bump to the next version
|
786
|
+
// drop any prereleases that might already exist, since they are not
|
787
|
+
// relevant at this point.
|
788
|
+
this.prerelease.length = 0;
|
789
|
+
this.inc('patch', identifier);
|
790
|
+
this.inc('pre', identifier);
|
791
|
+
break
|
792
|
+
// If the input is a non-prerelease version, this acts the same as
|
793
|
+
// prepatch.
|
794
|
+
case 'prerelease':
|
795
|
+
if (this.prerelease.length === 0) {
|
796
|
+
this.inc('patch', identifier);
|
797
|
+
}
|
798
|
+
this.inc('pre', identifier);
|
799
|
+
break
|
800
|
+
|
801
|
+
case 'major':
|
802
|
+
// If this is a pre-major version, bump up to the same major version.
|
803
|
+
// Otherwise increment major.
|
804
|
+
// 1.0.0-5 bumps to 1.0.0
|
805
|
+
// 1.1.0 bumps to 2.0.0
|
806
|
+
if (
|
807
|
+
this.minor !== 0 ||
|
808
|
+
this.patch !== 0 ||
|
809
|
+
this.prerelease.length === 0
|
810
|
+
) {
|
811
|
+
this.major++;
|
812
|
+
}
|
813
|
+
this.minor = 0;
|
814
|
+
this.patch = 0;
|
815
|
+
this.prerelease = [];
|
816
|
+
break
|
817
|
+
case 'minor':
|
818
|
+
// If this is a pre-minor version, bump up to the same minor version.
|
819
|
+
// Otherwise increment minor.
|
820
|
+
// 1.2.0-5 bumps to 1.2.0
|
821
|
+
// 1.2.1 bumps to 1.3.0
|
822
|
+
if (this.patch !== 0 || this.prerelease.length === 0) {
|
823
|
+
this.minor++;
|
824
|
+
}
|
825
|
+
this.patch = 0;
|
826
|
+
this.prerelease = [];
|
827
|
+
break
|
828
|
+
case 'patch':
|
829
|
+
// If this is not a pre-release version, it will increment the patch.
|
830
|
+
// If it is a pre-release it will bump up to the same patch version.
|
831
|
+
// 1.2.0-5 patches to 1.2.0
|
832
|
+
// 1.2.0 patches to 1.2.1
|
833
|
+
if (this.prerelease.length === 0) {
|
834
|
+
this.patch++;
|
835
|
+
}
|
836
|
+
this.prerelease = [];
|
837
|
+
break
|
838
|
+
// This probably shouldn't be used publicly.
|
839
|
+
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
|
840
|
+
case 'pre':
|
841
|
+
if (this.prerelease.length === 0) {
|
842
|
+
this.prerelease = [0];
|
843
|
+
} else {
|
844
|
+
let i = this.prerelease.length;
|
845
|
+
while (--i >= 0) {
|
846
|
+
if (typeof this.prerelease[i] === 'number') {
|
847
|
+
this.prerelease[i]++;
|
848
|
+
i = -2;
|
849
|
+
}
|
850
|
+
}
|
851
|
+
if (i === -1) {
|
852
|
+
// didn't increment anything
|
853
|
+
this.prerelease.push(0);
|
854
|
+
}
|
855
|
+
}
|
856
|
+
if (identifier) {
|
857
|
+
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
858
|
+
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
859
|
+
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
|
860
|
+
if (isNaN(this.prerelease[1])) {
|
861
|
+
this.prerelease = [identifier, 0];
|
862
|
+
}
|
863
|
+
} else {
|
864
|
+
this.prerelease = [identifier, 0];
|
865
|
+
}
|
866
|
+
}
|
867
|
+
break
|
868
|
+
|
869
|
+
default:
|
870
|
+
throw new Error(`invalid increment argument: ${release}`)
|
871
|
+
}
|
872
|
+
this.format();
|
873
|
+
this.raw = this.version;
|
874
|
+
return this
|
875
|
+
}
|
876
|
+
}
|
877
|
+
|
878
|
+
var semver = SemVer;
|
879
|
+
|
880
|
+
const major = (a, loose) => new semver(a, loose).major;
|
881
|
+
var major_1 = major;
|
882
|
+
|
883
|
+
let lastReactDom;
|
884
|
+
const cleanup = () => {
|
885
|
+
if (lastReactDom) {
|
886
|
+
const root = getContainerEl();
|
887
|
+
lastReactDom.unmountComponentAtNode(root);
|
888
|
+
return true;
|
889
|
+
}
|
890
|
+
return false;
|
891
|
+
};
|
892
|
+
function mount(jsx, options = {}, rerenderKey) {
|
893
|
+
if (major_1(React__default.version) === 18) {
|
894
|
+
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.';
|
895
|
+
console.error(message);
|
896
|
+
Cypress.log({ name: 'warning', message });
|
897
|
+
}
|
898
|
+
const internalOptions = {
|
380
899
|
reactDom: ReactDOM,
|
381
|
-
render:
|
382
|
-
|
900
|
+
render: (reactComponent, el, reactDomToUse) => {
|
901
|
+
lastReactDom = (reactDomToUse || ReactDOM);
|
902
|
+
return lastReactDom.render(reactComponent, el);
|
383
903
|
},
|
384
|
-
unmount
|
904
|
+
unmount,
|
905
|
+
cleanup,
|
385
906
|
};
|
386
|
-
return makeMountFn('mount', jsx,
|
907
|
+
return makeMountFn('mount', jsx, Object.assign({ ReactDom: ReactDOM }, options), rerenderKey, internalOptions);
|
387
908
|
}
|
388
|
-
function unmount(options) {
|
389
|
-
|
390
|
-
var internalOptions = {
|
391
|
-
unmount: function (el) {
|
392
|
-
return (lastMountedReactDom || ReactDOM).unmountComponentAtNode(el);
|
393
|
-
},
|
394
|
-
};
|
395
|
-
return makeUnmountFn(options, internalOptions);
|
909
|
+
function unmount(options = { log: true }) {
|
910
|
+
return makeUnmountFn(options);
|
396
911
|
}
|
397
912
|
|
398
913
|
// mounting hooks inside a test component mostly copied from
|
399
914
|
// https://github.com/testing-library/react-hooks-testing-library/blob/master/src/pure.js
|
400
915
|
function resultContainer() {
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
916
|
+
let value = null;
|
917
|
+
let error = null;
|
918
|
+
const resolvers = [];
|
919
|
+
const result = {
|
405
920
|
get current() {
|
406
921
|
if (error) {
|
407
922
|
throw error;
|
@@ -412,23 +927,21 @@ function resultContainer() {
|
|
412
927
|
return error;
|
413
928
|
},
|
414
929
|
};
|
415
|
-
|
416
|
-
if (err === void 0) { err = null; }
|
930
|
+
const updateResult = (val, err = null) => {
|
417
931
|
value = val;
|
418
932
|
error = err;
|
419
|
-
resolvers.splice(0, resolvers.length).forEach(
|
933
|
+
resolvers.splice(0, resolvers.length).forEach((resolve) => resolve());
|
420
934
|
};
|
421
935
|
return {
|
422
|
-
result
|
423
|
-
addResolver:
|
936
|
+
result,
|
937
|
+
addResolver: (resolver) => {
|
424
938
|
resolvers.push(resolver);
|
425
939
|
},
|
426
|
-
setValue:
|
427
|
-
setError:
|
940
|
+
setValue: (val) => updateResult(val),
|
941
|
+
setError: (err) => updateResult(undefined, err),
|
428
942
|
};
|
429
943
|
}
|
430
|
-
function TestHook(
|
431
|
-
var callback = _a.callback, onError = _a.onError, children = _a.children;
|
944
|
+
function TestHook({ callback, onError, children }) {
|
432
945
|
try {
|
433
946
|
children(callback());
|
434
947
|
}
|
@@ -446,14 +959,14 @@ function TestHook(_a) {
|
|
446
959
|
* Mounts a React hook function in a test component for testing.
|
447
960
|
*
|
448
961
|
*/
|
449
|
-
|
450
|
-
|
451
|
-
|
962
|
+
const mountHook = (hookFn) => {
|
963
|
+
const { result, setValue, setError } = resultContainer();
|
964
|
+
const componentTest = React.createElement(TestHook, {
|
452
965
|
callback: hookFn,
|
453
966
|
onError: setError,
|
454
967
|
children: setValue,
|
455
968
|
});
|
456
|
-
return mount(componentTest).then(
|
969
|
+
return mount(componentTest).then(() => result);
|
457
970
|
};
|
458
971
|
|
459
|
-
export { createMount,
|
972
|
+
export { createMount, makeMountFn, makeUnmountFn, mount, mountHook, unmount };
|