cypress 10.10.0 → 11.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. package/angular/CHANGELOG.md +27 -0
  2. package/angular/dist/index.d.ts +124 -1
  3. package/angular/dist/index.js +59 -59
  4. package/lib/cli.js +15 -1
  5. package/lib/tasks/download.js +3 -7
  6. package/lib/util.js +2 -2
  7. package/mount-utils/CHANGELOG.md +7 -63
  8. package/mount-utils/README.md +5 -23
  9. package/mount-utils/dist/index.d.ts +25 -39
  10. package/mount-utils/dist/index.js +33 -112
  11. package/mount-utils/package.json +1 -0
  12. package/package.json +5 -4
  13. package/react/CHANGELOG.md +12 -55
  14. package/react/README.md +2 -22
  15. package/react/dist/cypress-react.cjs.js +92 -219
  16. package/react/dist/cypress-react.esm-bundler.js +92 -220
  17. package/react/dist/index.d.ts +111 -4
  18. package/react18/CHANGELOG.md +6 -106
  19. package/react18/dist/cypress-react.cjs.js +117 -180
  20. package/react18/dist/cypress-react.esm-bundler.js +103 -167
  21. package/react18/dist/index.d.ts +78 -6
  22. package/react18/package.json +1 -0
  23. package/svelte/CHANGELOG.md +20 -0
  24. package/svelte/dist/cypress-svelte.cjs.js +19 -114
  25. package/svelte/dist/cypress-svelte.esm-bundler.js +19 -114
  26. package/svelte/dist/index.d.ts +201 -1
  27. package/types/cypress-npm-api.d.ts +1 -1
  28. package/types/cypress.d.ts +43 -21
  29. package/vue/CHANGELOG.md +13 -101
  30. package/vue/README.md +4 -8
  31. package/vue/dist/cypress-vue.cjs.js +70 -153
  32. package/vue/dist/cypress-vue.esm-bundler.js +70 -153
  33. package/vue/dist/index.d.ts +1352 -104
  34. package/vue/package.json +1 -1
  35. package/vue2/CHANGELOG.md +15 -50
  36. package/vue2/README.md +3 -7
  37. package/vue2/dist/cypress-vue2.cjs.js +87 -211
  38. package/vue2/dist/cypress-vue2.esm-bundler.js +86 -210
  39. package/vue2/dist/index.d.ts +341 -172
  40. package/vue2/package.json +1 -3
  41. package/angular/dist/mount.d.ts +0 -112
  42. package/react/dist/createMount.d.ts +0 -31
  43. package/react/dist/getDisplayName.d.ts +0 -8
  44. package/react/dist/mount.d.ts +0 -8
  45. package/react/dist/mountHook.d.ts +0 -12
  46. package/react/dist/types.d.ts +0 -45
  47. package/svelte/dist/mount.d.ts +0 -30
  48. package/vue/dist/@vue/test-utils/baseWrapper.d.ts +0 -63
  49. package/vue/dist/@vue/test-utils/components/RouterLinkStub.d.ts +0 -21
  50. package/vue/dist/@vue/test-utils/config.d.ts +0 -30
  51. package/vue/dist/@vue/test-utils/constants/dom-events.d.ts +0 -900
  52. package/vue/dist/@vue/test-utils/createDomEvent.d.ts +0 -9
  53. package/vue/dist/@vue/test-utils/domWrapper.d.ts +0 -18
  54. package/vue/dist/@vue/test-utils/emit.d.ts +0 -5
  55. package/vue/dist/@vue/test-utils/errorWrapper.d.ts +0 -1
  56. package/vue/dist/@vue/test-utils/index.d.ts +0 -11
  57. package/vue/dist/@vue/test-utils/interfaces/wrapperLike.d.ts +0 -56
  58. package/vue/dist/@vue/test-utils/mount.d.ts +0 -35
  59. package/vue/dist/@vue/test-utils/stubs.d.ts +0 -22
  60. package/vue/dist/@vue/test-utils/types.d.ts +0 -125
  61. package/vue/dist/@vue/test-utils/utils/autoUnmount.d.ts +0 -5
  62. package/vue/dist/@vue/test-utils/utils/compileSlots.d.ts +0 -2
  63. package/vue/dist/@vue/test-utils/utils/componentName.d.ts +0 -4
  64. package/vue/dist/@vue/test-utils/utils/find.d.ts +0 -10
  65. package/vue/dist/@vue/test-utils/utils/flushPromises.d.ts +0 -1
  66. package/vue/dist/@vue/test-utils/utils/getRootNodes.d.ts +0 -2
  67. package/vue/dist/@vue/test-utils/utils/isElement.d.ts +0 -1
  68. package/vue/dist/@vue/test-utils/utils/isElementVisible.d.ts +0 -6
  69. package/vue/dist/@vue/test-utils/utils/matchName.d.ts +0 -1
  70. package/vue/dist/@vue/test-utils/utils/stringifyNode.d.ts +0 -1
  71. package/vue/dist/@vue/test-utils/utils/vueCompatSupport.d.ts +0 -8
  72. package/vue/dist/@vue/test-utils/utils/vueShared.d.ts +0 -3
  73. package/vue/dist/@vue/test-utils/utils.d.ts +0 -13
  74. package/vue/dist/@vue/test-utils/vueWrapper.d.ts +0 -35
  75. package/vue/dist/@vue/test-utils/wrapperFactory.d.ts +0 -14
