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
@@ -1,4 +1,9 @@
1
1
  export const ROOT_SELECTOR = '[data-cy-root]';
2
+ /**
3
+ * Gets the root element used to mount the component.
4
+ * @returns {HTMLElement} The root element
5
+ * @throws {Error} If the root element is not found
6
+ */
2
7
  export const getContainerEl = () => {
3
8
  const el = document.querySelector(ROOT_SELECTOR);
4
9
  if (el) {
@@ -6,122 +11,19 @@ export const getContainerEl = () => {
6
11
  }
7
12
  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.`);
8
13
  };
9
- /**
10
- * Remove any style or extra link elements from the iframe placeholder
11
- * left from any previous test
12
- *
13
- */
14
- export function cleanupStyles() {
15
- const styles = document.body.querySelectorAll('[data-cy=injected-style-tag]');
16
- styles.forEach((styleElement) => {
17
- if (styleElement.parentElement) {
18
- styleElement.parentElement.removeChild(styleElement);
14
+ export function checkForRemovedStyleOptions(mountingOptions) {
15
+ for (const key of ['cssFile', 'cssFiles', 'style', 'styles', 'stylesheet', 'stylesheets']) {
16
+ if (mountingOptions[key]) {
17
+ Cypress.utils.throwErrByPath('mount.removed_style_mounting_options', key);
19
18
  }
20
- });
21
- const links = document.body.querySelectorAll('[data-cy=injected-stylesheet]');
22
- links.forEach((link) => {
23
- if (link.parentElement) {
24
- link.parentElement.removeChild(link);
25
- }
26
- });
27
- }
28
- /**
29
- * Insert links to external style resources.
30
- */
31
- function insertStylesheets(stylesheets, document, el) {
32
- stylesheets.forEach((href) => {
33
- const link = document.createElement('link');
34
- link.type = 'text/css';
35
- link.rel = 'stylesheet';
36
- link.href = href;
37
- link.dataset.cy = 'injected-stylesheet';
38
- document.body.insertBefore(link, el);
39
- });
40
- }
41
- /**
42
- * Inserts a single stylesheet element
43
- */
44
- function insertStyles(styles, document, el) {
45
- styles.forEach((style) => {
46
- const styleElement = document.createElement('style');
47
- styleElement.dataset.cy = 'injected-style-tag';
48
- styleElement.appendChild(document.createTextNode(style));
49
- document.body.insertBefore(styleElement, el);
50
- });
51
- }
52
- function insertSingleCssFile(cssFilename, document, el, log) {
53
- return cy.readFile(cssFilename, { log }).then((css) => {
54
- const style = document.createElement('style');
55
- style.appendChild(document.createTextNode(css));
56
- document.body.insertBefore(style, el);
57
- });
58
- }
59
- /**
60
- * Reads the given CSS file from local file system
61
- * and adds the loaded style text as an element.
62
- */
63
- function insertLocalCssFiles(cssFilenames, document, el, log) {
64
- return Cypress.Promise.mapSeries(cssFilenames, (cssFilename) => {
65
- return insertSingleCssFile(cssFilename, document, el, log);
66
- });
19
+ }
67
20
  }
68
21
  /**
69
- * Injects custom style text or CSS file or 3rd party style resources
70
- * into the given document.
22
+ * Utility function to register CT side effects and run cleanup code during the "test:before:run" Cypress hook
23
+ * @param optionalCallback Callback to be called before the next test runs
71
24
  */
72
- export const injectStylesBeforeElement = (options, document, el) => {
73
- if (!el)
74
- return;
75
- // first insert all stylesheets as Link elements
76
- let stylesheets = [];
77
- if (typeof options.stylesheet === 'string') {
78
- stylesheets.push(options.stylesheet);
79
- }
80
- else if (Array.isArray(options.stylesheet)) {
81
- stylesheets = stylesheets.concat(options.stylesheet);
82
- }
83
- if (typeof options.stylesheets === 'string') {
84
- options.stylesheets = [options.stylesheets];
85
- }
86
- if (options.stylesheets) {
87
- stylesheets = stylesheets.concat(options.stylesheets);
88
- }
89
- insertStylesheets(stylesheets, document, el);
90
- // insert any styles as <style>...</style> elements
91
- let styles = [];
92
- if (typeof options.style === 'string') {
93
- styles.push(options.style);
94
- }
95
- else if (Array.isArray(options.style)) {
96
- styles = styles.concat(options.style);
97
- }
98
- if (typeof options.styles === 'string') {
99
- styles.push(options.styles);
100
- }
101
- else if (Array.isArray(options.styles)) {
102
- styles = styles.concat(options.styles);
103
- }
104
- insertStyles(styles, document, el);
105
- // now load any css files by path and add their content
106
- // as <style>...</style> elements
107
- let cssFiles = [];
108
- if (typeof options.cssFile === 'string') {
109
- cssFiles.push(options.cssFile);
110
- }
111
- else if (Array.isArray(options.cssFile)) {
112
- cssFiles = cssFiles.concat(options.cssFile);
113
- }
114
- if (typeof options.cssFiles === 'string') {
115
- cssFiles.push(options.cssFiles);
116
- }
117
- else if (Array.isArray(options.cssFiles)) {
118
- cssFiles = cssFiles.concat(options.cssFiles);
119
- }
120
- return insertLocalCssFiles(cssFiles, document, el, options.log);
121
- };
122
25
  export function setupHooks(optionalCallback) {
123
- // Consumed by the framework "mount" libs. A user might register their own mount in the scaffolded 'commands.js'
124
- // file that is imported by e2e and component support files by default. We don't want CT side effects to run when e2e
26
+ // We don't want CT side effects to run when e2e
125
27
  // testing so we early return.
126
28
  // System test to verify CT side effects do not pollute e2e: system-tests/test/e2e_with_mount_import_spec.ts
127
29
  if (Cypress.testingType !== 'component') {
@@ -136,6 +38,25 @@ export function setupHooks(optionalCallback) {
136
38
  // @ts-ignore
137
39
  Cypress.on('test:before:run', () => {
138
40
  optionalCallback === null || optionalCallback === void 0 ? void 0 : optionalCallback();
139
- cleanupStyles();
140
41
  });
141
42
  }
43
+ /**
44
+ * Remove any style or extra link elements from the iframe placeholder
45
+ * left from any previous test
46
+ *
47
+ * Removed as of Cypress 11.0.0
48
+ * @see https://on.cypress.io/migration-11-0-0-component-testing-updates
49
+ */
50
+ export function cleanupStyles() {
51
+ Cypress.utils.throwErrByPath('mount.cleanup_styles');
52
+ }
53
+ /**
54
+ * Injects custom style text or CSS file or 3rd party style resources
55
+ * into the given document.
56
+ *
57
+ * Removed as of Cypress 11.0.0.
58
+ * @see https://on.cypress.io/migration-11-0-0-component-testing-updates
59
+ */
60
+ export const injectStylesBeforeElement = (options, document, el) => {
61
+ Cypress.utils.throwErrByPath('mount.inject_styles_before_element');
62
+ };
@@ -15,6 +15,7 @@
15
15
  "@rollup/plugin-commonjs": "^17.1.0",
16
16
  "@rollup/plugin-node-resolve": "^11.1.1",
17
17
  "rollup": "^2.38.5",
18
+ "rollup-plugin-dts": "^4.2.3",
18
19
  "rollup-plugin-typescript2": "^0.29.0",
19
20
  "typescript": "^4.7.4"
20
21
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cypress",
3
- "version": "10.10.0",
3
+ "version": "11.0.0",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "postinstall": "node index.js --exec install",
@@ -118,11 +118,11 @@
118
118
  },
119
119
  "buildInfo": {
120
120
  "commitBranch": "develop",
121
- "commitSha": "53eef4fbd7e1caf32f0183cadbc0e4cf05524c34",
122
- "commitDate": "2022-10-11T14:21:32.000Z",
121
+ "commitSha": "2513beac307e95267ab736a93a39cd1cd1280506",
122
+ "commitDate": "2022-11-08T20:29:47.000Z",
123
123
  "stable": true
124
124
  },
125
- "description": "Cypress.io end to end testing tool",
125
+ "description": "Cypress is a next generation front end testing tool built for the modern web",
126
126
  "homepage": "https://github.com/cypress-io/cypress",
127
127
  "license": "MIT",
128
128
  "bugs": {
@@ -140,6 +140,7 @@
140
140
  "e2e",
141
141
  "end-to-end",
142
142
  "integration",
143
+ "component",
143
144
  "mocks",
144
145
  "runner",
145
146
  "spies",
@@ -1,72 +1,29 @@
1
- # [@cypress/react-v6.2.0](https://github.com/cypress-io/cypress/compare/@cypress/react-v6.1.1...@cypress/react-v6.2.0) (2022-10-11)
1
+ # [@cypress/react-v7.0.1](https://github.com/cypress-io/cypress/compare/@cypress/react-v7.0.0...@cypress/react-v7.0.1) (2022-11-08)
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/react-v6.2.0](https://github.com/cypress-io/cypress/compare/@cypress/react-v6.1.1...@cypress/react-v6.2.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/react-v6.2.0](https://github.com/cypress-io/cypress/compare/@cypress/react-v6.1.1...@cypress/react-v6.2.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/react-v6.2.0](https://github.com/cypress-io/cypress/compare/@cypress/react-v6.1.1...@cypress/react-v6.2.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/react-v6.2.0](https://github.com/cypress-io/cypress/compare/@cypress/react-v6.1.1...@cypress/react-v6.2.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/react-v6.2.0](https://github.com/cypress-io/cypress/compare/@cypress/react-v6.1.1...@cypress/react-v6.2.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))
42
-
43
- # [@cypress/react-v6.2.0](https://github.com/cypress-io/cypress/compare/@cypress/react-v6.1.1...@cypress/react-v6.2.0) (2022-09-30)
44
-
45
-
46
- ### Features
47
-
48
- * 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
49
5
 
50
- # [@cypress/react-v6.2.0](https://github.com/cypress-io/cypress/compare/@cypress/react-v6.1.1...@cypress/react-v6.2.0) (2022-09-30)
6
+ * make component derived info not throw ([#24571](https://github.com/cypress-io/cypress/issues/24571)) ([838dd4f](https://github.com/cypress-io/cypress/commit/838dd4fa2e0ec56633d0af2faf10a47d190b5594))
51
7
 
8
+ # [@cypress/react-v7.0.0](https://github.com/cypress-io/cypress/compare/@cypress/react-v6.2.1...@cypress/react-v7.0.0) (2022-11-07)
52
9
 
53
- ### Features
54
10
 
55
- * adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8))
11
+ ### Bug Fixes
56
12
 
57
- # [@cypress/react-v6.2.0](https://github.com/cypress-io/cypress/compare/@cypress/react-v6.1.1...@cypress/react-v6.2.0) (2022-09-30)
13
+ * 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))
14
+ * remove some CT functions and props ([#24419](https://github.com/cypress-io/cypress/issues/24419)) ([294985f](https://github.com/cypress-io/cypress/commit/294985f8b3e0fa00ed66d25f88c8814603766074))
58
15
 
59
16
 
60
- ### Features
17
+ ### BREAKING CHANGES
61
18
 
62
- * adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8))
19
+ * remove last mounted component upon subsequent mount calls of mount
63
20
 
64
- # [@cypress/react-v6.2.0](https://github.com/cypress-io/cypress/compare/@cypress/react-v6.1.1...@cypress/react-v6.2.0) (2022-09-29)
21
+ # [@cypress/react-v6.2.1](https://github.com/cypress-io/cypress/compare/@cypress/react-v6.2.0...@cypress/react-v6.2.1) (2022-11-01)
65
22
 
66
23
 
67
- ### Features
24
+ ### Bug Fixes
68
25
 
69
- * adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8))
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))
70
27
 
71
28
  # [@cypress/react-v6.2.0](https://github.com/cypress-io/cypress/compare/@cypress/react-v6.1.1...@cypress/react-v6.2.0) (2022-08-30)
72
29
 
package/react/README.md CHANGED
@@ -31,8 +31,6 @@ For more information, please check the official docs for [running Cypress](https
31
31
 
32
32
  - `mount` is the most important function, allows to mount a given React component as a mini web application and interact with it using Cypress commands
33
33
  - `createMount` factory function that creates new `mount` function with default options
34
- - `unmount` removes previously mounted component, mostly useful to test how the component cleans up after itself
35
- - `mountHook` mounts a given React Hook in a test component for full testing, see `hooks` example
36
34
 
37
35
  ## Examples
38
36
 
@@ -65,20 +63,7 @@ it('looks right', () => {
65
63
  })
66
64
  ```
67
65
 
68
- ### Extra styles
69
-
70
- You can pass additional styles, css files and external stylesheets to load, see [docs/styles.md](./docs/styles.md) for the full list of options.
71
-
72
- ```js
73
- const todo = {
74
- id: '123',
75
- title: 'Write more tests',
76
- }
77
- mount(<Todo todo={todo} />, {
78
- stylesheets: [
79
- 'https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.2/css/bulma.css',
80
- ],
81
- })
66
+ See [docs/styles.md](./docs/styles.md) for full list of options.
82
67
  ```
83
68
 
84
69
  You may also specify the `ReactDOM` package to use. This can be useful in complex monorepo setups that have different versions of React and React DOM installed. If you see an error relating to [mismatching versions of React or React DOM](https://reactjs.org/warnings/invalid-hook-call-warning.html#mismatching-versions-of-react-and-react-dom), this may be the solution. You can do this using the `ReactDom` option:
@@ -87,12 +72,7 @@ You may also specify the `ReactDOM` package to use. This can be useful in comple
87
72
  // if you have multiple versions of ReactDom in your monorepo
88
73
  import ReactDom from 'react-dom'
89
74
 
90
- mount(<Todo todo={todo} />, {
91
- stylesheets: [
92
- 'https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.2/css/bulma.css',
93
- ],
94
- ReactDom
95
- })
75
+ mount(<Todo todo={todo} />, { reactDom: ReactDom })
96
76
  ```
97
77
 
98
78
  ## Compatibility