cypress 10.3.1 → 10.4.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 (41) hide show
  1. package/lib/exec/open.js +6 -0
  2. package/mount-utils/CHANGELOG.md +0 -1
  3. package/mount-utils/README.md +7 -0
  4. package/package.json +10 -5
  5. package/react/CHANGELOG.md +0 -19
  6. package/react/README.md +28 -323
  7. package/react/dist/createMount.d.ts +30 -0
  8. package/react/dist/cypress-react.cjs.js +59 -78
  9. package/react/dist/cypress-react.esm-bundler.js +51 -74
  10. package/react/dist/getDisplayName.d.ts +1 -1
  11. package/react/dist/index.d.ts +2 -0
  12. package/react/dist/mount.d.ts +5 -141
  13. package/react/dist/types.d.ts +50 -0
  14. package/react/package.json +1 -5
  15. package/react18/dist/cypress-react.cjs.js +422 -0
  16. package/react18/dist/cypress-react.esm-bundler.js +394 -0
  17. package/react18/dist/index.d.ts +5 -0
  18. package/react18/package.json +59 -0
  19. package/types/cypress.d.ts +9 -0
  20. package/types/index.d.ts +1 -1
  21. package/types/{net-stubbing.ts → net-stubbing.d.ts} +0 -0
  22. package/vue/CHANGELOG.md +2 -17
  23. package/vue/README.md +17 -608
  24. package/vue/dist/@vue/test-utils/baseWrapper.d.ts +3 -1
  25. package/vue/dist/@vue/test-utils/config.d.ts +4 -2
  26. package/vue/dist/@vue/test-utils/emit.d.ts +1 -0
  27. package/vue/dist/@vue/test-utils/index.d.ts +2 -1
  28. package/vue/dist/@vue/test-utils/interfaces/wrapperLike.d.ts +2 -2
  29. package/vue/dist/@vue/test-utils/mount.d.ts +2 -0
  30. package/vue/dist/@vue/test-utils/stubs.d.ts +2 -6
  31. package/vue/dist/@vue/test-utils/types.d.ts +1 -1
  32. package/vue/dist/@vue/test-utils/vueWrapper.d.ts +2 -1
  33. package/vue/dist/cypress-vue.cjs.js +5379 -5090
  34. package/vue/dist/cypress-vue.esm-bundler.js +5380 -5091
  35. package/vue/dist/index.d.ts +1 -0
  36. package/vue/package.json +2 -2
  37. package/vue2/README.md +11 -627
  38. package/vue2/dist/cypress-vue2.browser.js +251 -260
  39. package/vue2/dist/cypress-vue2.cjs.js +250 -259
  40. package/vue2/dist/cypress-vue2.esm-bundler.js +248 -257
  41. package/react/dist/cypress-react.browser.js +0 -512
@@ -12,6 +12,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
12
12
  var React = require('react');
13
13
  var ReactDOM = require('react-dom');
14
14
 