package/vue/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "cy:open": "node ../../scripts/cypress.js open --component --project ${PWD}",
9
9
  "cy:run": "node ../../scripts/cypress.js run --component --project ${PWD}",
10
10
  "build": "rimraf dist && rollup -c rollup.config.mjs",
11
- "postbuild": "node --require @packages/ts/register ./inline-types.ts && node ../../scripts/sync-exported-npm-with-cli.js",
11
+ "postbuild": "node ../../scripts/sync-exported-npm-with-cli.js",
12
12
  "typecheck": "yarn tsd && vue-tsc --noEmit",
13
13
  "test": "yarn cy:run",
14
14
  "tsd": "yarn build && yarn tsc -p test-tsd/tsconfig.tsd.json",
package/vue2/CHANGELOG.md CHANGED
@@ -1,72 +1,37 @@
1
- # [@cypress/vue2-v1.1.0](https://github.com/cypress-io/cypress/compare/@cypress/vue2-v1.0.2...@cypress/vue2-v1.1.0) (2022-10-11)
1
+ # [@cypress/vue2-v2.0.0](https://github.com/cypress-io/cypress/compare/@cypress/vue2-v1.1.2...@cypress/vue2-v2.0.0) (2022-11-07)
2
2
 
3
3
 
4
- ### Features
5
-
6
- * adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8))
7
-
8
- # [@cypress/vue2-v1.1.0](https://github.com/cypress-io/cypress/compare/@cypress/vue2-v1.0.2...@cypress/vue2-v1.1.0) (2022-10-06)
9
-
10
-
11
- ### Features
12
-
13
- * adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8))
14
-
15
- # [@cypress/vue2-v1.1.0](https://github.com/cypress-io/cypress/compare/@cypress/vue2-v1.0.2...@cypress/vue2-v1.1.0) (2022-10-04)
16
-
17
-
18
- ### Features
19
-
20
- * adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8))
21
-
22
- # [@cypress/vue2-v1.1.0](https://github.com/cypress-io/cypress/compare/@cypress/vue2-v1.0.2...@cypress/vue2-v1.1.0) (2022-10-04)
23
-
24
-
25
- ### Features
26
-
27
- * adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8))
28
-
29
- # [@cypress/vue2-v1.1.0](https://github.com/cypress-io/cypress/compare/@cypress/vue2-v1.0.2...@cypress/vue2-v1.1.0) (2022-10-03)
30
-
31
-
32
- ### Features
33
-
34
- * adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8))
35
-
36
- # [@cypress/vue2-v1.1.0](https://github.com/cypress-io/cypress/compare/@cypress/vue2-v1.0.2...@cypress/vue2-v1.1.0) (2022-10-01)
37
-
38
-
39
- ### Features
40
-
41
- * adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8))
4
+ ### Bug Fixes
42
5
 
