cypress 10.3.0 → 10.5.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/CHANGELOG.md +55 -0
- package/angular/README.md +154 -0
- package/angular/dist/index.d.ts +1 -0
- package/angular/dist/index.js +263 -0
- package/angular/dist/mount.d.ts +111 -0
- package/angular/package.json +70 -0
- package/lib/exec/open.js +7 -2
- package/lib/exec/spawn.js +7 -2
- package/mount-utils/CHANGELOG.md +7 -1
- package/mount-utils/README.md +7 -0
- package/mount-utils/dist/index.js +8 -1
- package/mount-utils/package.json +1 -0
- package/package.json +26 -10
- package/react/CHANGELOG.md +13 -19
- package/react/README.md +28 -323
- package/react/dist/createMount.d.ts +28 -0
- package/react/dist/cypress-react.cjs.js +643 -99
- package/react/dist/cypress-react.esm-bundler.js +640 -100
- package/react/dist/getDisplayName.d.ts +1 -1
- package/react/dist/index.d.ts +2 -0
- package/react/dist/mount.d.ts +5 -141
- package/react/dist/types.d.ts +44 -0
- package/react/package.json +3 -5
- package/react18/CHANGELOG.md +6 -0
- package/react18/dist/cypress-react.cjs.js +633 -0
- package/react18/dist/cypress-react.esm-bundler.js +605 -0
- package/react18/dist/index.d.ts +5 -0
- package/react18/package.json +59 -0
- package/types/cypress.d.ts +24 -3
- package/types/index.d.ts +1 -1
- package/types/{net-stubbing.ts → net-stubbing.d.ts} +0 -0
- package/vue/CHANGELOG.md +16 -17
- package/vue/README.md +17 -607
- package/vue/dist/@vue/test-utils/baseWrapper.d.ts +63 -0
- package/vue/dist/@vue/test-utils/components/RouterLinkStub.d.ts +21 -0
- package/vue/dist/@vue/test-utils/config.d.ts +30 -0
- package/vue/dist/@vue/test-utils/constants/dom-events.d.ts +900 -0
- package/vue/dist/@vue/test-utils/createDomEvent.d.ts +9 -0
- package/vue/dist/@vue/test-utils/domWrapper.d.ts +18 -0
- package/vue/dist/@vue/test-utils/emit.d.ts +5 -0
- package/vue/dist/@vue/test-utils/errorWrapper.d.ts +1 -0
- package/vue/dist/@vue/test-utils/index.d.ts +11 -0
- package/vue/dist/@vue/test-utils/interfaces/wrapperLike.d.ts +56 -0
- package/vue/dist/@vue/test-utils/mount.d.ts +35 -0
- package/vue/dist/@vue/test-utils/stubs.d.ts +22 -0
- package/vue/dist/@vue/test-utils/types.d.ts +125 -0
- package/vue/dist/@vue/test-utils/utils/autoUnmount.d.ts +5 -0
- package/vue/dist/@vue/test-utils/utils/compileSlots.d.ts +2 -0
- package/vue/dist/@vue/test-utils/utils/componentName.d.ts +4 -0
- package/vue/dist/@vue/test-utils/utils/find.d.ts +10 -0
- package/vue/dist/@vue/test-utils/utils/flushPromises.d.ts +1 -0
- package/vue/dist/@vue/test-utils/utils/getRootNodes.d.ts +2 -0
- package/vue/dist/@vue/test-utils/utils/isElement.d.ts +1 -0
- package/vue/dist/@vue/test-utils/utils/isElementVisible.d.ts +6 -0
- package/vue/dist/@vue/test-utils/utils/matchName.d.ts +1 -0
- package/vue/dist/@vue/test-utils/utils/stringifyNode.d.ts +1 -0
- package/vue/dist/@vue/test-utils/utils/vueCompatSupport.d.ts +8 -0
- package/vue/dist/@vue/test-utils/utils/vueShared.d.ts +3 -0
- package/vue/dist/@vue/test-utils/utils.d.ts +13 -0
- package/vue/dist/@vue/test-utils/vueWrapper.d.ts +35 -0
- package/vue/dist/@vue/test-utils/wrapperFactory.d.ts +14 -0
- package/vue/dist/cypress-vue.cjs.js +5585 -5211
- package/vue/dist/cypress-vue.esm-bundler.js +5586 -5213
- package/vue/dist/index.d.ts +35 -3
- package/vue/package.json +11 -8
- package/vue2/CHANGELOG.md +7 -0
- package/vue2/README.md +11 -627
- package/vue2/dist/cypress-vue2.browser.js +267 -261
- package/vue2/dist/cypress-vue2.cjs.js +266 -260
- package/vue2/dist/cypress-vue2.esm-bundler.js +264 -258
- package/vue2/package.json +1 -1
- package/react/dist/cypress-react.browser.js +0 -497
@@ -12,6 +12,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
12
12
|
var React = require('react');
|
13
13
|
var ReactDOM = require('react-dom');
|
14
14
|
|
15
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
16
|
+
|
15
17
|
function _interopNamespace(e) {
|
16
18
|
if (e && e.__esModule) return e;
|
17
19
|
var n = Object.create(null);
|
@@ -31,7 +33,8 @@ function _interopNamespace(e) {
|
|
31
33
|
}
|
32
34
|
|
33
35
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
34
|
-
var
|
36
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
37
|
+
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
35
38
|
|
36
39
|
/******************************************************************************
|
37
40
|
Copyright (c) Microsoft Corporation.
|
@@ -110,7 +113,7 @@ const getContainerEl = () => {
|
|
110
113
|
if (el) {
|
111
114
|
return el;
|
112
115
|
}
|
113
|
-
throw Error(`No element found that matches selector ${ROOT_SELECTOR}. Please
|
116
|
+
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.`);
|
114
117
|
};
|
115
118
|
/**
|
116
119
|
* Remove any style or extra link elements from the iframe placeholder
|
@@ -226,6 +229,13 @@ const injectStylesBeforeElement = (options, document, el) => {
|
|
226
229
|
return insertLocalCssFiles(cssFiles, document, el, options.log);
|
227
230
|
};
|
228
231
|
function setupHooks(optionalCallback) {
|
232
|
+
// Consumed by the framework "mount" libs. A user might register their own mount in the scaffolded 'commands.js'
|
233
|
+
// file that is imported by e2e and component support files by default. We don't want CT side effects to run when e2e
|
234
|
+
// testing so we early return.
|
235
|
+
// System test to verify CT side effects do not pollute e2e: system-tests/test/e2e_with_mount_import_spec.ts
|
236
|
+
if (Cypress.testingType !== 'component') {
|
237
|
+
return;
|
238
|
+
}
|
229
239
|
// When running component specs, we cannot allow "cy.visit"
|
230
240
|
// because it will wipe out our preparation work, and does not make much sense
|
231
241
|
// thus we overwrite "cy.visit" to throw an error
|
@@ -248,37 +258,22 @@ var injectStyles = function (options) {
|
|
248
258
|
return injectStylesBeforeElement(options, document, el);
|
249
259
|
};
|
250
260
|
};
|
261
|
+
var mountCleanup;
|
251
262
|
/**
|
252
|
-
*
|
253
|
-
*
|
254
|
-
*
|
255
|
-
*
|
256
|
-
*
|
257
|
-
*
|
258
|
-
*
|
259
|
-
* @example
|
260
|
-
```
|
261
|
-
import Hello from './hello.jsx'
|
262
|
-
import { mount } from '@cypress/react'
|
263
|
-
it('works', () => {
|
264
|
-
mount(<Hello onClick={cy.stub()} />)
|
265
|
-
// use Cypress commands
|
266
|
-
cy.contains('Hello').click()
|
267
|
-
})
|
268
|
-
```
|
269
|
-
**/
|
270
|
-
var mount = function (jsx, options) {
|
271
|
-
if (options === void 0) { options = {}; }
|
272
|
-
return _mount('mount', jsx, options);
|
273
|
-
};
|
274
|
-
var lastMountedReactDom;
|
275
|
-
/**
|
276
|
-
* @see `mount`
|
277
|
-
* @param type The type of mount executed
|
278
|
-
* @param rerenderKey If specified, use the provided key rather than generating a new one
|
263
|
+
* Create an `mount` function. Performs all the non-React-version specific
|
264
|
+
* behavior related to mounting. The React-version-specific code
|
265
|
+
* is injected. This helps us to maintain a consistent public API
|
266
|
+
* and handle breaking changes in React's rendering API.
|
267
|
+
*
|
268
|
+
* This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
|
269
|
+
* or people writing adapters for third-party, custom adapters.
|
279
270
|
*/
|
280
|
-
var
|
271
|
+
var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOptions) {
|
281
272
|
if (options === void 0) { options = {}; }
|
273
|
+
if (!internalMountOptions) {
|
274
|
+
throw Error('internalMountOptions must be provided with `render` and `reactDom` parameters');
|
275
|
+
}
|
276
|
+
mountCleanup = internalMountOptions.cleanup;
|
282
277
|
// Get the display name property via the component constructor
|
283
278
|
// @ts-ignore FIXME
|
284
279
|
var componentName = getDisplayName(jsx.type, options.alias);
|
@@ -291,8 +286,7 @@ var _mount = function (type, jsx, options, rerenderKey) {
|
|
291
286
|
.then(injectStyles(options))
|
292
287
|
.then(function () {
|
293
288
|
var _a, _b, _c;
|
294
|
-
var reactDomToUse =
|
295
|
-
lastMountedReactDom = reactDomToUse;
|
289
|
+
var reactDomToUse = internalMountOptions.reactDom;
|
296
290
|
var el = getContainerEl();
|
297
291
|
if (!el) {
|
298
292
|
throw new Error([
|
@@ -309,7 +303,7 @@ var _mount = function (type, jsx, options, rerenderKey) {
|
|
309
303
|
// since we always surround the component with a fragment
|
310
304
|
// let's get back the original component
|
311
305
|
var userComponent = reactComponent.props.children;
|
312
|
-
|
306
|
+
internalMountOptions.render(reactComponent, el, reactDomToUse);
|
313
307
|
if (options.log !== false) {
|
314
308
|
Cypress.log({
|
315
309
|
name: type,
|
@@ -334,8 +328,8 @@ var _mount = function (type, jsx, options, rerenderKey) {
|
|
334
328
|
.then(function () {
|
335
329
|
return cy.wrap({
|
336
330
|
component: userComponent,
|
337
|
-
rerender: function (newComponent) { return
|
338
|
-
unmount:
|
331
|
+
rerender: function (newComponent) { return makeMountFn('rerender', newComponent, options, key, internalMountOptions); },
|
332
|
+
unmount: internalMountOptions.unmount,
|
339
333
|
}, { log: false });
|
340
334
|
})
|
341
335
|
// by waiting, we delaying test execution for the next tick of event loop
|
@@ -346,88 +340,636 @@ var _mount = function (type, jsx, options, rerenderKey) {
|
|
346
340
|
});
|
347
341
|
};
|
348
342
|
/**
|
349
|
-
*
|
350
|
-
*
|
351
|
-
*
|
352
|
-
*
|
353
|
-
*
|
354
|
-
```
|
355
|
-
import { mount, unmount } from '@cypress/react'
|
356
|
-
it('works', () => {
|
357
|
-
mount(...)
|
358
|
-
// interact with the component using Cypress commands
|
359
|
-
// whenever you want to unmount
|
360
|
-
unmount()
|
361
|
-
})
|
362
|
-
```
|
343
|
+
* Create an `unmount` function. Performs all the non-React-version specific
|
344
|
+
* behavior related to unmounting.
|
345
|
+
*
|
346
|
+
* This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
|
347
|
+
* or people writing adapters for third-party, custom adapters.
|
363
348
|
*/
|
364
|
-
|
365
|
-
var unmount = function (options) {
|
366
|
-
if (options === void 0) { options = { log: true }; }
|
367
|
-
return _unmount(options);
|
368
|
-
};
|
369
|
-
var _unmount = function (options) {
|
349
|
+
var makeUnmountFn = function (options) {
|
370
350
|
return cy.then(function () {
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
});
|
388
|
-
}
|
389
|
-
}
|
390
|
-
});
|
351
|
+
var _a;
|
352
|
+
var wasUnmounted = mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
|
353
|
+
if (wasUnmounted && options.log) {
|
354
|
+
Cypress.log({
|
355
|
+
name: 'unmount',
|
356
|
+
type: 'parent',
|
357
|
+
message: [(_a = options.boundComponentMessage) !== null && _a !== void 0 ? _a : 'Unmounted component'],
|
358
|
+
consoleProps: function () {
|
359
|
+
return {
|
360
|
+
description: 'Unmounts React component',
|
361
|
+
parent: getContainerEl().parentNode,
|
362
|
+
home: 'https://github.com/cypress-io/cypress',
|
363
|
+
};
|
364
|
+
},
|
365
|
+
});
|
366
|
+
}
|
391
367
|
});
|
392
368
|
};
|
393
369
|
// Cleanup before each run
|
394
370
|
// NOTE: we cannot use unmount here because
|
395
371
|
// we are not in the context of a test
|
396
372
|
var preMountCleanup = function () {
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
}
|
373
|
+
mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
|
374
|
+
};
|
375
|
+
var _mount = function (jsx, options) {
|
376
|
+
if (options === void 0) { options = {}; }
|
377
|
+
return makeMountFn('mount', jsx, options);
|
401
378
|
};
|
402
|
-
/**
|
403
|
-
* Creates new instance of `mount` function with default options
|
404
|
-
* @function createMount
|
405
|
-
* @param {MountOptions} [defaultOptions] - defaultOptions for returned `mount` function
|
406
|
-
* @returns new instance of `mount` with assigned options
|
407
|
-
* @example
|
408
|
-
* ```
|
409
|
-
* import Hello from './hello.jsx'
|
410
|
-
* import { createMount } from '@cypress/react'
|
411
|
-
*
|
412
|
-
* const mount = createMount({ strict: true, cssFile: 'path/to/any/css/file.css' })
|
413
|
-
*
|
414
|
-
* it('works', () => {
|
415
|
-
* mount(<Hello />)
|
416
|
-
* // use Cypress commands
|
417
|
-
* cy.get('button').should('have.css', 'color', 'rgb(124, 12, 109)')
|
418
|
-
* })
|
419
|
-
```
|
420
|
-
**/
|
421
379
|
var createMount = function (defaultOptions) {
|
422
380
|
return function (element, options) {
|
423
|
-
return
|
381
|
+
return _mount(element, __assign(__assign({}, defaultOptions), options));
|
424
382
|
};
|
425
383
|
};
|
384
|
+
// Side effects from "import { mount } from '@cypress/<my-framework>'" are annoying, we should avoid doing this
|
385
|
+
// by creating an explicit function/import that the user can register in their 'component.js' support file,
|
386
|
+
// such as:
|
387
|
+
// import 'cypress/<my-framework>/support'
|
388
|
+
// or
|
389
|
+
// import { registerCT } from 'cypress/<my-framework>'
|
390
|
+
// registerCT()
|
391
|
+
// Note: This would be a breaking change
|
426
392
|
// it is required to unmount component in beforeEach hook in order to provide a clean state inside test
|
427
393
|
// because `mount` can be called after some preparation that can side effect unmount
|
428
394
|
// @see npm/react/cypress/component/advanced/set-timeout-example/loading-indicator-spec.js
|
429
395
|
setupHooks(preMountCleanup);
|
430
396
|
|
397
|
+
const debug = (
|
398
|
+
typeof process === 'object' &&
|
399
|
+
process.env &&
|
400
|
+
process.env.NODE_DEBUG &&
|
401
|
+
/\bsemver\b/i.test(process.env.NODE_DEBUG)
|
402
|
+
) ? (...args) => console.error('SEMVER', ...args)
|
403
|
+
: () => {};
|
404
|
+
|
405
|
+
var debug_1 = debug;
|
406
|
+
|
407
|
+
// Note: this is the semver.org version of the spec that it implements
|
408
|
+
// Not necessarily the package version of this code.
|
409
|
+
const SEMVER_SPEC_VERSION = '2.0.0';
|
410
|
+
|
411
|
+
const MAX_LENGTH$1 = 256;
|
412
|
+
const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER ||
|
413
|
+
/* istanbul ignore next */ 9007199254740991;
|
414
|
+
|
415
|
+
// Max safe segment length for coercion.
|
416
|
+
const MAX_SAFE_COMPONENT_LENGTH = 16;
|
417
|
+
|
418
|
+
var constants = {
|
419
|
+
SEMVER_SPEC_VERSION,
|
420
|
+
MAX_LENGTH: MAX_LENGTH$1,
|
421
|
+
MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
|
422
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
423
|
+
};
|
424
|
+
|
425
|
+
function createCommonjsModule(fn) {
|
426
|
+
var module = { exports: {} };
|
427
|
+
return fn(module, module.exports), module.exports;
|
428
|
+
}
|
429
|
+
|
430
|
+
var re_1 = createCommonjsModule(function (module, exports) {
|
431
|
+
const { MAX_SAFE_COMPONENT_LENGTH } = constants;
|
432
|
+
|
433
|
+
exports = module.exports = {};
|
434
|
+
|
435
|
+
// The actual regexps go on exports.re
|
436
|
+
const re = exports.re = [];
|
437
|
+
const src = exports.src = [];
|
438
|
+
const t = exports.t = {};
|
439
|
+
let R = 0;
|
440
|
+
|
441
|
+
const createToken = (name, value, isGlobal) => {
|
442
|
+
const index = R++;
|
443
|
+
debug_1(name, index, value);
|
444
|
+
t[name] = index;
|
445
|
+
src[index] = value;
|
446
|
+
re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
|
447
|
+
};
|
448
|
+
|
449
|
+
// The following Regular Expressions can be used for tokenizing,
|
450
|
+
// validating, and parsing SemVer version strings.
|
451
|
+
|
452
|
+
// ## Numeric Identifier
|
453
|
+
// A single `0`, or a non-zero digit followed by zero or more digits.
|
454
|
+
|
455
|
+
createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
|
456
|
+
createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+');
|
457
|
+
|
458
|
+
// ## Non-numeric Identifier
|
459
|
+
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
460
|
+
// more letters, digits, or hyphens.
|
461
|
+
|
462
|
+
createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*');
|
463
|
+
|
464
|
+
// ## Main Version
|
465
|
+
// Three dot-separated numeric identifiers.
|
466
|
+
|
467
|
+
createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
|
468
|
+
`(${src[t.NUMERICIDENTIFIER]})\\.` +
|
469
|
+
`(${src[t.NUMERICIDENTIFIER]})`);
|
470
|
+
|
471
|
+
createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
472
|
+
`(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
473
|
+
`(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
474
|
+
|
475
|
+
// ## Pre-release Version Identifier
|
476
|
+
// A numeric identifier, or a non-numeric identifier.
|
477
|
+
|
478
|
+
createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
|
479
|
+
}|${src[t.NONNUMERICIDENTIFIER]})`);
|
480
|
+
|
481
|
+
createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
|
482
|
+
}|${src[t.NONNUMERICIDENTIFIER]})`);
|
483
|
+
|
484
|
+
// ## Pre-release Version
|
485
|
+
// Hyphen, followed by one or more dot-separated pre-release version
|
486
|
+
// identifiers.
|
487
|
+
|
488
|
+
createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
|
489
|
+
}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
490
|
+
|
491
|
+
createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
|
492
|
+
}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
493
|
+
|
494
|
+
// ## Build Metadata Identifier
|
495
|
+
// Any combination of digits, letters, or hyphens.
|
496
|
+
|
497
|
+
createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+');
|
498
|
+
|
499
|
+
// ## Build Metadata
|
500
|
+
// Plus sign, followed by one or more period-separated build metadata
|
501
|
+
// identifiers.
|
502
|
+
|
503
|
+
createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
|
504
|
+
}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
505
|
+
|
506
|
+
// ## Full Version String
|
507
|
+
// A main version, followed optionally by a pre-release version and
|
508
|
+
// build metadata.
|
509
|
+
|
510
|
+
// Note that the only major, minor, patch, and pre-release sections of
|
511
|
+
// the version string are capturing groups. The build metadata is not a
|
512
|
+
// capturing group, because it should not ever be used in version
|
513
|
+
// comparison.
|
514
|
+
|
515
|
+
createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
|
516
|
+
}${src[t.PRERELEASE]}?${
|
517
|
+
src[t.BUILD]}?`);
|
518
|
+
|
519
|
+
createToken('FULL', `^${src[t.FULLPLAIN]}$`);
|
520
|
+
|
521
|
+
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
522
|
+
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
523
|
+
// common in the npm registry.
|
524
|
+
createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
|
525
|
+
}${src[t.PRERELEASELOOSE]}?${
|
526
|
+
src[t.BUILD]}?`);
|
527
|
+
|
528
|
+
createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
|
529
|
+
|
530
|
+
createToken('GTLT', '((?:<|>)?=?)');
|
531
|
+
|
532
|
+
// Something like "2.*" or "1.2.x".
|
533
|
+
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
534
|
+
// Only the first item is strictly required.
|
535
|
+
createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
536
|
+
createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
537
|
+
|
538
|
+
createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
|
539
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
|
540
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
|
541
|
+
`(?:${src[t.PRERELEASE]})?${
|
542
|
+
src[t.BUILD]}?` +
|
543
|
+
`)?)?`);
|
544
|
+
|
545
|
+
createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
546
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
547
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
548
|
+
`(?:${src[t.PRERELEASELOOSE]})?${
|
549
|
+
src[t.BUILD]}?` +
|
550
|
+
`)?)?`);
|
551
|
+
|
552
|
+
createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
553
|
+
createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
554
|
+
|
555
|
+
// Coercion.
|
556
|
+
// Extract anything that could conceivably be a part of a valid semver
|
557
|
+
createToken('COERCE', `${'(^|[^\\d])' +
|
558
|
+
'(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
|
559
|
+
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
|
560
|
+
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
|
561
|
+
`(?:$|[^\\d])`);
|
562
|
+
createToken('COERCERTL', src[t.COERCE], true);
|
563
|
+
|
564
|
+
// Tilde ranges.
|
565
|
+
// Meaning is "reasonably at or greater than"
|
566
|
+
createToken('LONETILDE', '(?:~>?)');
|
567
|
+
|
568
|
+
createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
569
|
+
exports.tildeTrimReplace = '$1~';
|
570
|
+
|
571
|
+
createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
572
|
+
createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
573
|
+
|
574
|
+
// Caret ranges.
|
575
|
+
// Meaning is "at least and backwards compatible with"
|
576
|
+
createToken('LONECARET', '(?:\\^)');
|
577
|
+
|
578
|
+
createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
579
|
+
exports.caretTrimReplace = '$1^';
|
580
|
+
|
581
|
+
createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
582
|
+
createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
583
|
+
|
584
|
+
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
585
|
+
createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
586
|
+
createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
587
|
+
|
588
|
+
// An expression to strip any whitespace between the gtlt and the thing
|
589
|
+
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
590
|
+
createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
|
591
|
+
}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
592
|
+
exports.comparatorTrimReplace = '$1$2$3';
|
593
|
+
|
594
|
+
// Something like `1.2.3 - 1.2.4`
|
595
|
+
// Note that these all use the loose form, because they'll be
|
596
|
+
// checked against either the strict or loose comparator form
|
597
|
+
// later.
|
598
|
+
createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
|
599
|
+
`\\s+-\\s+` +
|
600
|
+
`(${src[t.XRANGEPLAIN]})` +
|
601
|
+
`\\s*$`);
|
602
|
+
|
603
|
+
createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
|
604
|
+
`\\s+-\\s+` +
|
605
|
+
`(${src[t.XRANGEPLAINLOOSE]})` +
|
606
|
+
`\\s*$`);
|
607
|
+
|
608
|
+
// Star ranges basically just allow anything at all.
|
609
|
+
createToken('STAR', '(<|>)?=?\\s*\\*');
|
610
|
+
// >=0.0.0 is like a star
|
611
|
+
createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
|
612
|
+
createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
|
613
|
+
});
|
614
|
+
|
615
|
+
// parse out just the options we care about so we always get a consistent
|
616
|
+
// obj with keys in a consistent order.
|
617
|
+
const opts = ['includePrerelease', 'loose', 'rtl'];
|
618
|
+
const parseOptions = options =>
|
619
|
+
!options ? {}
|
620
|
+
: typeof options !== 'object' ? { loose: true }
|
621
|
+
: opts.filter(k => options[k]).reduce((o, k) => {
|
622
|
+
o[k] = true;
|
623
|
+
return o
|
624
|
+
}, {});
|
625
|
+
var parseOptions_1 = parseOptions;
|
626
|
+
|
627
|
+
const numeric = /^[0-9]+$/;
|
628
|
+
const compareIdentifiers$1 = (a, b) => {
|
629
|
+
const anum = numeric.test(a);
|
630
|
+
const bnum = numeric.test(b);
|
631
|
+
|
632
|
+
if (anum && bnum) {
|
633
|
+
a = +a;
|
634
|
+
b = +b;
|
635
|
+
}
|
636
|
+
|
637
|
+
return a === b ? 0
|
638
|
+
: (anum && !bnum) ? -1
|
639
|
+
: (bnum && !anum) ? 1
|
640
|
+
: a < b ? -1
|
641
|
+
: 1
|
642
|
+
};
|
643
|
+
|
644
|
+
const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
|
645
|
+
|
646
|
+
var identifiers = {
|
647
|
+
compareIdentifiers: compareIdentifiers$1,
|
648
|
+
rcompareIdentifiers,
|
649
|
+
};
|
650
|
+
|
651
|
+
const { MAX_LENGTH, MAX_SAFE_INTEGER } = constants;
|
652
|
+
const { re, t } = re_1;
|
653
|
+
|
654
|
+
|
655
|
+
const { compareIdentifiers } = identifiers;
|
656
|
+
class SemVer {
|
657
|
+
constructor (version, options) {
|
658
|
+
options = parseOptions_1(options);
|
659
|
+
|
660
|
+
if (version instanceof SemVer) {
|
661
|
+
if (version.loose === !!options.loose &&
|
662
|
+
version.includePrerelease === !!options.includePrerelease) {
|
663
|
+
return version
|
664
|
+
} else {
|
665
|
+
version = version.version;
|
666
|
+
}
|
667
|
+
} else if (typeof version !== 'string') {
|
668
|
+
throw new TypeError(`Invalid Version: ${version}`)
|
669
|
+
}
|
670
|
+
|
671
|
+
if (version.length > MAX_LENGTH) {
|
672
|
+
throw new TypeError(
|
673
|
+
`version is longer than ${MAX_LENGTH} characters`
|
674
|
+
)
|
675
|
+
}
|
676
|
+
|
677
|
+
debug_1('SemVer', version, options);
|
678
|
+
this.options = options;
|
679
|
+
this.loose = !!options.loose;
|
680
|
+
// this isn't actually relevant for versions, but keep it so that we
|
681
|
+
// don't run into trouble passing this.options around.
|
682
|
+
this.includePrerelease = !!options.includePrerelease;
|
683
|
+
|
684
|
+
const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
|
685
|
+
|
686
|
+
if (!m) {
|
687
|
+
throw new TypeError(`Invalid Version: ${version}`)
|
688
|
+
}
|
689
|
+
|
690
|
+
this.raw = version;
|
691
|
+
|
692
|
+
// these are actually numbers
|
693
|
+
this.major = +m[1];
|
694
|
+
this.minor = +m[2];
|
695
|
+
this.patch = +m[3];
|
696
|
+
|
697
|
+
if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
|
698
|
+
throw new TypeError('Invalid major version')
|
699
|
+
}
|
700
|
+
|
701
|
+
if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
|
702
|
+
throw new TypeError('Invalid minor version')
|
703
|
+
}
|
704
|
+
|
705
|
+
if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
|
706
|
+
throw new TypeError('Invalid patch version')
|
707
|
+
}
|
708
|
+
|
709
|
+
// numberify any prerelease numeric ids
|
710
|
+
if (!m[4]) {
|
711
|
+
this.prerelease = [];
|
712
|
+
} else {
|
713
|
+
this.prerelease = m[4].split('.').map((id) => {
|
714
|
+
if (/^[0-9]+$/.test(id)) {
|
715
|
+
const num = +id;
|
716
|
+
if (num >= 0 && num < MAX_SAFE_INTEGER) {
|
717
|
+
return num
|
718
|
+
}
|
719
|
+
}
|
720
|
+
return id
|
721
|
+
});
|
722
|
+
}
|
723
|
+
|
724
|
+
this.build = m[5] ? m[5].split('.') : [];
|
725
|
+
this.format();
|
726
|
+
}
|
727
|
+
|
728
|
+
format () {
|
729
|
+
this.version = `${this.major}.${this.minor}.${this.patch}`;
|
730
|
+
if (this.prerelease.length) {
|
731
|
+
this.version += `-${this.prerelease.join('.')}`;
|
732
|
+
}
|
733
|
+
return this.version
|
734
|
+
}
|
735
|
+
|
736
|
+
toString () {
|
737
|
+
return this.version
|
738
|
+
}
|
739
|
+
|
740
|
+
compare (other) {
|
741
|
+
debug_1('SemVer.compare', this.version, this.options, other);
|
742
|
+
if (!(other instanceof SemVer)) {
|
743
|
+
if (typeof other === 'string' && other === this.version) {
|
744
|
+
return 0
|
745
|
+
}
|
746
|
+
other = new SemVer(other, this.options);
|
747
|
+
}
|
748
|
+
|
749
|
+
if (other.version === this.version) {
|
750
|
+
return 0
|
751
|
+
}
|
752
|
+
|
753
|
+
return this.compareMain(other) || this.comparePre(other)
|
754
|
+
}
|
755
|
+
|
756
|
+
compareMain (other) {
|
757
|
+
if (!(other instanceof SemVer)) {
|
758
|
+
other = new SemVer(other, this.options);
|
759
|
+
}
|
760
|
+
|
761
|
+
return (
|
762
|
+
compareIdentifiers(this.major, other.major) ||
|
763
|
+
compareIdentifiers(this.minor, other.minor) ||
|
764
|
+
compareIdentifiers(this.patch, other.patch)
|
765
|
+
)
|
766
|
+
}
|
767
|
+
|
768
|
+
comparePre (other) {
|
769
|
+
if (!(other instanceof SemVer)) {
|
770
|
+
other = new SemVer(other, this.options);
|
771
|
+
}
|
772
|
+
|
773
|
+
// NOT having a prerelease is > having one
|
774
|
+
if (this.prerelease.length && !other.prerelease.length) {
|
775
|
+
return -1
|
776
|
+
} else if (!this.prerelease.length && other.prerelease.length) {
|
777
|
+
return 1
|
778
|
+
} else if (!this.prerelease.length && !other.prerelease.length) {
|
779
|
+
return 0
|
780
|
+
}
|
781
|
+
|
782
|
+
let i = 0;
|
783
|
+
do {
|
784
|
+
const a = this.prerelease[i];
|
785
|
+
const b = other.prerelease[i];
|
786
|
+
debug_1('prerelease compare', i, a, b);
|
787
|
+
if (a === undefined && b === undefined) {
|
788
|
+
return 0
|
789
|
+
} else if (b === undefined) {
|
790
|
+
return 1
|
791
|
+
} else if (a === undefined) {
|
792
|
+
return -1
|
793
|
+
} else if (a === b) {
|
794
|
+
continue
|
795
|
+
} else {
|
796
|
+
return compareIdentifiers(a, b)
|
797
|
+
}
|
798
|
+
} while (++i)
|
799
|
+
}
|
800
|
+
|
801
|
+
compareBuild (other) {
|
802
|
+
if (!(other instanceof SemVer)) {
|
803
|
+
other = new SemVer(other, this.options);
|
804
|
+
}
|
805
|
+
|
806
|
+
let i = 0;
|
807
|
+
do {
|
808
|
+
const a = this.build[i];
|
809
|
+
const b = other.build[i];
|
810
|
+
debug_1('prerelease compare', i, a, b);
|
811
|
+
if (a === undefined && b === undefined) {
|
812
|
+
return 0
|
813
|
+
} else if (b === undefined) {
|
814
|
+
return 1
|
815
|
+
} else if (a === undefined) {
|
816
|
+
return -1
|
817
|
+
} else if (a === b) {
|
818
|
+
continue
|
819
|
+
} else {
|
820
|
+
return compareIdentifiers(a, b)
|
821
|
+
}
|
822
|
+
} while (++i)
|
823
|
+
}
|
824
|
+
|
825
|
+
// preminor will bump the version up to the next minor release, and immediately
|
826
|
+
// down to pre-release. premajor and prepatch work the same way.
|
827
|
+
inc (release, identifier) {
|
828
|
+
switch (release) {
|
829
|
+
case 'premajor':
|
830
|
+
this.prerelease.length = 0;
|
831
|
+
this.patch = 0;
|
832
|
+
this.minor = 0;
|
833
|
+
this.major++;
|
834
|
+
this.inc('pre', identifier);
|
835
|
+
break
|
836
|
+
case 'preminor':
|
837
|
+
this.prerelease.length = 0;
|
838
|
+
this.patch = 0;
|
839
|
+
this.minor++;
|
840
|
+
this.inc('pre', identifier);
|
841
|
+
break
|
842
|
+
case 'prepatch':
|
843
|
+
// If this is already a prerelease, it will bump to the next version
|
844
|
+
// drop any prereleases that might already exist, since they are not
|
845
|
+
// relevant at this point.
|
846
|
+
this.prerelease.length = 0;
|
847
|
+
this.inc('patch', identifier);
|
848
|
+
this.inc('pre', identifier);
|
849
|
+
break
|
850
|
+
// If the input is a non-prerelease version, this acts the same as
|
851
|
+
// prepatch.
|
852
|
+
case 'prerelease':
|
853
|
+
if (this.prerelease.length === 0) {
|
854
|
+
this.inc('patch', identifier);
|
855
|
+
}
|
856
|
+
this.inc('pre', identifier);
|
857
|
+
break
|
858
|
+
|
859
|
+
case 'major':
|
860
|
+
// If this is a pre-major version, bump up to the same major version.
|
861
|
+
// Otherwise increment major.
|
862
|
+
// 1.0.0-5 bumps to 1.0.0
|
863
|
+
// 1.1.0 bumps to 2.0.0
|
864
|
+
if (
|
865
|
+
this.minor !== 0 ||
|
866
|
+
this.patch !== 0 ||
|
867
|
+
this.prerelease.length === 0
|
868
|
+
) {
|
869
|
+
this.major++;
|
870
|
+
}
|
871
|
+
this.minor = 0;
|
872
|
+
this.patch = 0;
|
873
|
+
this.prerelease = [];
|
874
|
+
break
|
875
|
+
case 'minor':
|
876
|
+
// If this is a pre-minor version, bump up to the same minor version.
|
877
|
+
// Otherwise increment minor.
|
878
|
+
// 1.2.0-5 bumps to 1.2.0
|
879
|
+
// 1.2.1 bumps to 1.3.0
|
880
|
+
if (this.patch !== 0 || this.prerelease.length === 0) {
|
881
|
+
this.minor++;
|
882
|
+
}
|
883
|
+
this.patch = 0;
|
884
|
+
this.prerelease = [];
|
885
|
+
break
|
886
|
+
case 'patch':
|
887
|
+
// If this is not a pre-release version, it will increment the patch.
|
888
|
+
// If it is a pre-release it will bump up to the same patch version.
|
889
|
+
// 1.2.0-5 patches to 1.2.0
|
890
|
+
// 1.2.0 patches to 1.2.1
|
891
|
+
if (this.prerelease.length === 0) {
|
892
|
+
this.patch++;
|
893
|
+
}
|
894
|
+
this.prerelease = [];
|
895
|
+
break
|
896
|
+
// This probably shouldn't be used publicly.
|
897
|
+
// 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
|
898
|
+
case 'pre':
|
899
|
+
if (this.prerelease.length === 0) {
|
900
|
+
this.prerelease = [0];
|
901
|
+
} else {
|
902
|
+
let i = this.prerelease.length;
|
903
|
+
while (--i >= 0) {
|
904
|
+
if (typeof this.prerelease[i] === 'number') {
|
905
|
+
this.prerelease[i]++;
|
906
|
+
i = -2;
|
907
|
+
}
|
908
|
+
}
|
909
|
+
if (i === -1) {
|
910
|
+
// didn't increment anything
|
911
|
+
this.prerelease.push(0);
|
912
|
+
}
|
913
|
+
}
|
914
|
+
if (identifier) {
|
915
|
+
// 1.2.0-beta.1 bumps to 1.2.0-beta.2,
|
916
|
+
// 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
|
917
|
+
if (compareIdentifiers(this.prerelease[0], identifier) === 0) {
|
918
|
+
if (isNaN(this.prerelease[1])) {
|
919
|
+
this.prerelease = [identifier, 0];
|
920
|
+
}
|
921
|
+
} else {
|
922
|
+
this.prerelease = [identifier, 0];
|
923
|
+
}
|
924
|
+
}
|
925
|
+
break
|
926
|
+
|
927
|
+
default:
|
928
|
+
throw new Error(`invalid increment argument: ${release}`)
|
929
|
+
}
|
930
|
+
this.format();
|
931
|
+
this.raw = this.version;
|
932
|
+
return this
|
933
|
+
}
|
934
|
+
}
|
935
|
+
|
936
|
+
var semver = SemVer;
|
937
|
+
|
938
|
+
const major = (a, loose) => new semver(a, loose).major;
|
939
|
+
var major_1 = major;
|
940
|
+
|
941
|
+
var lastReactDom;
|
942
|
+
var cleanup = function () {
|
943
|
+
if (lastReactDom) {
|
944
|
+
var root = getContainerEl();
|
945
|
+
lastReactDom.unmountComponentAtNode(root);
|
946
|
+
return true;
|
947
|
+
}
|
948
|
+
return false;
|
949
|
+
};
|
950
|
+
function mount(jsx, options, rerenderKey) {
|
951
|
+
if (options === void 0) { options = {}; }
|
952
|
+
if (major_1(React__default["default"].version) === 18) {
|
953
|
+
var 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.';
|
954
|
+
console.error(message);
|
955
|
+
Cypress.log({ name: 'warning', message: message });
|
956
|
+
}
|
957
|
+
var internalOptions = {
|
958
|
+
reactDom: ReactDOM__default["default"],
|
959
|
+
render: function (reactComponent, el, reactDomToUse) {
|
960
|
+
lastReactDom = (reactDomToUse || ReactDOM__default["default"]);
|
961
|
+
return lastReactDom.render(reactComponent, el);
|
962
|
+
},
|
963
|
+
unmount: unmount,
|
964
|
+
cleanup: cleanup,
|
965
|
+
};
|
966
|
+
return makeMountFn('mount', jsx, __assign({ ReactDom: ReactDOM__default["default"] }, options), rerenderKey, internalOptions);
|
967
|
+
}
|
968
|
+
function unmount(options) {
|
969
|
+
if (options === void 0) { options = { log: true }; }
|
970
|
+
return makeUnmountFn(options);
|
971
|
+
}
|
972
|
+
|
431
973
|
// mounting hooks inside a test component mostly copied from
|
432
974
|
// https://github.com/testing-library/react-hooks-testing-library/blob/master/src/pure.js
|
433
975
|
function resultContainer() {
|
@@ -490,6 +1032,8 @@ var mountHook = function (hookFn) {
|
|
490
1032
|
};
|
491
1033
|
|
492
1034
|
exports.createMount = createMount;
|
1035
|
+
exports.makeMountFn = makeMountFn;
|
1036
|
+
exports.makeUnmountFn = makeUnmountFn;
|
493
1037
|
exports.mount = mount;
|
494
1038
|
exports.mountHook = mountHook;
|
495
1039
|
exports.unmount = unmount;
|