cypress 10.5.0 → 10.8.0
Sign up to get free protection for your applications and to get access to all the features.
- package/angular/CHANGELOG.md +43 -0
- package/angular/README.md +43 -112
- package/angular/dist/index.js +8 -6
- package/angular/dist/mount.d.ts +1 -0
- package/angular/package.json +6 -8
- package/lib/tasks/download.js +4 -3
- package/mount-utils/CHANGELOG.md +7 -0
- package/mount-utils/package.json +5 -1
- package/package.json +11 -5
- package/react/CHANGELOG.md +14 -0
- package/react/dist/createMount.d.ts +5 -2
- package/react/dist/cypress-react.cjs.js +80 -115
- package/react/dist/cypress-react.esm-bundler.js +66 -101
- package/react/dist/mount.d.ts +1 -0
- package/react/dist/mountHook.d.ts +1 -0
- package/react/dist/types.d.ts +1 -0
- package/react/package.json +3 -7
- package/react18/CHANGELOG.md +14 -0
- package/react18/dist/cypress-react.cjs.js +63 -89
- package/react18/dist/cypress-react.esm-bundler.js +49 -75
- package/react18/dist/index.d.ts +1 -0
- package/react18/package.json +2 -2
- package/svelte/CHANGELOG.md +6 -0
- package/svelte/README.md +83 -0
- package/svelte/dist/cypress-svelte.cjs.js +213 -0
- package/svelte/dist/cypress-svelte.esm-bundler.js +209 -0
- package/svelte/dist/index.d.ts +1 -0
- package/svelte/dist/mount.d.ts +30 -0
- package/svelte/package.json +43 -0
- package/types/cypress-type-helpers.d.ts +3 -1
- package/types/cypress.d.ts +61 -12
- package/vue/CHANGELOG.md +7 -0
- package/vue/dist/cypress-vue.cjs.js +30 -38
- package/vue/dist/cypress-vue.esm-bundler.js +30 -38
- package/vue/dist/index.d.ts +1 -0
- package/vue/package.json +3 -8
- package/vue2/CHANGELOG.md +7 -0
- package/vue2/dist/cypress-vue2.cjs.js +53 -84
- package/vue2/dist/cypress-vue2.esm-bundler.js +53 -84
- package/vue2/dist/index.d.ts +1 -0
- package/vue2/package.json +2 -5
- package/vue2/dist/cypress-vue2.browser.js +0 -20197
@@ -15,67 +15,40 @@ var ReactDOM = require('react-dom');
|
|
15
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
16
16
|
|
17
17
|
function _interopNamespace(e) {
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
});
|
28
|
-
}
|
18
|
+
if (e && e.__esModule) return e;
|
19
|
+
var n = Object.create(null);
|
20
|
+
if (e) {
|
21
|
+
Object.keys(e).forEach(function (k) {
|
22
|
+
if (k !== 'default') {
|
23
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
24
|
+
Object.defineProperty(n, k, d.get ? d : {
|
25
|
+
enumerable: true,
|
26
|
+
get: function () { return e[k]; }
|
29
27
|
});
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
}
|
29
|
+
});
|
30
|
+
}
|
31
|
+
n["default"] = e;
|
32
|
+
return Object.freeze(n);
|
33
33
|
}
|
34
34
|
|
35
35
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
36
36
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
37
37
|
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
38
38
|
|
39
|
-
|
40
|
-
Copyright (c) Microsoft Corporation.
|
41
|
-
|
42
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
43
|
-
purpose with or without fee is hereby granted.
|
44
|
-
|
45
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
46
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
47
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
48
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
49
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
50
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
51
|
-
PERFORMANCE OF THIS SOFTWARE.
|
52
|
-
***************************************************************************** */
|
53
|
-
|
54
|
-
var __assign = function() {
|
55
|
-
__assign = Object.assign || function __assign(t) {
|
56
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
57
|
-
s = arguments[i];
|
58
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
59
|
-
}
|
60
|
-
return t;
|
61
|
-
};
|
62
|
-
return __assign.apply(this, arguments);
|
63
|
-
};
|
64
|
-
|
65
|
-
var cachedDisplayNames = new WeakMap();
|
39
|
+
const cachedDisplayNames = new WeakMap();
|
66
40
|
/**
|
67
41
|
* Gets the display name of the component when possible.
|
68
42
|
* @param type {JSX} The type object returned from creating the react element.
|
69
43
|
* @param fallbackName {string} The alias, or fallback name to use when the name cannot be derived.
|
70
44
|
* @link https://github.com/facebook/react-devtools/blob/master/backend/getDisplayName.js
|
71
45
|
*/
|
72
|
-
function getDisplayName(type, fallbackName) {
|
73
|
-
|
74
|
-
var nameFromCache = cachedDisplayNames.get(type);
|
46
|
+
function getDisplayName(type, fallbackName = 'Unknown') {
|
47
|
+
const nameFromCache = cachedDisplayNames.get(type);
|
75
48
|
if (nameFromCache != null) {
|
76
49
|
return nameFromCache;
|
77
50
|
}
|
78
|
-
|
51
|
+
let displayName = null;
|
79
52
|
// The displayName property is not guaranteed to be a string.
|
80
53
|
// It's only safe to use for our purposes if it's a string.
|
81
54
|
// github.com/facebook/react-devtools/issues/803
|
@@ -87,13 +60,13 @@ function getDisplayName(type, fallbackName) {
|
|
87
60
|
}
|
88
61
|
// Facebook-specific hack to turn "Image [from Image.react]" into just "Image".
|
89
62
|
// We need displayName with module name for error reports but it clutters the DevTools.
|
90
|
-
|
63
|
+
const match = displayName.match(/^(.*) \[from (.*)\]$/);
|
91
64
|
if (match) {
|
92
|
-
|
93
|
-
|
65
|
+
const componentName = match[1];
|
66
|
+
const moduleName = match[2];
|
94
67
|
if (componentName && moduleName) {
|
95
68
|
if (moduleName === componentName ||
|
96
|
-
moduleName.startsWith(componentName
|
69
|
+
moduleName.startsWith(`${componentName}.`)) {
|
97
70
|
displayName = componentName;
|
98
71
|
}
|
99
72
|
}
|
@@ -252,13 +225,13 @@ function setupHooks(optionalCallback) {
|
|
252
225
|
/**
|
253
226
|
* Inject custom style text or CSS file or 3rd party style resources
|
254
227
|
*/
|
255
|
-
|
256
|
-
return
|
257
|
-
|
228
|
+
const injectStyles = (options) => {
|
229
|
+
return () => {
|
230
|
+
const el = getContainerEl();
|
258
231
|
return injectStylesBeforeElement(options, document, el);
|
259
232
|
};
|
260
233
|
};
|
261
|
-
|
234
|
+
let mountCleanup;
|
262
235
|
/**
|
263
236
|
* Create an `mount` function. Performs all the non-React-version specific
|
264
237
|
* behavior related to mounting. The React-version-specific code
|
@@ -268,41 +241,40 @@ var mountCleanup;
|
|
268
241
|
* This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
|
269
242
|
* or people writing adapters for third-party, custom adapters.
|
270
243
|
*/
|
271
|
-
|
272
|
-
if (options === void 0) { options = {}; }
|
244
|
+
const makeMountFn = (type, jsx, options = {}, rerenderKey, internalMountOptions) => {
|
273
245
|
if (!internalMountOptions) {
|
274
246
|
throw Error('internalMountOptions must be provided with `render` and `reactDom` parameters');
|
275
247
|
}
|
276
248
|
mountCleanup = internalMountOptions.cleanup;
|
277
249
|
// Get the display name property via the component constructor
|
278
250
|
// @ts-ignore FIXME
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
? jsxComponentName
|
251
|
+
const componentName = getDisplayName(jsx.type, options.alias);
|
252
|
+
const displayName = options.alias || componentName;
|
253
|
+
const jsxComponentName = `<${componentName} ... />`;
|
254
|
+
const message = options.alias
|
255
|
+
? `${jsxComponentName} as "${options.alias}"`
|
284
256
|
: jsxComponentName;
|
285
257
|
return cy
|
286
258
|
.then(injectStyles(options))
|
287
|
-
.then(
|
259
|
+
.then(() => {
|
288
260
|
var _a, _b, _c;
|
289
|
-
|
290
|
-
|
261
|
+
const reactDomToUse = internalMountOptions.reactDom;
|
262
|
+
const el = getContainerEl();
|
291
263
|
if (!el) {
|
292
264
|
throw new Error([
|
293
|
-
|
265
|
+
`[@cypress/react] 🔥 Hmm, cannot find root element to mount the component. Searched for ${ROOT_SELECTOR}`,
|
294
266
|
].join(' '));
|
295
267
|
}
|
296
|
-
|
268
|
+
const key = rerenderKey !== null && rerenderKey !== void 0 ? rerenderKey :
|
297
269
|
// @ts-ignore provide unique key to the the wrapped component to make sure we are rerendering between tests
|
298
270
|
(((_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();
|
299
|
-
|
300
|
-
key
|
271
|
+
const props = {
|
272
|
+
key,
|
301
273
|
};
|
302
|
-
|
274
|
+
const reactComponent = React__namespace.createElement(options.strict ? React__namespace.StrictMode : React__namespace.Fragment, props, jsx);
|
303
275
|
// since we always surround the component with a fragment
|
304
276
|
// let's get back the original component
|
305
|
-
|
277
|
+
const userComponent = reactComponent.props.children;
|
306
278
|
internalMountOptions.render(reactComponent, el, reactDomToUse);
|
307
279
|
if (options.log !== false) {
|
308
280
|
Cypress.log({
|
@@ -311,7 +283,7 @@ var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOption
|
|
311
283
|
message: [message],
|
312
284
|
// @ts-ignore
|
313
285
|
$el: el.children.item(0),
|
314
|
-
consoleProps:
|
286
|
+
consoleProps: () => {
|
315
287
|
return {
|
316
288
|
// @ts-ignore protect the use of jsx functional components use ReactNode
|
317
289
|
props: jsx.props,
|
@@ -325,10 +297,10 @@ var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOption
|
|
325
297
|
// Separate alias and returned value. Alias returns the component only, and the thenable returns the additional functions
|
326
298
|
cy.wrap(userComponent, { log: false })
|
327
299
|
.as(displayName)
|
328
|
-
.then(
|
300
|
+
.then(() => {
|
329
301
|
return cy.wrap({
|
330
302
|
component: userComponent,
|
331
|
-
rerender:
|
303
|
+
rerender: (newComponent) => makeMountFn('rerender', newComponent, options, key, internalMountOptions),
|
332
304
|
unmount: internalMountOptions.unmount,
|
333
305
|
}, { log: false });
|
334
306
|
})
|
@@ -346,16 +318,16 @@ var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOption
|
|
346
318
|
* This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
|
347
319
|
* or people writing adapters for third-party, custom adapters.
|
348
320
|
*/
|
349
|
-
|
350
|
-
return cy.then(
|
321
|
+
const makeUnmountFn = (options) => {
|
322
|
+
return cy.then(() => {
|
351
323
|
var _a;
|
352
|
-
|
324
|
+
const wasUnmounted = mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
|
353
325
|
if (wasUnmounted && options.log) {
|
354
326
|
Cypress.log({
|
355
327
|
name: 'unmount',
|
356
328
|
type: 'parent',
|
357
329
|
message: [(_a = options.boundComponentMessage) !== null && _a !== void 0 ? _a : 'Unmounted component'],
|
358
|
-
consoleProps:
|
330
|
+
consoleProps: () => {
|
359
331
|
return {
|
360
332
|
description: 'Unmounts React component',
|
361
333
|
parent: getContainerEl().parentNode,
|
@@ -369,16 +341,13 @@ var makeUnmountFn = function (options) {
|
|
369
341
|
// Cleanup before each run
|
370
342
|
// NOTE: we cannot use unmount here because
|
371
343
|
// we are not in the context of a test
|
372
|
-
|
344
|
+
const preMountCleanup = () => {
|
373
345
|
mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
|
374
346
|
};
|
375
|
-
|
376
|
-
|
377
|
-
return
|
378
|
-
};
|
379
|
-
var createMount = function (defaultOptions) {
|
380
|
-
return function (element, options) {
|
381
|
-
return _mount(element, __assign(__assign({}, defaultOptions), options));
|
347
|
+
const _mount = (jsx, options = {}) => makeMountFn('mount', jsx, options);
|
348
|
+
const createMount = (defaultOptions) => {
|
349
|
+
return (element, options) => {
|
350
|
+
return _mount(element, Object.assign(Object.assign({}, defaultOptions), options));
|
382
351
|
};
|
383
352
|
};
|
384
353
|
// Side effects from "import { mount } from '@cypress/<my-framework>'" are annoying, we should avoid doing this
|
@@ -938,45 +907,43 @@ var semver = SemVer;
|
|
938
907
|
const major = (a, loose) => new semver(a, loose).major;
|
939
908
|
var major_1 = major;
|
940
909
|
|
941
|
-
|
942
|
-
|
910
|
+
let lastReactDom;
|
911
|
+
const cleanup = () => {
|
943
912
|
if (lastReactDom) {
|
944
|
-
|
913
|
+
const root = getContainerEl();
|
945
914
|
lastReactDom.unmountComponentAtNode(root);
|
946
915
|
return true;
|
947
916
|
}
|
948
917
|
return false;
|
949
918
|
};
|
950
|
-
function mount(jsx, options, rerenderKey) {
|
951
|
-
if (options === void 0) { options = {}; }
|
919
|
+
function mount(jsx, options = {}, rerenderKey) {
|
952
920
|
if (major_1(React__default["default"].version) === 18) {
|
953
|
-
|
921
|
+
const message = '[cypress/react]: You are using `cypress/react`, which is designed for React <= 17. Consider changing to `cypress/react18`, which is designed for React 18.';
|
954
922
|
console.error(message);
|
955
|
-
Cypress.log({ name: 'warning', message
|
923
|
+
Cypress.log({ name: 'warning', message });
|
956
924
|
}
|
957
|
-
|
925
|
+
const internalOptions = {
|
958
926
|
reactDom: ReactDOM__default["default"],
|
959
|
-
render:
|
927
|
+
render: (reactComponent, el, reactDomToUse) => {
|
960
928
|
lastReactDom = (reactDomToUse || ReactDOM__default["default"]);
|
961
929
|
return lastReactDom.render(reactComponent, el);
|
962
930
|
},
|
963
|
-
unmount
|
964
|
-
cleanup
|
931
|
+
unmount,
|
932
|
+
cleanup,
|
965
933
|
};
|
966
|
-
return makeMountFn('mount', jsx,
|
934
|
+
return makeMountFn('mount', jsx, Object.assign({ ReactDom: ReactDOM__default["default"] }, options), rerenderKey, internalOptions);
|
967
935
|
}
|
968
|
-
function unmount(options) {
|
969
|
-
if (options === void 0) { options = { log: true }; }
|
936
|
+
function unmount(options = { log: true }) {
|
970
937
|
return makeUnmountFn(options);
|
971
938
|
}
|
972
939
|
|
973
940
|
// mounting hooks inside a test component mostly copied from
|
974
941
|
// https://github.com/testing-library/react-hooks-testing-library/blob/master/src/pure.js
|
975
942
|
function resultContainer() {
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
943
|
+
let value = null;
|
944
|
+
let error = null;
|
945
|
+
const resolvers = [];
|
946
|
+
const result = {
|
980
947
|
get current() {
|
981
948
|
if (error) {
|
982
949
|
throw error;
|
@@ -987,23 +954,21 @@ function resultContainer() {
|
|
987
954
|
return error;
|
988
955
|
},
|
989
956
|
};
|
990
|
-
|
991
|
-
if (err === void 0) { err = null; }
|
957
|
+
const updateResult = (val, err = null) => {
|
992
958
|
value = val;
|
993
959
|
error = err;
|
994
|
-
resolvers.splice(0, resolvers.length).forEach(
|
960
|
+
resolvers.splice(0, resolvers.length).forEach((resolve) => resolve());
|
995
961
|
};
|
996
962
|
return {
|
997
|
-
result
|
998
|
-
addResolver:
|
963
|
+
result,
|
964
|
+
addResolver: (resolver) => {
|
999
965
|
resolvers.push(resolver);
|
1000
966
|
},
|
1001
|
-
setValue:
|
1002
|
-
setError:
|
967
|
+
setValue: (val) => updateResult(val),
|
968
|
+
setError: (err) => updateResult(undefined, err),
|
1003
969
|
};
|
1004
970
|
}
|
1005
|
-
function TestHook(
|
1006
|
-
var callback = _a.callback, onError = _a.onError, children = _a.children;
|
971
|
+
function TestHook({ callback, onError, children }) {
|
1007
972
|
try {
|
1008
973
|
children(callback());
|
1009
974
|
}
|
@@ -1021,14 +986,14 @@ function TestHook(_a) {
|
|
1021
986
|
* Mounts a React hook function in a test component for testing.
|
1022
987
|
*
|
1023
988
|
*/
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
989
|
+
const mountHook = (hookFn) => {
|
990
|
+
const { result, setValue, setError } = resultContainer();
|
991
|
+
const componentTest = React__namespace.createElement(TestHook, {
|
1027
992
|
callback: hookFn,
|
1028
993
|
onError: setError,
|
1029
994
|
children: setValue,
|
1030
995
|
});
|
1031
|
-
return mount(componentTest).then(
|
996
|
+
return mount(componentTest).then(() => result);
|
1032
997
|
};
|
1033
998
|
|
1034
999
|
exports.createMount = createMount;
|