cypress 10.5.0 → 10.8.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.
Files changed (42) hide show
  1. package/angular/CHANGELOG.md +43 -0
  2. package/angular/README.md +43 -112
  3. package/angular/dist/index.js +8 -6
  4. package/angular/dist/mount.d.ts +1 -0
  5. package/angular/package.json +6 -8
  6. package/lib/tasks/download.js +4 -3
  7. package/mount-utils/CHANGELOG.md +7 -0
  8. package/mount-utils/package.json +5 -1
  9. package/package.json +11 -5
  10. package/react/CHANGELOG.md +14 -0
  11. package/react/dist/createMount.d.ts +5 -2
  12. package/react/dist/cypress-react.cjs.js +80 -115
  13. package/react/dist/cypress-react.esm-bundler.js +66 -101
  14. package/react/dist/mount.d.ts +1 -0
  15. package/react/dist/mountHook.d.ts +1 -0
  16. package/react/dist/types.d.ts +1 -0
  17. package/react/package.json +3 -7
  18. package/react18/CHANGELOG.md +14 -0
  19. package/react18/dist/cypress-react.cjs.js +63 -89
  20. package/react18/dist/cypress-react.esm-bundler.js +49 -75
  21. package/react18/dist/index.d.ts +1 -0
  22. package/react18/package.json +2 -2
  23. package/svelte/CHANGELOG.md +6 -0
  24. package/svelte/README.md +83 -0
  25. package/svelte/dist/cypress-svelte.cjs.js +213 -0
  26. package/svelte/dist/cypress-svelte.esm-bundler.js +209 -0
  27. package/svelte/dist/index.d.ts +1 -0
  28. package/svelte/dist/mount.d.ts +30 -0
  29. package/svelte/package.json +43 -0
  30. package/types/cypress-type-helpers.d.ts +3 -1
  31. package/types/cypress.d.ts +61 -12
  32. package/vue/CHANGELOG.md +7 -0
  33. package/vue/dist/cypress-vue.cjs.js +30 -38
  34. package/vue/dist/cypress-vue.esm-bundler.js +30 -38
  35. package/vue/dist/index.d.ts +1 -0
  36. package/vue/package.json +3 -8
  37. package/vue2/CHANGELOG.md +7 -0
  38. package/vue2/dist/cypress-vue2.cjs.js +53 -84
  39. package/vue2/dist/cypress-vue2.esm-bundler.js +53 -84
  40. package/vue2/dist/index.d.ts +1 -0
  41. package/vue2/package.json +2 -5
  42. 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
- 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]; }
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
- n["default"] = e;
32
- return Object.freeze(n);
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
- if (fallbackName === void 0) { fallbackName = 'Unknown'; }
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
- var displayName = null;
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
- var match = displayName.match(/^(.*) \[from (.*)\]$/);
63
+ const match = displayName.match(/^(.*) \[from (.*)\]$/);
91
64
  if (match) {
92
- var componentName = match[1];
93
- var moduleName = match[2];
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
- var injectStyles = function (options) {
256
- return function () {
257
- var el = getContainerEl();
228
+ const injectStyles = (options) => {
229
+ return () => {
230
+ const el = getContainerEl();
258
231
  return injectStylesBeforeElement(options, document, el);
259
232
  };
260
233
  };
261
- var mountCleanup;
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
- var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOptions) {
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
- var componentName = getDisplayName(jsx.type, options.alias);
280
- var displayName = options.alias || componentName;
281
- var jsxComponentName = "<" + componentName + " ... />";
282
- var message = options.alias
283
- ? jsxComponentName + " as \"" + options.alias + "\""
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(function () {
259
+ .then(() => {
288
260
  var _a, _b, _c;
289
- var reactDomToUse = internalMountOptions.reactDom;
290
- var el = getContainerEl();
261
+ const reactDomToUse = internalMountOptions.reactDom;
262
+ const el = getContainerEl();
291
263
  if (!el) {
292
264
  throw new Error([
293
- "[@cypress/react] \uD83D\uDD25 Hmm, cannot find root element to mount the component. Searched for " + ROOT_SELECTOR,
265
+ `[@cypress/react] 🔥 Hmm, cannot find root element to mount the component. Searched for ${ROOT_SELECTOR}`,
294
266
  ].join(' '));
295
267
  }
296
- var key = rerenderKey !== null && rerenderKey !== void 0 ? rerenderKey :
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
- var props = {
300
- key: key,
271
+ const props = {
272
+ key,
301
273
  };
302
- var reactComponent = React__namespace.createElement(options.strict ? React__namespace.StrictMode : React__namespace.Fragment, props, jsx);
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
- var userComponent = reactComponent.props.children;
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: function () {
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(function () {
300
+ .then(() => {
329
301
  return cy.wrap({
330
302
  component: userComponent,
331
- rerender: function (newComponent) { return makeMountFn('rerender', newComponent, options, key, internalMountOptions); },
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
- var makeUnmountFn = function (options) {
350
- return cy.then(function () {
321
+ const makeUnmountFn = (options) => {
322
+ return cy.then(() => {
351
323
  var _a;
352
- var wasUnmounted = mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
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: function () {
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
- var preMountCleanup = function () {
344
+ const preMountCleanup = () => {
373
345
  mountCleanup === null || mountCleanup === void 0 ? void 0 : mountCleanup();
374
346
  };
375
- var _mount = function (jsx, options) {
376
- if (options === void 0) { options = {}; }
377
- return makeMountFn('mount', jsx, options);
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
- var lastReactDom;
942
- var cleanup = function () {
910
+ let lastReactDom;
911
+ const cleanup = () => {
943
912
  if (lastReactDom) {
944
- var root = getContainerEl();
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
- 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.';
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: message });
923
+ Cypress.log({ name: 'warning', message });
956
924
  }
957
- var internalOptions = {
925
+ const internalOptions = {
958
926
  reactDom: ReactDOM__default["default"],
959
- render: function (reactComponent, el, reactDomToUse) {
927
+ render: (reactComponent, el, reactDomToUse) => {
960
928
  lastReactDom = (reactDomToUse || ReactDOM__default["default"]);
961
929
  return lastReactDom.render(reactComponent, el);
962
930
  },
963
- unmount: unmount,
964
- cleanup: cleanup,
931
+ unmount,
932
+ cleanup,
965
933
  };
966
- return makeMountFn('mount', jsx, __assign({ ReactDom: ReactDOM__default["default"] }, options), rerenderKey, internalOptions);
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
- var value = null;
977
- var error = null;
978
- var resolvers = [];
979
- var result = {
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
- var updateResult = function (val, err) {
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(function (resolve) { return resolve(); });
960
+ resolvers.splice(0, resolvers.length).forEach((resolve) => resolve());
995
961
  };
996
962
  return {
997
- result: result,
998
- addResolver: function (resolver) {
963
+ result,
964
+ addResolver: (resolver) => {
999
965
  resolvers.push(resolver);
1000
966
  },
1001
- setValue: function (val) { return updateResult(val); },
1002
- setError: function (err) { return updateResult(undefined, err); },
967
+ setValue: (val) => updateResult(val),
968
+ setError: (err) => updateResult(undefined, err),
1003
969
  };
1004
970
  }
1005
- function TestHook(_a) {
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
- var mountHook = function (hookFn) {
1025
- var _a = resultContainer(), result = _a.result, setValue = _a.setValue, setError = _a.setError;
1026
- var componentTest = React__namespace.createElement(TestHook, {
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(function () { return result; });
996
+ return mount(componentTest).then(() => result);
1032
997
  };
1033
998
 
1034
999
  exports.createMount = createMount;