cypress 13.11.0 → 13.13.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 (62) hide show
  1. package/angular/angular/dist/index.d.ts +1 -2
  2. package/angular/angular/dist/index.js +239 -239
  3. package/angular/angular/package.json +1 -1
  4. package/angular/dist/index.d.ts +1 -2
  5. package/angular/dist/index.js +239 -239
  6. package/angular/package.json +1 -1
  7. package/angular-signals/README.md +11 -0
  8. package/angular-signals/angular-signals/README.md +11 -0
  9. package/angular-signals/angular-signals/dist/index.d.ts +136 -0
  10. package/angular-signals/angular-signals/dist/index.js +1861 -0
  11. package/angular-signals/angular-signals/package.json +74 -0
  12. package/angular-signals/dist/index.d.ts +136 -0
  13. package/angular-signals/dist/index.js +1861 -0
  14. package/angular-signals/package.json +74 -0
  15. package/lib/cli.js +0 -1
  16. package/lib/exec/xvfb.js +0 -1
  17. package/lib/logger.js +0 -3
  18. package/mount-utils/dist/index.d.ts +1 -1
  19. package/mount-utils/mount-utils/dist/index.d.ts +1 -1
  20. package/mount-utils/mount-utils/package.json +1 -1
  21. package/mount-utils/package.json +1 -1
  22. package/package.json +11 -5
  23. package/react/dist/cypress-react.cjs.js +237 -237
  24. package/react/dist/cypress-react.esm-bundler.js +237 -237
  25. package/react/dist/index.d.ts +1 -1
  26. package/react/package.json +3 -3
  27. package/react/react/dist/cypress-react.cjs.js +237 -237
  28. package/react/react/dist/cypress-react.esm-bundler.js +237 -237
  29. package/react/react/dist/index.d.ts +1 -1
  30. package/react/react/package.json +3 -3
  31. package/react18/dist/cypress-react.cjs.js +222 -222
  32. package/react18/dist/cypress-react.esm-bundler.js +222 -222
  33. package/react18/dist/index.d.ts +1 -1
  34. package/react18/package.json +1 -1
  35. package/react18/react18/dist/cypress-react.cjs.js +222 -222
  36. package/react18/react18/dist/cypress-react.esm-bundler.js +222 -222
  37. package/react18/react18/dist/index.d.ts +1 -1
  38. package/react18/react18/package.json +1 -1
  39. package/svelte/dist/cypress-svelte.cjs.js +61 -61
  40. package/svelte/dist/cypress-svelte.esm-bundler.js +61 -61
  41. package/svelte/dist/index.d.ts +2 -2
  42. package/svelte/package.json +1 -1
  43. package/svelte/svelte/dist/cypress-svelte.cjs.js +61 -61
  44. package/svelte/svelte/dist/cypress-svelte.esm-bundler.js +61 -61
  45. package/svelte/svelte/dist/index.d.ts +2 -2
  46. package/svelte/svelte/package.json +1 -1
  47. package/vue/dist/cypress-vue.cjs.js +128 -128
  48. package/vue/dist/cypress-vue.esm-bundler.js +128 -128
  49. package/vue/dist/index.d.ts +5 -5
  50. package/vue/package.json +5 -5
  51. package/vue/vue/dist/cypress-vue.cjs.js +128 -128
  52. package/vue/vue/dist/cypress-vue.esm-bundler.js +128 -128
  53. package/vue/vue/dist/index.d.ts +5 -5
  54. package/vue/vue/package.json +5 -5
  55. package/vue2/dist/cypress-vue2.cjs.js +211 -211
  56. package/vue2/dist/cypress-vue2.esm-bundler.js +211 -211
  57. package/vue2/dist/index.d.ts +11 -11
  58. package/vue2/package.json +1 -1
  59. package/vue2/vue2/dist/cypress-vue2.cjs.js +211 -211
  60. package/vue2/vue2/dist/cypress-vue2.esm-bundler.js +211 -211
  61. package/vue2/vue2/dist/index.d.ts +11 -11
  62. package/vue2/vue2/package.json +1 -1
@@ -44,41 +44,41 @@ const getContainerEl$1 = () => {
44
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
45
  };
46
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;
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
82
  }
83
83
 
84
84
  const ROOT_SELECTOR = '[data-cy-root]';
@@ -130,135 +130,135 @@ function setupHooks(optionalCallback) {
130
130
  });
131
131
  }
132
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
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
262
  setupHooks(preMountCleanup);
263
263
 
264
264
  const debug = (
@@ -532,64 +532,64 @@ createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$');
532
532
  createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$');
533
533
  });
534
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');
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
593
  }
594
594
 
595
595
  exports.getContainerEl = getContainerEl$1;