cypress 10.3.1 → 10.6.0
Sign up to get free protection for your applications and to get access to all the features.
- 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 +6 -0
- package/lib/tasks/download.js +4 -3
- package/mount-utils/CHANGELOG.md +7 -1
- package/mount-utils/README.md +7 -0
- package/package.json +16 -5
- package/react/CHANGELOG.md +20 -19
- package/react/README.md +28 -323
- package/react/dist/createMount.d.ts +28 -0
- package/react/dist/cypress-react.cjs.js +627 -98
- package/react/dist/cypress-react.esm-bundler.js +624 -99
- 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 +13 -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 +28 -2
- 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 -608
- package/vue/dist/@vue/test-utils/baseWrapper.d.ts +3 -1
- package/vue/dist/@vue/test-utils/config.d.ts +4 -2
- package/vue/dist/@vue/test-utils/emit.d.ts +1 -0
- package/vue/dist/@vue/test-utils/index.d.ts +2 -1
- package/vue/dist/@vue/test-utils/interfaces/wrapperLike.d.ts +2 -2
- package/vue/dist/@vue/test-utils/mount.d.ts +2 -0
- package/vue/dist/@vue/test-utils/stubs.d.ts +2 -6
- package/vue/dist/@vue/test-utils/types.d.ts +1 -1
- package/vue/dist/@vue/test-utils/vueWrapper.d.ts +2 -1
- package/vue/dist/cypress-vue.cjs.js +5379 -5090
- package/vue/dist/cypress-vue.esm-bundler.js +5380 -5091
- package/vue/dist/index.d.ts +1 -0
- package/vue/package.json +2 -3
- package/vue2/CHANGELOG.md +7 -0
- package/vue2/README.md +11 -627
- package/vue2/dist/cypress-vue2.browser.js +251 -260
- package/vue2/dist/cypress-vue2.cjs.js +250 -259
- package/vue2/dist/cypress-vue2.esm-bundler.js +248 -257
- package/react/dist/cypress-react.browser.js +0 -512
@@ -0,0 +1,605 @@
|
|
1
|
+
|
2
|
+
/**
|
3
|
+
* @cypress/react18 v0.0.0-development
|
4
|
+
* (c) 2022 Cypress.io
|
5
|
+
* Released under the MIT License
|
6
|
+
*/
|
7
|
+
|
8
|
+
import ReactDOM from 'react-dom/client';
|
9
|
+
import * as React from 'react';
|
10
|
+
import 'react-dom';
|
11
|
+
|
12
|
+
/******************************************************************************
|
13
|
+
Copyright (c) Microsoft Corporation.
|
14
|
+
|
15
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
16
|
+
purpose with or without fee is hereby granted.
|
17
|
+
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
19
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
20
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
21
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
22
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
23
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
24
|
+
PERFORMANCE OF THIS SOFTWARE.
|
25
|
+
***************************************************************************** */
|
26
|
+
|
27
|
+
var __assign = function() {
|
28
|
+
__assign = Object.assign || function __assign(t) {
|
29
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
30
|
+
s = arguments[i];
|
31
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
32
|
+
}
|
33
|
+
return t;
|
34
|
+
};
|
35
|
+
return __assign.apply(this, arguments);
|
36
|
+
};
|
37
|
+
|
38
|
+
var cachedDisplayNames = new WeakMap();
|
39
|
+
/**
|
40
|
+
* Gets the display name of the component when possible.
|
41
|
+
* @param type {JSX} The type object returned from creating the react element.
|
42
|
+
* @param fallbackName {string} The alias, or fallback name to use when the name cannot be derived.
|
43
|
+
* @link https://github.com/facebook/react-devtools/blob/master/backend/getDisplayName.js
|
44
|
+
*/
|
45
|
+
function getDisplayName(type, fallbackName) {
|
46
|
+
if (fallbackName === void 0) { fallbackName = 'Unknown'; }
|
47
|
+
var nameFromCache = cachedDisplayNames.get(type);
|
48
|
+
if (nameFromCache != null) {
|
49
|
+
return nameFromCache;
|
50
|
+
}
|
51
|
+
var displayName = null;
|
52
|
+
// The displayName property is not guaranteed to be a string.
|
53
|
+
// It's only safe to use for our purposes if it's a string.
|
54
|
+
// github.com/facebook/react-devtools/issues/803
|
55
|
+
if (typeof type.displayName === 'string') {
|
56
|
+
displayName = type.displayName;
|
57
|
+
}
|
58
|
+
if (!displayName) {
|
59
|
+
displayName = type.name || fallbackName;
|
60
|
+
}
|
61
|
+
// Facebook-specific hack to turn "Image [from Image.react]" into just "Image".
|
62
|
+
// We need displayName with module name for error reports but it clutters the DevTools.
|
63
|
+
var match = displayName.match(/^(.*) \[from (.*)\]$/);
|
64
|
+
if (match) {
|
65
|
+
var componentName = match[1];
|
66
|
+
var moduleName = match[2];
|
67
|
+
if (componentName && moduleName) {
|
68
|
+
if (moduleName === componentName ||
|
69
|
+
moduleName.startsWith(componentName + ".")) {
|
70
|
+
displayName = componentName;
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
try {
|
75
|
+
cachedDisplayNames.set(type, displayName);
|
76
|
+
}
|
77
|
+
catch (e) {
|
78
|
+
// do nothing
|
79
|
+
}
|
80
|
+
return displayName;
|
81
|
+
}
|
82
|
+
|
83
|
+
const ROOT_SELECTOR = '[data-cy-root]';
|
84
|
+
const getContainerEl = () => {
|
85
|
+
const el = document.querySelector(ROOT_SELECTOR);
|
86
|
+
if (el) {
|
87
|
+
return el;
|
88
|
+
}
|
89
|
+
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.`);
|
90
|
+
};
|
91
|
+
/**
|
92
|
+
* Remove any style or extra link elements from the iframe placeholder
|
93
|
+
* left from any previous test
|
94
|
+
*
|
95
|
+
*/
|
96
|
+
function cleanupStyles() {
|
97
|
+
const styles = document.body.querySelectorAll('[data-cy=injected-style-tag]');
|
98
|
+
styles.forEach((styleElement) => {
|
99
|
+
if (styleElement.parentElement) {
|
100
|
+
styleElement.parentElement.removeChild(styleElement);
|
101
|
+
}
|
102
|
+
});
|
103
|
+
const links = document.body.querySelectorAll('[data-cy=injected-stylesheet]');
|
104
|
+
links.forEach((link) => {
|
105
|
+
if (link.parentElement) {
|
106
|
+
link.parentElement.removeChild(link);
|
107
|
+
}
|
108
|
+
});
|
109
|
+
}
|
110
|
+
/**
|
111
|
+
* Insert links to external style resources.
|
112
|
+
*/
|
113
|
+
function insertStylesheets(stylesheets, document, el) {
|
114
|
+
stylesheets.forEach((href) => {
|
115
|
+
const link = document.createElement('link');
|
116
|
+
link.type = 'text/css';
|
117
|
+
link.rel = 'stylesheet';
|
118
|
+
link.href = href;
|
119
|
+
link.dataset.cy = 'injected-stylesheet';
|
120
|
+
document.body.insertBefore(link, el);
|
121
|
+
});
|
122
|
+
}
|
123
|
+
/**
|
124
|
+
* Inserts a single stylesheet element
|
125
|
+
*/
|
126
|
+
function insertStyles(styles, document, el) {
|
127
|
+
styles.forEach((style) => {
|
128
|
+
const styleElement = document.createElement('style');
|
129
|
+
styleElement.dataset.cy = 'injected-style-tag';
|
130
|
+
styleElement.appendChild(document.createTextNode(style));
|
131
|
+
document.body.insertBefore(styleElement, el);
|
132
|
+
});
|
133
|
+
}
|
134
|
+
function insertSingleCssFile(cssFilename, document, el, log) {
|
135
|
+
return cy.readFile(cssFilename, { log }).then((css) => {
|
136
|
+
const style = document.createElement('style');
|
137
|
+
style.appendChild(document.createTextNode(css));
|
138
|
+
document.body.insertBefore(style, el);
|
139
|
+
});
|
140
|
+
}
|
141
|
+
/**
|
142
|
+
* Reads the given CSS file from local file system
|
143
|
+
* and adds the loaded style text as an element.
|
144
|
+
*/
|
145
|
+
function insertLocalCssFiles(cssFilenames, document, el, log) {
|
146
|
+
return Cypress.Promise.mapSeries(cssFilenames, (cssFilename) => {
|
147
|
+
return insertSingleCssFile(cssFilename, document, el, log);
|
148
|
+
});
|
149
|
+
}
|
150
|
+
/**
|
151
|
+
* Injects custom style text or CSS file or 3rd party style resources
|
152
|
+
* into the given document.
|
153
|
+
*/
|
154
|
+
const injectStylesBeforeElement = (options, document, el) => {
|
155
|
+
if (!el)
|
156
|
+
return;
|
157
|
+
// first insert all stylesheets as Link elements
|
158
|
+
let stylesheets = [];
|
159
|
+
if (typeof options.stylesheet === 'string') {
|
160
|
+
stylesheets.push(options.stylesheet);
|
161
|
+
}
|
162
|
+
else if (Array.isArray(options.stylesheet)) {
|
163
|
+
stylesheets = stylesheets.concat(options.stylesheet);
|
164
|
+
}
|
165
|
+
if (typeof options.stylesheets === 'string') {
|
166
|
+
options.stylesheets = [options.stylesheets];
|
167
|
+
}
|
168
|
+
if (options.stylesheets) {
|
169
|
+
stylesheets = stylesheets.concat(options.stylesheets);
|
170
|
+
}
|
171
|
+
insertStylesheets(stylesheets, document, el);
|
172
|
+
// insert any styles as <style>...</style> elements
|
173
|
+
let styles = [];
|
174
|
+
if (typeof options.style === 'string') {
|
175
|
+
styles.push(options.style);
|
176
|
+
}
|
177
|
+
else if (Array.isArray(options.style)) {
|
178
|
+
styles = styles.concat(options.style);
|
179
|
+
}
|
180
|
+
if (typeof options.styles === 'string') {
|
181
|
+
styles.push(options.styles);
|
182
|
+
}
|
183
|
+
else if (Array.isArray(options.styles)) {
|
184
|
+
styles = styles.concat(options.styles);
|
185
|
+
}
|
186
|
+
insertStyles(styles, document, el);
|
187
|
+
// now load any css files by path and add their content
|
188
|
+
// as <style>...</style> elements
|
189
|
+
let cssFiles = [];
|
190
|
+
if (typeof options.cssFile === 'string') {
|
191
|
+
cssFiles.push(options.cssFile);
|
192
|
+
}
|
193
|
+
else if (Array.isArray(options.cssFile)) {
|
194
|
+
cssFiles = cssFiles.concat(options.cssFile);
|
195
|
+
}
|
196
|
+
if (typeof options.cssFiles === 'string') {
|
197
|
+
cssFiles.push(options.cssFiles);
|
198
|
+
}
|
199
|
+
else if (Array.isArray(options.cssFiles)) {
|
200
|
+
cssFiles = cssFiles.concat(options.cssFiles);
|
201
|
+
}
|
202
|
+
return insertLocalCssFiles(cssFiles, document, el, options.log);
|
203
|
+
};
|
204
|
+
function setupHooks(optionalCallback) {
|
205
|
+
// Consumed by the framework "mount" libs. A user might register their own mount in the scaffolded 'commands.js'
|
206
|
+
// file that is imported by e2e and component support files by default. We don't want CT side effects to run when e2e
|
207
|
+
// testing so we early return.
|
208
|
+
// System test to verify CT side effects do not pollute e2e: system-tests/test/e2e_with_mount_import_spec.ts
|
209
|
+
if (Cypress.testingType !== 'component') {
|
210
|
+
return;
|
211
|
+
}
|
212
|
+
// When running component specs, we cannot allow "cy.visit"
|
213
|
+
// because it will wipe out our preparation work, and does not make much sense
|
214
|
+
// thus we overwrite "cy.visit" to throw an error
|
215
|
+
Cypress.Commands.overwrite('visit', () => {
|
216
|
+
throw new Error('cy.visit from a component spec is not allowed');
|
217
|
+
});
|
218
|
+
// @ts-ignore
|
219
|
+
Cypress.on('test:before:run', () => {
|
220
|
+
optionalCallback === null || optionalCallback === void 0 ? void 0 : optionalCallback();
|
221
|
+
cleanupStyles();
|
222
|
+
});
|
223
|
+
}
|
224
|
+
|
225
|
+
/**
|
226
|
+
* Inject custom style text or CSS file or 3rd party style resources
|
227
|
+
*/
|
228
|
+
var injectStyles = function (options) {
|
229
|
+
return function () {
|
230
|
+
var el = getContainerEl();
|
231
|
+
return injectStylesBeforeElement(options, document, el);
|
232
|
+
};
|
233
|
+
};
|
234
|
+
var mountCleanup;
|
235
|
+
/**
|
236
|
+
* Create an `mount` function. Performs all the non-React-version specific
|
237
|
+
* behavior related to mounting. The React-version-specific code
|
238
|
+
* is injected. This helps us to maintain a consistent public API
|
239
|
+
* and handle breaking changes in React's rendering API.
|
240
|
+
*
|
241
|
+
* This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
|
242
|
+
* or people writing adapters for third-party, custom adapters.
|
243
|
+
*/
|
244
|
+
var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOptions) {
|
245
|
+
if (options === void 0) { options = {}; }
|
246
|
+
if (!internalMountOptions) {
|
247
|
+
throw Error('internalMountOptions must be provided with `render` and `reactDom` parameters');
|
248
|
+
}
|
249
|
+
mountCleanup = internalMountOptions.cleanup;
|
250
|
+
// Get the display name property via the component constructor
|
251
|
+
// @ts-ignore FIXME
|
252
|
+
var componentName = getDisplayName(jsx.type, options.alias);
|
253
|
+
var displayName = options.alias || componentName;
|
254
|
+
var jsxComponentName = "<" + componentName + " ... />";
|
255
|
+
var message = options.alias
|
256
|
+
? jsxComponentName + " as \"" + options.alias + "\""
|
257
|
+
: jsxComponentName;
|
258
|
+
return cy
|
259
|
+
.then(injectStyles(options))
|
260
|
+
.then(function () {
|
261
|
+
var _a, _b, _c;
|
262
|
+
var reactDomToUse = internalMountOptions.reactDom;
|
263
|
+
var el = getContainerEl();
|
264
|
+
if (!el) {
|
265
|
+
throw new Error([
|
266
|
+
"[@cypress/react] \uD83D\uDD25 Hmm, cannot find root element to mount the component. Searched for " + ROOT_SELECTOR,
|
267
|
+
].join(' '));
|
268
|
+
}
|
269
|
+
var key = rerenderKey !== null && rerenderKey !== void 0 ? rerenderKey :
|
270
|
+
// @ts-ignore provide unique key to the the wrapped component to make sure we are rerendering between tests
|
271
|
+
(((_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();
|
272
|
+
var props = {
|
273
|
+
key: key,
|
274
|
+
};
|
275
|
+
var reactComponent = React.createElement(options.strict ? React.StrictMode : React.Fragment, props, jsx);
|
276
|
+
// since we always surround the component with a fragment
|
277
|
+
// let's get back the original component
|
278
|
+
var userComponent = reactComponent.props.children;
|
279
|
+
internalMountOptions.render(reactComponent, el, reactDomToUse);
|
280
|
+
if (options.log !== false) {
|
281
|
+
Cypress.log({
|
282
|
+
name: type,
|
283
|
+
type: 'parent',
|
284
|
+
message: [message],
|
285
|
+
// @ts-ignore
|
286
|
+
$el: el.children.item(0),
|
287
|
+
consoleProps: function () {
|
288
|
+
return {
|
289
|
+
// @ts-ignore protect the use of jsx functional components use ReactNode
|
290
|
+
props: jsx.props,
|
291
|
+
description: type === 'mount' ? 'Mounts React component' : 'Rerenders mounted React component',
|
292
|
+
home: 'https://github.com/cypress-io/cypress',
|
293
|
+
};
|
294
|
+
},
|
295
|
+
}).snapshot('mounted').end();
|
296
|
+
}
|
297
|
+
return (
|
298
|
+
// Separate alias and returned value. Alias returns the component only, and the thenable returns the additional functions
|
299
|
+
cy.wrap(userComponent, { log: false })
|
300
|
+
.as(displayName)
|
301
|
+
.then(function () {
|
302
|
+
return cy.wrap({
|
303
|
+
component: userComponent,
|
304
|
+
rerender: function (newComponent) { return makeMountFn('rerender', newComponent, options, key, internalMountOptions); },
|
305
|
+
unmount: internalMountOptions.unmount,
|
306
|
+
}, { log: false });
|
307
|
+
})
|
308
|
+
// by waiting, we delaying test execution for the next tick of event loop
|
309
|
+
// and letting hooks and component lifecycle methods to execute mount
|
310
|
+
// https://github.com/bahmutov/cypress-react-unit-test/issues/200
|
311
|
+
.wait(0, { log: false }));
|
312
|
+
// Bluebird types are terrible. I don't think the return type can be carried without this cast
|
313
|
+
});
|
314
|
+
};
|
315
|
+
/**
|
316
|
+
* Create an `unmount` function. Performs all the non-React-version specific
|
317
|
+
* behavior related to unmounting.
|
318
|
+
*
|
319
|
+
* This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
|
320
|
+
* or people writing adapters for third-party, custom adapters.
|
321
|
+
*/
|
322
|
+
var makeUnmountFn = function (options) {
|
323
|
+
return cy.then(function () {
|
324
|
+
var _a;
|
325
|
+
var wasUnmounted = mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
|
326
|
+
if (wasUnmounted && options.log) {
|
327
|
+
Cypress.log({
|
328
|
+
name: 'unmount',
|
329
|
+
type: 'parent',
|
330
|
+
message: [(_a = options.boundComponentMessage) !== null && _a !== void 0 ? _a : 'Unmounted component'],
|
331
|
+
consoleProps: function () {
|
332
|
+
return {
|
333
|
+
description: 'Unmounts React component',
|
334
|
+
parent: getContainerEl().parentNode,
|
335
|
+
home: 'https://github.com/cypress-io/cypress',
|
336
|
+
};
|
337
|
+
},
|
338
|
+
});
|
339
|
+
}
|
340
|
+
});
|
341
|
+
};
|
342
|
+
// Cleanup before each run
|
343
|
+
// NOTE: we cannot use unmount here because
|
344
|
+
// we are not in the context of a test
|
345
|
+
var preMountCleanup = function () {
|
346
|
+
mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
|
347
|
+
};
|
348
|
+
// Side effects from "import { mount } from '@cypress/<my-framework>'" are annoying, we should avoid doing this
|
349
|
+
// by creating an explicit function/import that the user can register in their 'component.js' support file,
|
350
|
+
// such as:
|
351
|
+
// import 'cypress/<my-framework>/support'
|
352
|
+
// or
|
353
|
+
// import { registerCT } from 'cypress/<my-framework>'
|
354
|
+
// registerCT()
|
355
|
+
// Note: This would be a breaking change
|
356
|
+
// it is required to unmount component in beforeEach hook in order to provide a clean state inside test
|
357
|
+
// because `mount` can be called after some preparation that can side effect unmount
|
358
|
+
// @see npm/react/cypress/component/advanced/set-timeout-example/loading-indicator-spec.js
|
359
|
+
setupHooks(preMountCleanup);
|
360
|
+
|
361
|
+
const debug = (
|
362
|
+
typeof process === 'object' &&
|
363
|
+
process.env &&
|
364
|
+
process.env.NODE_DEBUG &&
|
365
|
+
/\bsemver\b/i.test(process.env.NODE_DEBUG)
|
366
|
+
) ? (...args) => console.error('SEMVER', ...args)
|
367
|
+
: () => {};
|
368
|
+
|
369
|
+
var debug_1 = debug;
|
370
|
+
|
371
|
+
// Note: this is the semver.org version of the spec that it implements
|
372
|
+
// Not necessarily the package version of this code.
|
373
|
+
const SEMVER_SPEC_VERSION = '2.0.0';
|
374
|
+
|
375
|
+
const MAX_LENGTH$1 = 256;
|
376
|
+
const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER ||
|
377
|
+
/* istanbul ignore next */ 9007199254740991;
|
378
|
+
|
379
|
+
// Max safe segment length for coercion.
|
380
|
+
const MAX_SAFE_COMPONENT_LENGTH = 16;
|
381
|
+
|
382
|
+
var constants = {
|
383
|
+
SEMVER_SPEC_VERSION,
|
384
|
+
MAX_LENGTH: MAX_LENGTH$1,
|
385
|
+
MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
|
386
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
387
|
+
};
|
388
|
+
|
389
|
+
function createCommonjsModule(fn) {
|
390
|
+
var module = { exports: {} };
|
391
|
+
return fn(module, module.exports), module.exports;
|
392
|
+
}
|
393
|
+
|
394
|
+
createCommonjsModule(function (module, exports) {
|
395
|
+
const { MAX_SAFE_COMPONENT_LENGTH } = constants;
|
396
|
+
|
397
|
+
exports = module.exports = {};
|
398
|
+
|
399
|
+
// The actual regexps go on exports.re
|
400
|
+
const re = exports.re = [];
|
401
|
+
const src = exports.src = [];
|
402
|
+
const t = exports.t = {};
|
403
|
+
let R = 0;
|
404
|
+
|
405
|
+
const createToken = (name, value, isGlobal) => {
|
406
|
+
const index = R++;
|
407
|
+
debug_1(name, index, value);
|
408
|
+
t[name] = index;
|
409
|
+
src[index] = value;
|
410
|
+
re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
|
411
|
+
};
|
412
|
+
|
413
|
+
// The following Regular Expressions can be used for tokenizing,
|
414
|
+
// validating, and parsing SemVer version strings.
|
415
|
+
|
416
|
+
// ## Numeric Identifier
|
417
|
+
// A single `0`, or a non-zero digit followed by zero or more digits.
|
418
|
+
|
419
|
+
createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
|
420
|
+
createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+');
|
421
|
+
|
422
|
+
// ## Non-numeric Identifier
|
423
|
+
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
424
|
+
// more letters, digits, or hyphens.
|
425
|
+
|
426
|
+
createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*');
|
427
|
+
|
428
|
+
// ## Main Version
|
429
|
+
// Three dot-separated numeric identifiers.
|
430
|
+
|
431
|
+
createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
|
432
|
+
`(${src[t.NUMERICIDENTIFIER]})\\.` +
|
433
|
+
`(${src[t.NUMERICIDENTIFIER]})`);
|
434
|
+
|
435
|
+
createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
436
|
+
`(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
437
|
+
`(${src[t.NUMERICIDENTIFIERLOOSE]})`);
|
438
|
+
|
439
|
+
// ## Pre-release Version Identifier
|
440
|
+
// A numeric identifier, or a non-numeric identifier.
|
441
|
+
|
442
|
+
createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
|
443
|
+
}|${src[t.NONNUMERICIDENTIFIER]})`);
|
444
|
+
|
445
|
+
createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
|
446
|
+
}|${src[t.NONNUMERICIDENTIFIER]})`);
|
447
|
+
|
448
|
+
// ## Pre-release Version
|
449
|
+
// Hyphen, followed by one or more dot-separated pre-release version
|
450
|
+
// identifiers.
|
451
|
+
|
452
|
+
createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
|
453
|
+
}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
|
454
|
+
|
455
|
+
createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
|
456
|
+
}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`);
|
457
|
+
|
458
|
+
// ## Build Metadata Identifier
|
459
|
+
// Any combination of digits, letters, or hyphens.
|
460
|
+
|
461
|
+
createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+');
|
462
|
+
|
463
|
+
// ## Build Metadata
|
464
|
+
// Plus sign, followed by one or more period-separated build metadata
|
465
|
+
// identifiers.
|
466
|
+
|
467
|
+
createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
|
468
|
+
}(?:\\.${src[t.BUILDIDENTIFIER]})*))`);
|
469
|
+
|
470
|
+
// ## Full Version String
|
471
|
+
// A main version, followed optionally by a pre-release version and
|
472
|
+
// build metadata.
|
473
|
+
|
474
|
+
// Note that the only major, minor, patch, and pre-release sections of
|
475
|
+
// the version string are capturing groups. The build metadata is not a
|
476
|
+
// capturing group, because it should not ever be used in version
|
477
|
+
// comparison.
|
478
|
+
|
479
|
+
createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
|
480
|
+
}${src[t.PRERELEASE]}?${
|
481
|
+
src[t.BUILD]}?`);
|
482
|
+
|
483
|
+
createToken('FULL', `^${src[t.FULLPLAIN]}$`);
|
484
|
+
|
485
|
+
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
486
|
+
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
487
|
+
// common in the npm registry.
|
488
|
+
createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
|
489
|
+
}${src[t.PRERELEASELOOSE]}?${
|
490
|
+
src[t.BUILD]}?`);
|
491
|
+
|
492
|
+
createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
|
493
|
+
|
494
|
+
createToken('GTLT', '((?:<|>)?=?)');
|
495
|
+
|
496
|
+
// Something like "2.*" or "1.2.x".
|
497
|
+
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
498
|
+
// Only the first item is strictly required.
|
499
|
+
createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
|
500
|
+
createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
|
501
|
+
|
502
|
+
createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
|
503
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
|
504
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
|
505
|
+
`(?:${src[t.PRERELEASE]})?${
|
506
|
+
src[t.BUILD]}?` +
|
507
|
+
`)?)?`);
|
508
|
+
|
509
|
+
createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
510
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
511
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
512
|
+
`(?:${src[t.PRERELEASELOOSE]})?${
|
513
|
+
src[t.BUILD]}?` +
|
514
|
+
`)?)?`);
|
515
|
+
|
516
|
+
createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
|
517
|
+
createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`);
|
518
|
+
|
519
|
+
// Coercion.
|
520
|
+
// Extract anything that could conceivably be a part of a valid semver
|
521
|
+
createToken('COERCE', `${'(^|[^\\d])' +
|
522
|
+
'(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
|
523
|
+
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
|
524
|
+
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
|
525
|
+
`(?:$|[^\\d])`);
|
526
|
+
createToken('COERCERTL', src[t.COERCE], true);
|
527
|
+
|
528
|
+
// Tilde ranges.
|
529
|
+
// Meaning is "reasonably at or greater than"
|
530
|
+
createToken('LONETILDE', '(?:~>?)');
|
531
|
+
|
532
|
+
createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
|
533
|
+
exports.tildeTrimReplace = '$1~';
|
534
|
+
|
535
|
+
createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
|
536
|
+
createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`);
|
537
|
+
|
538
|
+
// Caret ranges.
|
539
|
+
// Meaning is "at least and backwards compatible with"
|
540
|
+
createToken('LONECARET', '(?:\\^)');
|
541
|
+
|
542
|
+
createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
|
543
|
+
exports.caretTrimReplace = '$1^';
|
544
|
+
|
545
|
+
createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
|
546
|
+
createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`);
|
547
|
+
|
548
|
+
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
549
|
+
createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
|
550
|
+
createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`);
|
551
|
+
|
552
|
+
// An expression to strip any whitespace between the gtlt and the thing
|
553
|
+
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
554
|
+
createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
|
555
|
+
}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
|
556
|
+
exports.comparatorTrimReplace = '$1$2$3';
|
557
|
+
|
558
|
+
// Something like `1.2.3 - 1.2.4`
|
559
|
+
// Note that these all use the loose form, because they'll be
|
560
|
+
// checked against either the strict or loose comparator form
|
561
|
+
// later.
|
562
|
+
createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
|
563
|
+
`\\s+-\\s+` +
|
564
|
+
`(${src[t.XRANGEPLAIN]})` +
|
565
|
+
`\\s*$`);
|
566
|
+
|
567
|
+
createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
|
568
|
+
`\\s+-\\s+` +
|
569
|
+
`(${src[t.XRANGEPLAINLOOSE]})` +
|
570
|
+
`\\s*$`);
|
571
|
+
|
572
|
+
// Star ranges basically just allow anything at all.
|
573
|
+
createToken('STAR', '(<|>)?=?\\s*\\*');
|
574
|
+
// >=0.0.0 is like a star
|
575
|
+
createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
|
576
|
+
createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
|
577
|
+
});
|
578
|
+
|
579
|
+
var root;
|
580
|
+
var cleanup = function () {
|
581
|
+
if (root) {
|
582
|
+
root.unmount();
|
583
|
+
return true;
|
584
|
+
}
|
585
|
+
return false;
|
586
|
+
};
|
587
|
+
function mount(jsx, options, rerenderKey) {
|
588
|
+
if (options === void 0) { options = {}; }
|
589
|
+
var internalOptions = {
|
590
|
+
reactDom: ReactDOM,
|
591
|
+
render: function (reactComponent, el) {
|
592
|
+
root = ReactDOM.createRoot(el);
|
593
|
+
return root.render(reactComponent);
|
594
|
+
},
|
595
|
+
unmount: unmount,
|
596
|
+
cleanup: cleanup,
|
597
|
+
};
|
598
|
+
return makeMountFn('mount', jsx, __assign({ ReactDom: ReactDOM }, options), rerenderKey, internalOptions);
|
599
|
+
}
|
600
|
+
function unmount(options) {
|
601
|
+
if (options === void 0) { options = { log: true }; }
|
602
|
+
return makeUnmountFn(options);
|
603
|
+
}
|
604
|
+
|
605
|
+
export { mount, unmount };
|
@@ -0,0 +1,5 @@
|
|
1
|
+
/// <reference types="cypress" />
|
2
|
+
import React from 'react';
|
3
|
+
import type { MountOptions, UnmountArgs } from '@cypress/react';
|
4
|
+
export declare function mount(jsx: React.ReactNode, options?: MountOptions, rerenderKey?: string): Cypress.Chainable<import("@cypress/react").MountReturn>;
|
5
|
+
export declare function unmount(options?: UnmountArgs): Cypress.Chainable<undefined>;
|
@@ -0,0 +1,59 @@
|
|
1
|
+
{
|
2
|
+
"name": "@cypress/react18",
|
3
|
+
"version": "0.0.0-development",
|
4
|
+
"description": "Test React components using Cypress",
|
5
|
+
"main": "dist/cypress-react.cjs.js",
|
6
|
+
"scripts": {
|
7
|
+
"build": "rimraf dist && rollup -c rollup.config.js",
|
8
|
+
"postbuild": "node ../../scripts/sync-exported-npm-with-cli.js",
|
9
|
+
"build-prod": "yarn build",
|
10
|
+
"watch": "yarn build --watch --watch.exclude ./dist/**/*"
|
11
|
+
},
|
12
|
+
"devDependencies": {
|
13
|
+
"@cypress/react": "0.0.0-development",
|
14
|
+
"@rollup/plugin-commonjs": "^17.1.0",
|
15
|
+
"@rollup/plugin-node-resolve": "^11.1.1",
|
16
|
+
"@types/react": "^16",
|
17
|
+
"@types/react-dom": "^16",
|
18
|
+
"cypress": "0.0.0-development",
|
19
|
+
"react": "^16",
|
20
|
+
"react-dom": "^16",
|
21
|
+
"rollup": "^2.38.5",
|
22
|
+
"rollup-plugin-typescript2": "^0.29.0",
|
23
|
+
"typescript": "^4.2.3"
|
24
|
+
},
|
25
|
+
"peerDependencies": {
|
26
|
+
"@types/react": "^18",
|
27
|
+
"@types/react-dom": "^18",
|
28
|
+
"cypress": "*",
|
29
|
+
"react": "^18",
|
30
|
+
"react-dom": "^18"
|
31
|
+
},
|
32
|
+
"files": [
|
33
|
+
"dist"
|
34
|
+
],
|
35
|
+
"types": "dist/index.d.ts",
|
36
|
+
"license": "MIT",
|
37
|
+
"repository": {
|
38
|
+
"type": "git",
|
39
|
+
"url": "https://github.com/cypress-io/cypress.git"
|
40
|
+
},
|
41
|
+
"homepage": "https://github.com/cypress-io/cypress/blob/master/npm/react18/#readme",
|
42
|
+
"bugs": "https://github.com/cypress-io/cypress/issues/new?assignees=&labels=npm%3A%20%40cypress%2Freact18&template=1-bug-report.md&title=",
|
43
|
+
"keywords": [
|
44
|
+
"react",
|
45
|
+
"cypress",
|
46
|
+
"cypress-io",
|
47
|
+
"test",
|
48
|
+
"testing"
|
49
|
+
],
|
50
|
+
"module": "dist/cypress-react.esm-bundler.js",
|
51
|
+
"peerDependenciesMeta": {
|
52
|
+
"@types/react": {
|
53
|
+
"optional": true
|
54
|
+
}
|
55
|
+
},
|
56
|
+
"publishConfig": {
|
57
|
+
"access": "public"
|
58
|
+
}
|
59
|
+
}
|