15
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
+
15
17
  function _interopNamespace(e) {
16
18
  if (e && e.__esModule) return e;
17
19
  var n = Object.create(null);
@@ -31,7 +33,7 @@ function _interopNamespace(e) {
31
33
  }
32
34
 
33
35
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
34
- var ReactDOM__namespace = /*#__PURE__*/_interopNamespace(ReactDOM);
36
+ var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
35
37
 
36
38
  /******************************************************************************
37
39
  Copyright (c) Microsoft Corporation.
@@ -255,37 +257,21 @@ var injectStyles = function (options) {
255
257
  return injectStylesBeforeElement(options, document, el);
256
258
  };
257
259
  };
260
+ exports.lastMountedReactDom = void 0;
258
261
  /**
259
- * Mount a React component in a blank document; register it as an alias
260
- * To access: use an alias or original component reference
261
- * @function mount
262
- * @param {React.ReactElement} jsx - component to mount
263
- * @param {MountOptions} [options] - options, like alias, styles
264
- * @see https://github.com/bahmutov/@cypress/react
265
- * @see https://glebbahmutov.com/blog/my-vision-for-component-tests/
266
- * @example
267
- ```
268
- import Hello from './hello.jsx'
269
- import { mount } from '@cypress/react'
270
- it('works', () => {
271
- mount(<Hello onClick={cy.stub()} />)
272
- // use Cypress commands
273
- cy.contains('Hello').click()
274
- })
275
- ```
276
- **/
277
- var mount = function (jsx, options) {
278
- if (options === void 0) { options = {}; }
279
- return _mount('mount', jsx, options);
280
- };
281
- var lastMountedReactDom;
282
- /**
283
- * @see `mount`
284
- * @param type The type of mount executed
285
- * @param rerenderKey If specified, use the provided key rather than generating a new one
262
+ * Create an `mount` function. Performs all the non-React-version specific
263
+ * behavior related to mounting. The React-version-specific code
264
+ * is injected. This helps us to maintain a consistent public API
265
+ * and handle breaking changes in React's rendering API.
266
+ *
267
+ * This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
268
+ * or people writing adapters for third-party, custom adapters.
286
269
  */
287
- var _mount = function (type, jsx, options, rerenderKey) {
270
+ var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOptions) {
288
271
  if (options === void 0) { options = {}; }
272
+ if (!internalMountOptions) {
273
+ throw Error('internalMountOptions must be provided with `render` and `reactDom` parameters');
274
+ }
289
275
  // Get the display name property via the component constructor
290
276
  // @ts-ignore FIXME
291
277
  var componentName = getDisplayName(jsx.type, options.alias);
@@ -298,8 +284,8 @@ var _mount = function (type, jsx, options, rerenderKey) {
298
284
  .then(injectStyles(options))
299
285
  .then(function () {
300
286
  var _a, _b, _c;
301
- var reactDomToUse = options.ReactDom || ReactDOM__namespace;
302
- lastMountedReactDom = reactDomToUse;
287
+ var reactDomToUse = internalMountOptions.reactDom;
288
+ exports.lastMountedReactDom = reactDomToUse;
303
289
  var el = getContainerEl();
304
290
  if (!el) {
305
291
  throw new Error([
@@ -316,7 +302,7 @@ var _mount = function (type, jsx, options, rerenderKey) {
316
302
  // since we always surround the component with a fragment
317
303
  // let's get back the original component
318
304
  var userComponent = reactComponent.props.children;
319
- reactDomToUse.render(reactComponent, el);
305
+ internalMountOptions.render(reactComponent, el, reactDomToUse);
320
306
  if (options.log !== false) {
321
307
  Cypress.log({
322
308
  name: type,
@@ -341,8 +327,8 @@ var _mount = function (type, jsx, options, rerenderKey) {
341
327
  .then(function () {
342
328
  return cy.wrap({
343
329
  component: userComponent,
344
- rerender: function (newComponent) { return _mount('rerender', newComponent, options, key); },
345
- unmount: function () { return _unmount({ boundComponentMessage: jsxComponentName, log: true }); },
330
+ rerender: function (newComponent) { return makeMountFn('rerender', newComponent, options, key, internalMountOptions); },
331
+ unmount: internalMountOptions.unmount,
346
332
  }, { log: false });
347
333
  })
348
334
  // by waiting, we delaying test execution for the next tick of event loop
@@ -353,32 +339,19 @@ var _mount = function (type, jsx, options, rerenderKey) {
353
339
  });
354
340
  };
355
341
  /**
356
- * Removes the mounted component. Notice this command automatically
357
- * queues up the `unmount` into Cypress chain, thus you don't need `.then`
358
- * to call it.
359
- * @see https://github.com/cypress-io/cypress/tree/develop/npm/react/cypress/component/basic/unmount
360
- * @example
361
- ```
362
- import { mount, unmount } from '@cypress/react'
363
- it('works', () => {
364
- mount(...)
365
- // interact with the component using Cypress commands
366
- // whenever you want to unmount
367
- unmount()
368
- })
369
- ```
342
+ * Create an `unmount` function. Performs all the non-React-version specific
343
+ * behavior related to unmounting.
344
+ *
345
+ * This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
346
+ * or people writing adapters for third-party, custom adapters.
370
347
  */
371
- // @ts-ignore
372
- var unmount = function (options) {
373
- if (options === void 0) { options = { log: true }; }
374
- return _unmount(options);
375
- };
376
- var _unmount = function (options) {
348
+ var makeUnmountFn = function (options, internalUnmountOptions) {
377
349
  return cy.then(function () {
378
350
  return cy.get(ROOT_SELECTOR, { log: false }).then(function ($el) {
379
351
  var _a;
380
- if (lastMountedReactDom) {
381
- var wasUnmounted = lastMountedReactDom.unmountComponentAtNode($el[0]);
352
+ if (exports.lastMountedReactDom) {
353
+ internalUnmountOptions.unmount($el[0]);
354
+ var wasUnmounted = internalUnmountOptions.unmount($el[0]);
382
355
  if (wasUnmounted && options.log) {
383
356
  Cypress.log({
384
357
  name: 'unmount',
@@ -402,32 +375,17 @@ var _unmount = function (options) {
402
375
  // we are not in the context of a test
403
376
  var preMountCleanup = function () {
404
377
  var el = getContainerEl();
405
- if (el && lastMountedReactDom) {
406
- lastMountedReactDom.unmountComponentAtNode(el);
378
+ if (el && exports.lastMountedReactDom) {
379
+ exports.lastMountedReactDom.unmountComponentAtNode(el);
407
380
  }
408
381
  };
409
- /**
410
- * Creates new instance of `mount` function with default options
411
- * @function createMount
412
- * @param {MountOptions} [defaultOptions] - defaultOptions for returned `mount` function
413
- * @returns new instance of `mount` with assigned options
414
- * @example
415
- * ```
416
- * import Hello from './hello.jsx'
417
- * import { createMount } from '@cypress/react'
418
- *
419
- * const mount = createMount({ strict: true, cssFile: 'path/to/any/css/file.css' })
420
- *
421
- * it('works', () => {
422
- * mount(<Hello />)
423
- * // use Cypress commands
424
- * cy.get('button').should('have.css', 'color', 'rgb(124, 12, 109)')
425
- * })
426
- ```
427
- **/
382
+ var _mount = function (jsx, options) {
383
+ if (options === void 0) { options = {}; }
384
+ return makeMountFn('mount', jsx, options);
385
+ };
428
386
  var createMount = function (defaultOptions) {
429
387
  return function (element, options) {
430
- return mount(element, __assign(__assign({}, defaultOptions), options));
388
+ return _mount(element, __assign(__assign({}, defaultOptions), options));
431
389
  };
432
390
  };
433
391
  // Side effects from "import { mount } from '@cypress/<my-framework>'" are annoying, we should avoid doing this
@@ -443,6 +401,27 @@ var createMount = function (defaultOptions) {
443
401
  // @see npm/react/cypress/component/advanced/set-timeout-example/loading-indicator-spec.js
444
402
  setupHooks(preMountCleanup);
445
403
 
404
+ function mount(jsx, options, rerenderKey) {
405
+ if (options === void 0) { options = {}; }
406
+ var internalOptions = {
407
+ reactDom: ReactDOM__default["default"],
408
+ render: function (reactComponent, el, reactDomToUse) {
409
+ return (reactDomToUse || ReactDOM__default["default"]).render(reactComponent, el);
410
+ },
411
+ unmount: unmount,
412
+ };
413
+ return makeMountFn('mount', jsx, __assign({ ReactDom: ReactDOM__default["default"] }, options), rerenderKey, internalOptions);
414
+ }
415
+ function unmount(options) {
416
+ if (options === void 0) { options = { log: true }; }
417
+ var internalOptions = {
418
+ unmount: function (el) {
419
+ return (exports.lastMountedReactDom || ReactDOM__default["default"]).unmountComponentAtNode(el);
420
+ },
421
+ };
422
+ return makeUnmountFn(options, internalOptions);
423
+ }
424
+
446
425
  // mounting hooks inside a test component mostly copied from
447
426
  // https://github.com/testing-library/react-hooks-testing-library/blob/master/src/pure.js
448
427
  function resultContainer() {
@@ -505,6 +484,8 @@ var mountHook = function (hookFn) {
505
484
  };
506
485
 
507
486
  exports.createMount = createMount;
487
+ exports.makeMountFn = makeMountFn;
488
+ exports.makeUnmountFn = makeUnmountFn;
508
489
  exports.mount = mount;
509
490
  exports.mountHook = mountHook;
510
491
  exports.unmount = unmount;
@@ -6,7 +6,7 @@
6
6
  */
7
7
 
8
8
  import * as React from 'react';
9
- import * as ReactDOM from 'react-dom';
9
+ import ReactDOM from 'react-dom';
10
10
 
11
11
  /******************************************************************************
12
12
  Copyright (c) Microsoft Corporation.
@@ -230,37 +230,21 @@ var injectStyles = function (options) {
230
230
  return injectStylesBeforeElement(options, document, el);
231
231
  };
232
232
  };
233
- /**
234
- * Mount a React component in a blank document; register it as an alias
235
- * To access: use an alias or original component reference
236
- * @function mount
237
- * @param {React.ReactElement} jsx - component to mount
238
- * @param {MountOptions} [options] - options, like alias, styles
239
- * @see https://github.com/bahmutov/@cypress/react
240
- * @see https://glebbahmutov.com/blog/my-vision-for-component-tests/
241
- * @example
242
- ```
243
- import Hello from './hello.jsx'
244
- import { mount } from '@cypress/react'
245
- it('works', () => {
246
- mount(<Hello onClick={cy.stub()} />)
247
- // use Cypress commands
248
- cy.contains('Hello').click()
249
- })
250
- ```
251
- **/
252
- var mount = function (jsx, options) {
253
- if (options === void 0) { options = {}; }
254
- return _mount('mount', jsx, options);
255
- };
256
233
  var lastMountedReactDom;
257
234
  /**
258
- * @see `mount`
259
- * @param type The type of mount executed
260
- * @param rerenderKey If specified, use the provided key rather than generating a new one
235
+ * Create an `mount` function. Performs all the non-React-version specific
236
+ * behavior related to mounting. The React-version-specific code
237
+ * is injected. This helps us to maintain a consistent public API
238
+ * and handle breaking changes in React's rendering API.
239
+ *
240
+ * This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
241
+ * or people writing adapters for third-party, custom adapters.
261
242
  */
262
- var _mount = function (type, jsx, options, rerenderKey) {
243
+ var makeMountFn = function (type, jsx, options, rerenderKey, internalMountOptions) {
263
244
  if (options === void 0) { options = {}; }
245
+ if (!internalMountOptions) {
246
+ throw Error('internalMountOptions must be provided with `render` and `reactDom` parameters');
247
+ }
264
248
  // Get the display name property via the component constructor
265
249
  // @ts-ignore FIXME
266
250
  var componentName = getDisplayName(jsx.type, options.alias);
@@ -273,7 +257,7 @@ var _mount = function (type, jsx, options, rerenderKey) {
273
257
  .then(injectStyles(options))
274
258
  .then(function () {
275
259
  var _a, _b, _c;
276
- var reactDomToUse = options.ReactDom || ReactDOM;
260
+ var reactDomToUse = internalMountOptions.reactDom;
277
261
  lastMountedReactDom = reactDomToUse;
278
262
  var el = getContainerEl();
279
263
  if (!el) {
@@ -291,7 +275,7 @@ var _mount = function (type, jsx, options, rerenderKey) {
291
275
  // since we always surround the component with a fragment
292
276
  // let's get back the original component
293
277
  var userComponent = reactComponent.props.children;
294
- reactDomToUse.render(reactComponent, el);
278
+ internalMountOptions.render(reactComponent, el, reactDomToUse);
295
279
  if (options.log !== false) {
296
280
  Cypress.log({
297
281
  name: type,
@@ -316,8 +300,8 @@ var _mount = function (type, jsx, options, rerenderKey) {
316
300
  .then(function () {
317
301
  return cy.wrap({
318
302
  component: userComponent,
319
- rerender: function (newComponent) { return _mount('rerender', newComponent, options, key); },
320
- unmount: function () { return _unmount({ boundComponentMessage: jsxComponentName, log: true }); },
303
+ rerender: function (newComponent) { return makeMountFn('rerender', newComponent, options, key, internalMountOptions); },
304
+ unmount: internalMountOptions.unmount,
321
305
  }, { log: false });
322
306
  })
323
307
  // by waiting, we delaying test execution for the next tick of event loop
@@ -328,32 +312,19 @@ var _mount = function (type, jsx, options, rerenderKey) {
328
312
  });
329
313
  };
330
314
  /**
331
- * Removes the mounted component. Notice this command automatically
332
- * queues up the `unmount` into Cypress chain, thus you don't need `.then`
333
- * to call it.
334
- * @see https://github.com/cypress-io/cypress/tree/develop/npm/react/cypress/component/basic/unmount
335
- * @example
336
- ```
337
- import { mount, unmount } from '@cypress/react'
338
- it('works', () => {
339
- mount(...)
340
- // interact with the component using Cypress commands
341
- // whenever you want to unmount
342
- unmount()
343
- })
344
- ```
315
+ * Create an `unmount` function. Performs all the non-React-version specific
316
+ * behavior related to unmounting.
317
+ *
318
+ * This is designed to be consumed by `npm/react{16,17,18}`, and other React adapters,
319
+ * or people writing adapters for third-party, custom adapters.
345
320
  */
346
- // @ts-ignore
347
- var unmount = function (options) {
348
- if (options === void 0) { options = { log: true }; }
349
- return _unmount(options);
350
- };
351
- var _unmount = function (options) {
321
+ var makeUnmountFn = function (options, internalUnmountOptions) {
352
322
  return cy.then(function () {
353
323
  return cy.get(ROOT_SELECTOR, { log: false }).then(function ($el) {
354
324
  var _a;
355
325
  if (lastMountedReactDom) {
356
- var wasUnmounted = lastMountedReactDom.unmountComponentAtNode($el[0]);
326
+ internalUnmountOptions.unmount($el[0]);
327
+ var wasUnmounted = internalUnmountOptions.unmount($el[0]);
357
328
  if (wasUnmounted && options.log) {
358
329
  Cypress.log({
359
330
  name: 'unmount',
@@ -381,28 +352,13 @@ var preMountCleanup = function () {
381
352
  lastMountedReactDom.unmountComponentAtNode(el);
382
353
  }
383
354
  };
384
- /**
385
- * Creates new instance of `mount` function with default options
386
- * @function createMount
387
- * @param {MountOptions} [defaultOptions] - defaultOptions for returned `mount` function
388
- * @returns new instance of `mount` with assigned options
389
- * @example
390
- * ```
391
- * import Hello from './hello.jsx'
392
- * import { createMount } from '@cypress/react'
393
- *
394
- * const mount = createMount({ strict: true, cssFile: 'path/to/any/css/file.css' })
395
- *
396
- * it('works', () => {
397
- * mount(<Hello />)
398
- * // use Cypress commands
399
- * cy.get('button').should('have.css', 'color', 'rgb(124, 12, 109)')
400
- * })
401
- ```
402
- **/
355
+ var _mount = function (jsx, options) {
356
+ if (options === void 0) { options = {}; }
357
+ return makeMountFn('mount', jsx, options);
358
+ };
403
359
  var createMount = function (defaultOptions) {
404
360
  return function (element, options) {
405
- return mount(element, __assign(__assign({}, defaultOptions), options));
361
+ return _mount(element, __assign(__assign({}, defaultOptions), options));
406
362
  };
407
363
  };
408
364
  // Side effects from "import { mount } from '@cypress/<my-framework>'" are annoying, we should avoid doing this
@@ -418,6 +374,27 @@ var createMount = function (defaultOptions) {
418
374
  // @see npm/react/cypress/component/advanced/set-timeout-example/loading-indicator-spec.js
419
375
  setupHooks(preMountCleanup);
420
376
 
377
+ function mount(jsx, options, rerenderKey) {
378
+ if (options === void 0) { options = {}; }
379
+ var internalOptions = {
380
+ reactDom: ReactDOM,
381
+ render: function (reactComponent, el, reactDomToUse) {
382
+ return (reactDomToUse || ReactDOM).render(reactComponent, el);
383
+ },
384
+ unmount: unmount,
385
+ };
386
+ return makeMountFn('mount', jsx, __assign({ ReactDom: ReactDOM }, options), rerenderKey, internalOptions);
387
+ }
388
+ function unmount(options) {
389
+ if (options === void 0) { options = { log: true }; }
390
+ var internalOptions = {
391
+ unmount: function (el) {
392
+ return (lastMountedReactDom || ReactDOM).unmountComponentAtNode(el);
393
+ },
394
+ };
395
+ return makeUnmountFn(options, internalOptions);
396
+ }
397
+
421
398
  // mounting hooks inside a test component mostly copied from
422
399
  // https://github.com/testing-library/react-hooks-testing-library/blob/master/src/pure.js
423
400
  function resultContainer() {
@@ -479,4 +456,4 @@ var mountHook = function (hookFn) {
479
456
  return mount(componentTest).then(function () { return result; });
480
457
  };
481
458
 
482
- export { createMount, mount, mountHook, unmount };
459
+ export { createMount, lastMountedReactDom, makeMountFn, makeUnmountFn, mount, mountHook, unmount };
@@ -1,4 +1,4 @@
1
- import { JSX } from './mount';
1
+ import { JSX } from './createMount';
2
2
  /**
3
3
  * Gets the display name of the component when possible.
4
4
  * @param type {JSX} The type object returned from creating the react element.
@@ -1,2 +1,4 @@
1
+ export * from './createMount';
1
2
  export * from './mount';
2
3
  export * from './mountHook';
4
+ export * from './types';
@@ -1,143 +1,7 @@
1
1
  /// <reference types="cypress" />
2
- import * as React from 'react';
3
- import * as ReactDOM from 'react-dom';
4
- import { StyleOptions } from '@cypress/mount-utils';
5
- /**
6
- * Mount a React component in a blank document; register it as an alias
7
- * To access: use an alias or original component reference
8
- * @function mount
9
- * @param {React.ReactElement} jsx - component to mount
10
- * @param {MountOptions} [options] - options, like alias, styles
11
- * @see https://github.com/bahmutov/@cypress/react
12
- * @see https://glebbahmutov.com/blog/my-vision-for-component-tests/
13
- * @example
14
- ```
15
- import Hello from './hello.jsx'
16
- import { mount } from '@cypress/react'
17
- it('works', () => {
18
- mount(<Hello onClick={cy.stub()} />)
19
- // use Cypress commands
20
- cy.contains('Hello').click()
21
- })
22
- ```
23
- **/
24
- export declare const mount: (jsx: React.ReactNode, options?: MountOptions) => globalThis.Cypress.Chainable<MountReturn>;
25
- /**
26
- * Removes the mounted component. Notice this command automatically
27
- * queues up the `unmount` into Cypress chain, thus you don't need `.then`
28
- * to call it.
29
- * @see https://github.com/cypress-io/cypress/tree/develop/npm/react/cypress/component/basic/unmount
30
- * @example
31
- ```
32
- import { mount, unmount } from '@cypress/react'
33
- it('works', () => {
34
- mount(...)
35
- // interact with the component using Cypress commands
36
- // whenever you want to unmount
37
- unmount()
38
- })
39
- ```
40
- */
41
- export declare const unmount: (options?: {
2
+ import React from 'react';
3
+ import type { MountOptions } from './types';
4
+ export declare function mount(jsx: React.ReactNode, options?: MountOptions, rerenderKey?: string): Cypress.Chainable<import("./types").MountReturn>;
5
+ export declare function unmount(options?: {
42
6
  log: boolean;
43
- }) => globalThis.Cypress.Chainable<JQuery<HTMLElement>>;
44
- /**
45
- * Creates new instance of `mount` function with default options
46
- * @function createMount
47
- * @param {MountOptions} [defaultOptions] - defaultOptions for returned `mount` function
48
- * @returns new instance of `mount` with assigned options
49
- * @example
50
- * ```
51
- * import Hello from './hello.jsx'
52
- * import { createMount } from '@cypress/react'
53
- *
54
- * const mount = createMount({ strict: true, cssFile: 'path/to/any/css/file.css' })
55
- *
56
- * it('works', () => {
57
- * mount(<Hello />)
58
- * // use Cypress commands
59
- * cy.get('button').should('have.css', 'color', 'rgb(124, 12, 109)')
60
- * })
61
- ```
62
- **/
63
- export declare const createMount: (defaultOptions: MountOptions) => (element: React.ReactElement, options?: Partial<StyleOptions & MountReactComponentOptions> | undefined) => globalThis.Cypress.Chainable<MountReturn>;
64
- /** @deprecated Should be removed in the next major version */
65
- export default mount;
66
- export interface ReactModule {
67
- name: string;
68
- type: string;
69
- location: string;
70
- source: string;
71
- }
72
- export interface MountReactComponentOptions {
73
- alias: string;
74
- ReactDom: typeof ReactDOM;
75
- /**
76
- * Log the mounting command into Cypress Command Log,
77
- * true by default.
78
- */
79
- log: boolean;
80
- /**
81
- * Render component in React [strict mode](https://reactjs.org/docs/strict-mode.html)
82
- * It activates additional checks and warnings for child components.
83
- */
84
- strict: boolean;
85
- }
86
- export declare type MountOptions = Partial<StyleOptions & MountReactComponentOptions>;
87
- export interface MountReturn {
88
- /**
89
- * The component that was rendered.
90
- */
91
- component: React.ReactNode;
92
- /**
93
- * Rerenders the specified component with new props. This allows testing of components that store state (`setState`)
94
- * or have asynchronous updates (`useEffect`, `useLayoutEffect`).
95
- */
96
- rerender: (component: React.ReactNode) => globalThis.Cypress.Chainable<MountReturn>;
97
- /**
98
- * Removes the mounted component.
99
- * @see `unmount`
100
- */
101
- unmount: () => globalThis.Cypress.Chainable<JQuery<HTMLElement>>;
102
- }
103
- /**
104
- * The `type` property from the transpiled JSX object.
105
- * @example
106
- * const { type } = React.createElement('div', null, 'Hello')
107
- * const { type } = <div>Hello</div>
108
- */
109
- export interface JSX extends Function {
110
- displayName: string;
111
- }
112
- export declare namespace Cypress {
113
- interface Cypress {
114
- stylesCache: any;
115
- React: string;
116
- ReactDOM: string;
117
- Styles: string;
118
- modules: ReactModule[];
119
- }
120
- interface Chainable<Subject> {
121
- state: (key: string) => any;
122
- /**
123
- * Mount a React component in a blank document; register it as an alias
124
- * To access: use an alias or original component reference
125
- * @function cy.mount
126
- * @param {Object} jsx - component to mount
127
- * @param {string} [Component] - alias to use later
128
- * @example
129
- ```
130
- import Hello from './hello.jsx'
131
- // mount and access by alias
132
- cy.mount(<Hello />, 'Hello')
133
- // using default alias
134
- cy.get('@Component')
135
- // using specified alias
136
- cy.get('@Hello').its('state').should(...)
137
- // using original component
138
- cy.get(Hello)
139
- ```
140
- **/
141
- get<S = any>(alias: string | symbol | Function, options?: Partial<any>): Chainable<any>;
142
- }
143
- }
7
+ }): Cypress.Chainable<JQuery<HTMLElement>>;
@@ -0,0 +1,50 @@
1
+ /// <reference types="cypress" />
2
+ import type React from 'react';
3
+ import type { StyleOptions } from '@cypress/mount-utils';
4
+ export interface UnmountArgs {
5
+ log: boolean;
6
+ boundComponentMessage?: string;
7
+ }
8
+ export interface InternalUnmountOptionsReact {
9
+ unmount: (el: HTMLElement) => boolean;
10
+ }
11
+ export interface InternalUnmountOptionsReact18 {
12
+ unmount: () => boolean;
13
+ }
14
+ export declare type InternalUnmountOptions = InternalUnmountOptionsReact | InternalUnmountOptionsReact18;
15
+ export declare type MountOptions = Partial<StyleOptions & MountReactComponentOptions>;
16
+ export interface MountReactComponentOptions {
17
+ alias: string;
18
+ ReactDom: typeof import('react-dom');
19
+ /**
20
+ * Log the mounting command into Cypress Command Log,
21
+ * true by default.
22
+ */
23
+ log: boolean;
24
+ /**
25
+ * Render component in React [strict mode](https://reactjs.org/docs/strict-mode.html)
26
+ * It activates additional checks and warnings for child components.
27
+ */
28
+ strict: boolean;
29
+ }
30
+ export interface InternalMountOptions {
31
+ reactDom: typeof import('react-dom');
32
+ render: (reactComponent: ReturnType<typeof React.createElement>, el: HTMLElement, reactDomToUse: typeof import('react-dom')) => void;
33
+ unmount: (options: UnmountArgs) => void;
34
+ }
35
+ export interface MountReturn {
36
+ /**
37
+ * The component that was rendered.
38
+ */
39
+ component: React.ReactNode;
40
+ /**
41
+ * Rerenders the specified component with new props. This allows testing of components that store state (`setState`)
42
+ * or have asynchronous updates (`useEffect`, `useLayoutEffect`).
43
+ */
44
+ rerender: (component: React.ReactNode) => globalThis.Cypress.Chainable<MountReturn>;
45
+ /**
46
+ * Removes the mounted component.
47
+ * @see `unmount`
48
+ */
49
+ unmount: (payload: UnmountArgs) => void;
50
+ }
@@ -14,9 +14,6 @@
14
14
  "test": "yarn cy:run",
15
15
  "watch": "yarn build --watch --watch.exclude ./dist/**/*"
16
16
  },
17
- "dependencies": {
18
- "debug": "^4.3.2"
19
- },
20
17
  "devDependencies": {
21
18
  "@cypress/mount-utils": "0.0.0-development",
22
19
  "@rollup/plugin-commonjs": "^17.1.0",
@@ -24,7 +21,6 @@
24
21
  "@vitejs/plugin-react": "1.3.1",
25
22
  "axios": "0.21.2",
26
23
  "cypress": "0.0.0-development",
27
- "cypress-plugin-snapshots": "1.4.4",
28
24
  "prop-types": "15.7.2",
29
25
  "react": "16.8.6",
30
26
  "react-dom": "16.8.6",
@@ -33,7 +29,7 @@
33
29
  "rollup": "^2.38.5",
34
30
  "rollup-plugin-typescript2": "^0.29.0",
35
31
  "typescript": "^4.2.3",
36
- "vite": "2.9.5",
32
+ "vite": "3.0.3",
37
33
  "vite-plugin-require-transform": "1.0.3"
38
34
  },
39
35
  "peerDependencies": {