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