43
- # [@cypress/vue2-v1.1.0](https://github.com/cypress-io/cypress/compare/@cypress/vue2-v1.0.2...@cypress/vue2-v1.1.0) (2022-09-30)
6
+ * remove dependence on @cypress/<dep> types ([#24415](https://github.com/cypress-io/cypress/issues/24415)) ([58e0ab9](https://github.com/cypress-io/cypress/commit/58e0ab91604618ea6f75932622f7e66e419270e6))
7
+ * remove last mounted component upon subsequent mount calls ([#24470](https://github.com/cypress-io/cypress/issues/24470)) ([f39eb1c](https://github.com/cypress-io/cypress/commit/f39eb1c19e0923bda7ae263168fc6448da942d54))
8
+ * remove some CT functions and props ([#24419](https://github.com/cypress-io/cypress/issues/24419)) ([294985f](https://github.com/cypress-io/cypress/commit/294985f8b3e0fa00ed66d25f88c8814603766074))
44
9
 
45
10
 
46
11
  ### Features
47
12
 
48
- * adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8))
13
+ * include component and wrapper in return type for vue mount adapter ([#24479](https://github.com/cypress-io/cypress/issues/24479)) ([33875d7](https://github.com/cypress-io/cypress/commit/33875d75505416b1f65ca7c6d5dedc46f3289f1b))
49
14
 
50
- # [@cypress/vue2-v1.1.0](https://github.com/cypress-io/cypress/compare/@cypress/vue2-v1.0.2...@cypress/vue2-v1.1.0) (2022-09-30)
51
15
 
16
+ ### BREAKING CHANGES
52
17
 
53
- ### Features
18
+ * remove last mounted component upon subsequent mount calls of mount
19
+ * Vue mount returns wrapper and component rather than wrapper only
54
20
 
55
- * adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8))
21
+ # [@cypress/vue2-v1.1.2](https://github.com/cypress-io/cypress/compare/@cypress/vue2-v1.1.1...@cypress/vue2-v1.1.2) (2022-11-01)
56
22
 
57
- # [@cypress/vue2-v1.1.0](https://github.com/cypress-io/cypress/compare/@cypress/vue2-v1.0.2...@cypress/vue2-v1.1.0) (2022-09-30)
58
23
 
24
+ ### Bug Fixes
59
25
 
60
- ### Features
26
+ * Hovering over mount in command log does not show component in AUT ([#24346](https://github.com/cypress-io/cypress/issues/24346)) ([355d210](https://github.com/cypress-io/cypress/commit/355d2101d38ea4d1e93b9c571cf77babab2bbbfc))
61
27
 
62
- * adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8))
28
+ # [@cypress/vue2-v1.1.1](https://github.com/cypress-io/cypress/compare/@cypress/vue2-v1.1.0...@cypress/vue2-v1.1.1) (2022-10-13)
63
29
 
64
- # [@cypress/vue2-v1.1.0](https://github.com/cypress-io/cypress/compare/@cypress/vue2-v1.0.2...@cypress/vue2-v1.1.0) (2022-09-29)
65
30
 
31
+ ### Bug Fixes
66
32
 
67
- ### Features
33
+ * angular and nuxt ct tests now fail on uncaught exceptions ([#24122](https://github.com/cypress-io/cypress/issues/24122)) ([53eef4f](https://github.com/cypress-io/cypress/commit/53eef4fbd7e1caf32f0183cadbc0e4cf05524c34))
68
34
 
69
- * adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8))
70
35
 
71
36
  # [@cypress/vue2-v1.1.0](https://github.com/cypress-io/cypress/compare/@cypress/vue2-v1.0.2...@cypress/vue2-v1.1.0) (2022-08-30)
72
37
 
package/vue2/README.md CHANGED
@@ -34,21 +34,17 @@ describe('HelloWorld component', () => {
34
34
 
35
35
  ### Options
36
36
 
37
- You can pass additional styles, css files and external stylesheets to load, see [docs/styles.md](./docs/styles.md) for full list.
37
+ One option for styling your components is to import stylesheets into your test file. See [docs/styles.md](./docs/styles.md) for full list of options.
38
38
 
39
39
  ```js
40
40
  import Todo from './Todo.vue'
41
+ import '../styles/main.css'
41
42
  const todo = {
42
43
  id: '123',
43
44
  title: 'Write more tests',
44
45
  }
45
46
 
46
- mount(Todo, {
47
- propsData: { todo },
48
- stylesheets: [
49
- 'https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.2/css/bulma.css',
50
- ],
51
- })
47
+ mount(Todo, { propsData: { todo } })
52
48
  ```
53
49
 
54
50
  ### Global Vue Options
@@ -9,11 +9,11 @@
9
9
 
10
10
  Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
- var require$$0$1 = require('vue');
12
+ var Vue = require('vue');
13
13
 
14
14
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
15
15
 
16
- var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
16
+ var Vue__default = /*#__PURE__*/_interopDefaultLegacy(Vue);
17
17
 
18
18
  var commonjsGlobal$1 = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
19
19
 
@@ -5737,15 +5737,11 @@ var build = /*#__PURE__*/Object.defineProperty({
5737
5737
  }, '__esModule', {value: true});
5738
5738
 
5739
5739
  try {
5740
- var vueVersion = require$$0__default["default"].version;
5740
+ var vueVersion = Vue__default["default"].version;
5741
5741
  } catch (e) {}
5742
5742
 
5743
5743
  var vueTemplateCompiler = build;
5744
5744
 
5745
- function _interopDefaultLegacy$1 (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
5746
-
5747
- var Vue__default = /*#__PURE__*/_interopDefaultLegacy$1(require$$0__default["default"]);
5748
-
5749
5745
  //
5750
5746
 
5751
5747
  function createVNodes(vm, slotValue, name) {
@@ -5791,7 +5787,7 @@ function createSlotVNodes(
5791
5787
  }, [])
5792
5788
  }
5793
5789
 
5794
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof commonjsGlobal$1 !== 'undefined' ? commonjsGlobal$1 : typeof self !== 'undefined' ? self : {};
5790
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
5795
5791
 
5796
5792
  function createCommonjsModule(fn, basedir, module) {
5797
5793
  return module = {
@@ -7417,17 +7413,17 @@ var DOM_SELECTOR = 'DOM_SELECTOR';
7417
7413
  var INVALID_SELECTOR = 'INVALID_SELECTOR';
7418
7414
 
7419
7415
  var VUE_VERSION = Number(
7420
- ((Vue__default['default'].version.split('.')[0]) + "." + (Vue__default['default'].version.split('.')[1]))
7416
+ ((Vue__default["default"].version.split('.')[0]) + "." + (Vue__default["default"].version.split('.')[1]))
7421
7417
  );
7422
7418
 
7423
7419
  var FUNCTIONAL_OPTIONS =
7424
7420
  VUE_VERSION >= 2.5 ? 'fnOptions' : 'functionalOptions';
7425
7421
 
7426
- var BEFORE_RENDER_LIFECYCLE_HOOK = semver.gt(Vue__default['default'].version, '2.1.8')
7422
+ var BEFORE_RENDER_LIFECYCLE_HOOK = semver.gt(Vue__default["default"].version, '2.1.8')
7427
7423
  ? 'beforeCreate'
7428
7424
  : 'beforeMount';
7429
7425
 
7430
- var CREATE_ELEMENT_ALIAS = semver.gt(Vue__default['default'].version, '2.1.5')
7426
+ var CREATE_ELEMENT_ALIAS = semver.gt(Vue__default["default"].version, '2.1.5')
7431
7427
  ? '_c'
7432
7428
  : '_h';
7433
7429
 
@@ -7501,7 +7497,7 @@ var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
7501
7497
 
7502
7498
  // get the event used to trigger v-model handler that updates bound data
7503
7499
  function getCheckedEvent() {
7504
- var version = Vue__default['default'].version;
7500
+ var version = Vue__default["default"].version;
7505
7501
 
7506
7502
  if (semver.satisfies(version, '2.1.9 - 2.1.10')) {
7507
7503
  return 'click'
@@ -7521,9 +7517,9 @@ function getCheckedEvent() {
7521
7517
  * @return {Promise<R>}
7522
7518
  */
7523
7519
  function nextTick() {
7524
- if (VUE_VERSION > 2) { return Vue__default['default'].nextTick() }
7520
+ if (VUE_VERSION > 2) { return Vue__default["default"].nextTick() }
7525
7521
  return new Promise(function (resolve) {
7526
- Vue__default['default'].nextTick(resolve);
7522
+ Vue__default["default"].nextTick(resolve);
7527
7523
  })
7528
7524
  }
7529
7525
 
@@ -7567,7 +7563,7 @@ function addMocks(
7567
7563
  );
7568
7564
  }
7569
7565
  // $FlowIgnore
7570
- Vue__default['default'].util.defineReactive(_Vue, key, mockedProperties[key]);
7566
+ Vue__default["default"].util.defineReactive(_Vue, key, mockedProperties[key]);
7571
7567
  });
7572
7568
  }
7573
7569
 
@@ -8068,8 +8064,8 @@ function createStubFromComponent(
8068
8064
  var tagName = (name || 'anonymous') + "-stub";
8069
8065
 
8070
8066
  // ignoreElements does not exist in Vue 2.0.x
8071
- if (Vue__default['default'].config.ignoredElements) {
8072
- Vue__default['default'].config.ignoredElements.push(tagName);
8067
+ if (Vue__default["default"].config.ignoredElements) {
8068
+ Vue__default["default"].config.ignoredElements.push(tagName);
8073
8069
  }
8074
8070
 
8075
8071
  return Object.assign({}, getCoreProperties(componentOptions),
@@ -14756,7 +14752,15 @@ ErrorWrapper.prototype.destroy = function destroy () {
14756
14752
  */
14757
14753
 
14758
14754
  function isStyleVisible(element) {
14759
- var ref = element.style;
14755
+ if (!(element instanceof HTMLElement) && !(element instanceof SVGElement)) {
14756
+ return false
14757
+ }
14758
+
14759
+ // Per https://lists.w3.org/Archives/Public/www-style/2018May/0031.html
14760
+ // getComputedStyle should only work with connected elements.
14761
+ var ref = element.isConnected
14762
+ ? getComputedStyle(element)
14763
+ : element.style;
14760
14764
  var display = ref.display;
14761
14765
  var visibility = ref.visibility;
14762
14766
  var opacity = ref.opacity;
@@ -17064,36 +17068,6 @@ var VueWrapper = /*@__PURE__*/(function (Wrapper) {
17064
17068
 
17065
17069
  //
17066
17070
 
17067
- var isEnabled = false;
17068
- var wrapperInstances = [];
17069
-
17070
- function enableAutoDestroy(hook) {
17071
- if (isEnabled) {
17072
- throwError('enableAutoDestroy cannot be called more than once');
17073
- }
17074
-
17075
- isEnabled = true;
17076
-
17077
- hook(function () {
17078
- wrapperInstances.forEach(function (wrapper) {
17079
- // skip child wrappers created by wrapper.find()
17080
- if (wrapper.vm || wrapper.isFunctionalComponent) {
17081
- wrapper.destroy();
17082
- }
17083
- });
17084
-
17085
- wrapperInstances.length = 0;
17086
- });
17087
- }
17088
-
17089
- function trackInstance(wrapper) {
17090
- if (!isEnabled) { return }
17091
-
17092
- wrapperInstances.push(wrapper);
17093
- }
17094
-
17095
- //
17096
-
17097
17071
  function createWrapper(
17098
17072
  node,
17099
17073
  options
@@ -17103,14 +17077,12 @@ function createWrapper(
17103
17077
  var componentInstance = node.child;
17104
17078
  if (componentInstance) {
17105
17079
  var wrapper$1 = new VueWrapper(componentInstance, options);
17106
- trackInstance(wrapper$1);
17107
17080
  return wrapper$1
17108
17081
  }
17109
17082
  var wrapper =
17110
- node instanceof Vue__default['default']
17083
+ node instanceof Vue__default["default"]
17111
17084
  ? new VueWrapper(node, options)
17112
17085
  : new Wrapper(node, options);
17113
- trackInstance(wrapper);
17114
17086
  return wrapper
17115
17087
  }
17116
17088
 
@@ -19609,7 +19581,7 @@ function _createLocalVue(
19609
19581
  _Vue,
19610
19582
  config
19611
19583
  ) {
19612
- if ( _Vue === void 0 ) _Vue = Vue__default['default'];
19584
+ if ( _Vue === void 0 ) _Vue = Vue__default["default"];
19613
19585
  if ( config === void 0 ) config = {};
19614
19586
 
19615
19587
  var instance = _Vue.extend();
@@ -19631,14 +19603,14 @@ function _createLocalVue(
19631
19603
  });
19632
19604
 
19633
19605
  // config is not enumerable
19634
- instance.config = cloneDeep_1(Vue__default['default'].config);
19606
+ instance.config = cloneDeep_1(Vue__default["default"].config);
19635
19607
 
19636
19608
  // if a user defined errorHandler is defined by a localVue instance via createLocalVue, register it
19637
19609
  instance.config.errorHandler = config.errorHandler;
19638
19610
 
19639
19611
  // option merge strategies need to be exposed by reference
19640
19612
  // so that merge strats registered by plugins can work properly
19641
- instance.config.optionMergeStrategies = Vue__default['default'].config.optionMergeStrategies;
19613
+ instance.config.optionMergeStrategies = Vue__default["default"].config.optionMergeStrategies;
19642
19614
 
19643
19615
  // make sure all extends are based on this instance.
19644
19616
  // this is important so that global components registered by plugins,
@@ -19759,8 +19731,8 @@ function validateOptions(options, component) {
19759
19731
  }
19760
19732
  }
19761
19733
 
19762
- Vue__default['default'].config.productionTip = false;
19763
- Vue__default['default'].config.devtools = false;
19734
+ Vue__default["default"].config.productionTip = false;
19735
+ Vue__default["default"].config.devtools = false;
19764
19736
 
19765
19737
  function mount$1(component, options) {
19766
19738
  if ( options === void 0 ) options = {};
@@ -19769,7 +19741,7 @@ function mount$1(component, options) {
19769
19741
 
19770
19742
  polyfill();
19771
19743
 
19772
- addGlobalErrorHandler(Vue__default['default']);
19744
+ addGlobalErrorHandler(Vue__default["default"]);
19773
19745
 
19774
19746
  var _Vue = _createLocalVue(
19775
19747
  options.localVue,
@@ -19815,11 +19787,13 @@ function createLocalVue(config) {
19815
19787
 
19816
19788
  return _createLocalVue(undefined, config)
19817
19789
  }
19818
- var createLocalVue_1 = createLocalVue;
19819
- var enableAutoDestroy_1 = enableAutoDestroy;
19820
- var mount_1 = mount$1;
19821
19790
 
19822
19791
  const ROOT_SELECTOR = '[data-cy-root]';
19792
+ /**
19793
+ * Gets the root element used to mount the component.
19794
+ * @returns {HTMLElement} The root element
19795
+ * @throws {Error} If the root element is not found
19796
+ */
19823
19797
  const getContainerEl = () => {
19824
19798
  const el = document.querySelector(ROOT_SELECTOR);
19825
19799
  if (el) {
@@ -19827,122 +19801,19 @@ const getContainerEl = () => {
19827
19801
  }
19828
19802
  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.`);
19829
19803
  };
19830
- /**
19831
- * Remove any style or extra link elements from the iframe placeholder
19832
- * left from any previous test
19833
- *
19834
- */
19835
- function cleanupStyles() {
19836
- const styles = document.body.querySelectorAll('[data-cy=injected-style-tag]');
19837
- styles.forEach((styleElement) => {
19838
- if (styleElement.parentElement) {
19839
- styleElement.parentElement.removeChild(styleElement);
19840
- }
19841
- });
19842
- const links = document.body.querySelectorAll('[data-cy=injected-stylesheet]');
19843
- links.forEach((link) => {
19844
- if (link.parentElement) {
19845
- link.parentElement.removeChild(link);
19804
+ function checkForRemovedStyleOptions(mountingOptions) {
19805
+ for (const key of ['cssFile', 'cssFiles', 'style', 'styles', 'stylesheet', 'stylesheets']) {
19806
+ if (mountingOptions[key]) {
19807
+ Cypress.utils.throwErrByPath('mount.removed_style_mounting_options', key);
19846
19808
  }
19847
- });
19848
- }
19849
- /**
19850
- * Insert links to external style resources.
19851
- */
19852
- function insertStylesheets(stylesheets, document, el) {
19853
- stylesheets.forEach((href) => {
19854
- const link = document.createElement('link');
19855
- link.type = 'text/css';
19856
- link.rel = 'stylesheet';
19857
- link.href = href;
19858
- link.dataset.cy = 'injected-stylesheet';
19859
- document.body.insertBefore(link, el);
19860
- });
19861
- }
19862
- /**
19863
- * Inserts a single stylesheet element
19864
- */
19865
- function insertStyles(styles, document, el) {
19866
- styles.forEach((style) => {
19867
- const styleElement = document.createElement('style');
19868
- styleElement.dataset.cy = 'injected-style-tag';
19869
- styleElement.appendChild(document.createTextNode(style));
19870
- document.body.insertBefore(styleElement, el);
19871
- });
19872
- }
19873
- function insertSingleCssFile(cssFilename, document, el, log) {
19874
- return cy.readFile(cssFilename, { log }).then((css) => {
19875
- const style = document.createElement('style');
19876
- style.appendChild(document.createTextNode(css));
19877
- document.body.insertBefore(style, el);
19878
- });
19879
- }
19880
- /**
19881
- * Reads the given CSS file from local file system
19882
- * and adds the loaded style text as an element.
19883
- */
19884
- function insertLocalCssFiles(cssFilenames, document, el, log) {
19885
- return Cypress.Promise.mapSeries(cssFilenames, (cssFilename) => {
19886
- return insertSingleCssFile(cssFilename, document, el, log);
19887
- });
19809
+ }
19888
19810
  }
19889
19811
  /**
19890
- * Injects custom style text or CSS file or 3rd party style resources
19891
- * into the given document.
19812
+ * Utility function to register CT side effects and run cleanup code during the "test:before:run" Cypress hook
19813
+ * @param optionalCallback Callback to be called before the next test runs
19892
19814
  */
19893
- const injectStylesBeforeElement = (options, document, el) => {
19894
- if (!el)
19895
- return;
19896
- // first insert all stylesheets as Link elements
19897
- let stylesheets = [];
19898
- if (typeof options.stylesheet === 'string') {
19899
- stylesheets.push(options.stylesheet);
19900
- }
19901
- else if (Array.isArray(options.stylesheet)) {
19902
- stylesheets = stylesheets.concat(options.stylesheet);
19903
- }
19904
- if (typeof options.stylesheets === 'string') {
19905
- options.stylesheets = [options.stylesheets];
19906
- }
19907
- if (options.stylesheets) {
19908
- stylesheets = stylesheets.concat(options.stylesheets);
19909
- }
19910
- insertStylesheets(stylesheets, document, el);
19911
- // insert any styles as <style>...</style> elements
19912
- let styles = [];
19913
- if (typeof options.style === 'string') {
19914
- styles.push(options.style);
19915
- }
19916
- else if (Array.isArray(options.style)) {
19917
- styles = styles.concat(options.style);
19918
- }
19919
- if (typeof options.styles === 'string') {
19920
- styles.push(options.styles);
19921
- }
19922
- else if (Array.isArray(options.styles)) {
19923
- styles = styles.concat(options.styles);
19924
- }
19925
- insertStyles(styles, document, el);
19926
- // now load any css files by path and add their content
19927
- // as <style>...</style> elements
19928
- let cssFiles = [];
19929
- if (typeof options.cssFile === 'string') {
19930
- cssFiles.push(options.cssFile);
19931
- }
19932
- else if (Array.isArray(options.cssFile)) {
19933
- cssFiles = cssFiles.concat(options.cssFile);
19934
- }
19935
- if (typeof options.cssFiles === 'string') {
19936
- cssFiles.push(options.cssFiles);
19937
- }
19938
- else if (Array.isArray(options.cssFiles)) {
19939
- cssFiles = cssFiles.concat(options.cssFiles);
19940
- }
19941
- return insertLocalCssFiles(cssFiles, document, el, options.log);
19942
- };
19943
19815
  function setupHooks(optionalCallback) {
19944
- // Consumed by the framework "mount" libs. A user might register their own mount in the scaffolded 'commands.js'
19945
- // file that is imported by e2e and component support files by default. We don't want CT side effects to run when e2e
19816
+ // We don't want CT side effects to run when e2e
19946
19817
  // testing so we early return.
19947
19818
  // System test to verify CT side effects do not pollute e2e: system-tests/test/e2e_with_mount_import_spec.ts
19948
19819
  if (Cypress.testingType !== 'component') {
@@ -19957,10 +19828,10 @@ function setupHooks(optionalCallback) {
19957
19828
  // @ts-ignore
19958
19829
  Cypress.on('test:before:run', () => {
19959
19830
  optionalCallback === null || optionalCallback === void 0 ? void 0 : optionalCallback();
19960
- cleanupStyles();
19961
19831
  });
19962
19832
  }
19963
19833
 
19834
+ /// <reference types="cypress" />
19964
19835
  const defaultOptions = [
19965
19836
  'vue',
19966
19837
  'extensions',
@@ -20027,6 +19898,10 @@ const resetStoreVM = (Vue, { store }) => {
20027
19898
  });
20028
19899
  return store;
20029
19900
  };
19901
+ const cleanup = () => {
19902
+ var _a;
19903
+ (_a = Cypress.vueWrapper) === null || _a === void 0 ? void 0 : _a.destroy();
19904
+ };
20030
19905
  /**
20031
19906
  * Direct Vue errors to the top error handler
20032
19907
  * where they will fail Cypress test
@@ -20040,15 +19915,6 @@ function failTestOnVueError(err, vm, info) {
20040
19915
  throw err;
20041
19916
  });
20042
19917
  }
20043
- function registerAutoDestroy($destroy) {
20044
- Cypress.on('test:before:run', () => {
20045
- $destroy();
20046
- });
20047
- }
20048
- enableAutoDestroy_1(registerAutoDestroy);
20049
- const injectStyles = (options) => {
20050
- return injectStylesBeforeElement(options, document, getContainerEl());
20051
- };
20052
19918
  /**
20053
19919
  * Extract the component name from the object passed to mount
20054
19920
  * @param componentOptions the compoennt passed to mount
@@ -20071,18 +19937,25 @@ function getComponentDisplayName(componentOptions) {
20071
19937
  }
20072
19938
  /**
20073
19939
  * Mounts a Vue component inside Cypress browser.
20074
- * @param {object} component imported from Vue file
19940
+ * @param {VueComponent} component imported from Vue file
19941
+ * @param {MountOptionsArgument} optionsOrProps used to pass options to component being mounted
19942
+ * @returns {Cypress.Chainable<{wrapper: Wrapper<T>, component: T}
20075
19943
  * @example
20076
- * import Greeting from './Greeting.vue'
20077
- * import { mount } from '@cypress/vue2'
20078
- * it('works', () => {
20079
- * // pass props, additional extensions, etc
20080
- * mount(Greeting, { ... })
20081
- * // use any Cypress command to test the component
20082
- * cy.get('#greeting').should('be.visible')
20083
- * })
19944
+ * import { mount } from '@cypress/vue'
19945
+ * import { Stepper } from './Stepper.vue'
19946
+ *
19947
+ * it('mounts', () => {
19948
+ * cy.mount(Stepper)
19949
+ * cy.get('[data-cy=increment]').click()
19950
+ * cy.get('[data-cy=counter]').should('have.text', '1')
19951
+ * })
19952
+ * @see {@link https://on.cypress.io/mounting-vue} for more details.
19953
+ *
20084
19954
  */
20085
19955
  const mount = (component, optionsOrProps = {}) => {
19956
+ checkForRemovedStyleOptions(optionsOrProps);
19957
+ // Remove last mounted component if cy.mount is called more than once in a test
19958
+ cleanup();
20086
19959
  const options = Cypress._.pick(optionsOrProps, defaultOptions);
20087
19960
  const props = Cypress._.omit(optionsOrProps, defaultOptions);
20088
19961
  const componentName = getComponentDisplayName(component);
@@ -20090,26 +19963,9 @@ const mount = (component, optionsOrProps = {}) => {
20090
19963
  return cy
20091
19964
  .window({
20092
19965
  log: false,
20093
- })
20094
- .then(() => {
20095
- const { style, stylesheets, stylesheet, styles, cssFiles, cssFile } = optionsOrProps;
20096
- injectStyles({
20097
- style,
20098
- stylesheets,
20099
- stylesheet,
20100
- styles,
20101
- cssFiles,
20102
- cssFile,
20103
- });
20104
19966
  })
20105
19967
  .then((win) => {
20106
- if (optionsOrProps.log !== false) {
20107
- Cypress.log({
20108
- name: 'mount',
20109
- message: [message],
20110
- }).snapshot('mounted').end();
20111
- }
20112
- const localVue = createLocalVue_1();
19968
+ const localVue = createLocalVue();
20113
19969
  // @ts-ignore
20114
19970
  win.Vue = localVue;
20115
19971
  localVue.config.errorHandler = failTestOnVueError;
@@ -20135,9 +19991,23 @@ const mount = (component, optionsOrProps = {}) => {
20135
19991
  registerGlobalComponents(localVue, options);
20136
19992
  props.attachTo = componentNode;
20137
19993
  const wrapper = localVue.extend(component);
20138
- const VTUWrapper = mount_1(wrapper, Object.assign({ localVue }, props));
19994
+ const VTUWrapper = mount$1(wrapper, Object.assign({ localVue }, props));
20139
19995
  Cypress.vue = VTUWrapper.vm;
20140
19996
  Cypress.vueWrapper = VTUWrapper;
19997
+ return {
19998
+ wrapper: VTUWrapper,
19999
+ component: VTUWrapper.vm,
20000
+ };
20001
+ })
20002
+ .then(() => {
20003
+ if (optionsOrProps.log !== false) {
20004
+ return Vue__default["default"].nextTick(() => {
20005
+ Cypress.log({
20006
+ name: 'mount',
20007
+ message: [message],
20008
+ });
20009
+ });
20010
+ }
20141
20011
  });
20142
20012
  };
20143
20013
  /**
@@ -20145,9 +20015,15 @@ const mount = (component, optionsOrProps = {}) => {
20145
20015
  * @example
20146
20016
  * import {mountCallback} from '@cypress/vue2'
20147
20017
  * beforeEach(mountVue(component, options))
20018
+ *
20019
+ * Removed as of Cypress 11.0.0.
20020
+ * @see https://on.cypress.io/migration-11-0-0-component-testing-updates
20148
20021
  */
20149
20022
  const mountCallback = (component, options) => {
20150
- return () => mount(component, options);
20023
+ return () => {
20024
+ // @ts-expect-error - undocumented API
20025
+ Cypress.utils.throwErrByPath('mount.mount_callback');
20026
+ };
20151
20027
  };
20152
20028
  // Side effects from "import { mount } from '@cypress/<my-framework>'" are annoying, we should avoid doing this
20153
20029
  // by creating an explicit function/import that the user can register in their 'component.js' support file,
@@ -20157,7 +20033,7 @@ const mountCallback = (component, options) => {
20157
20033
  // import { registerCT } from 'cypress/<my-framework>'
20158
20034
  // registerCT()
20159
20035
  // Note: This would be a breaking change
20160
- setupHooks();
20036
+ setupHooks(cleanup);
20161
20037
 
20162
20038
  exports.mount = mount;
20163
20039
  exports.mountCallback = mountCallback;