cypress 10.9.0 → 10.11.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.
@@ -1,3 +1,43 @@
1
+ # [@cypress/angular-v1.1.2](https://github.com/cypress-io/cypress/compare/@cypress/angular-v1.1.1...@cypress/angular-v1.1.2) (2022-10-11)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * 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))
7
+
8
+ # [@cypress/angular-v1.1.1](https://github.com/cypress-io/cypress/compare/@cypress/angular-v1.1.0...@cypress/angular-v1.1.1) (2022-10-04)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **angular:** call ngOnChanges after mount ([#23596](https://github.com/cypress-io/cypress/issues/23596)) ([670d438](https://github.com/cypress-io/cypress/commit/670d43830947c3ea93ef9fdc9c90932a817eb453))
14
+
15
+ # [@cypress/angular-v1.1.0](https://github.com/cypress-io/cypress/compare/@cypress/angular-v1.0.0...@cypress/angular-v1.1.0) (2022-09-28)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * angular 14.2 mount compilation error ([#23593](https://github.com/cypress-io/cypress/issues/23593)) ([2f337db](https://github.com/cypress-io/cypress/commit/2f337dbfa2bb212754c8fa82e3f4548a2f3a07a4))
21
+ * Fix missing `it.skip` function in Angular tests ([#23829](https://github.com/cypress-io/cypress/issues/23829)) ([64c0f45](https://github.com/cypress-io/cypress/commit/64c0f45182456bd43f4b64b2311e816dde615236))
22
+
23
+
24
+ ### Features
25
+
26
+ * adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8))
27
+
28
+ # [@cypress/angular-v1.1.0](https://github.com/cypress-io/cypress/compare/@cypress/angular-v1.0.0...@cypress/angular-v1.1.0) (2022-09-27)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * angular 14.2 mount compilation error ([#23593](https://github.com/cypress-io/cypress/issues/23593)) ([2f337db](https://github.com/cypress-io/cypress/commit/2f337dbfa2bb212754c8fa82e3f4548a2f3a07a4))
34
+ * Fix missing `it.skip` function in Angular tests ([#23829](https://github.com/cypress-io/cypress/issues/23829)) ([64c0f45](https://github.com/cypress-io/cypress/commit/64c0f45182456bd43f4b64b2311e816dde615236))
35
+
36
+
37
+ ### Features
38
+
39
+ * adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8))
40
+
1
41
  # [@cypress/angular-v1.1.0](https://github.com/cypress-io/cypress/compare/@cypress/angular-v1.0.0...@cypress/angular-v1.1.0) (2022-09-23)
2
42
 
3
43
 
@@ -8,7 +8,7 @@
8
8
  import 'zone.js';
9
9
  import 'zone.js/testing';
10
10
  import { CommonModule } from '@angular/common';
11
- import { Component, EventEmitter } from '@angular/core';
11
+ import { Injectable, Component, EventEmitter, SimpleChange, ErrorHandler } from '@angular/core';
12
12
  import { getTestBed, TestBed } from '@angular/core/testing';
13
13
  import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
14
14
 
@@ -95,6 +95,14 @@ window.Mocha['__zone_patch__'] = false;
95
95
  // Written up under https://github.com/angular/angular/issues/46297 but is not seeing movement
96
96
  // so we'll patch here pending a fix in that library
97
97
  globalThis.it.skip = globalThis.xit;
98
+ let CypressAngularErrorHandler = class CypressAngularErrorHandler {
99
+ handleError(error) {
100
+ throw error;
101
+ }
102
+ };
103
+ CypressAngularErrorHandler = __decorate([
104
+ Injectable()
105
+ ], CypressAngularErrorHandler);
98
106
  /**
99
107
  * Bootstraps the TestModuleMetaData passed to the TestBed
100
108
  *
@@ -110,6 +118,15 @@ function bootstrapModule(component, config) {
110
118
  if (!testModuleMetaData.imports) {
111
119
  testModuleMetaData.imports = [];
112
120
  }
121
+ if (!testModuleMetaData.providers) {
122
+ testModuleMetaData.providers = [];
123
+ }
124
+ // Replace default error handler since it will swallow uncaught exceptions.
125
+ // We want these to be uncaught so Cypress catches it and fails the test
126
+ testModuleMetaData.providers.push({
127
+ provide: ErrorHandler,
128
+ useClass: CypressAngularErrorHandler,
129
+ });
113
130
  // check if the component is a standalone component
114
131
  if (component.ɵcmp.standalone) {
115
132
  testModuleMetaData.imports.push(component);
@@ -198,6 +215,19 @@ function setupComponent(config, fixture) {
198
215
  }
199
216
  });
200
217
  }
218
+ // Manually call ngOnChanges when mounting components using the class syntax.
219
+ // This is necessary because we are assigning input values to the class directly
220
+ // on mount and therefore the ngOnChanges() lifecycle is not triggered.
221
+ if (component.ngOnChanges && config.componentProperties) {
222
+ const { componentProperties } = config;
223
+ const simpleChanges = Object.entries(componentProperties).reduce((acc, [key, value]) => {
224
+ acc[key] = new SimpleChange(null, value, true);
225
+ return acc;
226
+ }, {});
227
+ if (Object.keys(componentProperties).length > 0) {
228
+ component.ngOnChanges(simpleChanges);
229
+ }
230
+ }
201
231
  return component;
202
232
  }
203
233
  /**
@@ -8,6 +8,142 @@ It is used in:
8
8
 
9
9
  - [`@cypress/react`](https://github.com/cypress-io/cypress/tree/develop/npm/react)
10
10
  - [`@cypress/vue`](https://github.com/cypress-io/cypress/tree/develop/npm/vue)
11
+ - [`@cypress/svelte`](https://github.com/cypress-io/cypress/tree/develop/npm/svelte)
12
+ - [`@cypress/angular`](https://github.com/cypress-io/cypress/tree/develop/npm/angular)
13
+
14
+ ## What is a Mount Adapter?
15
+
16
+ All Component Tests require a component to be **mounted**. This is generally done with a custom command, `cy.mount` by default.
17
+
18
+
19
+ ### Requirements
20
+
21
+ All the functionality used to create the first party Mount adapters is available to support third parties adapters. At minimum, a Mount Adapter must:
22
+
23
+ - Receive a component as the first argument. This could be class, function etc - depends on the framework.
24
+ - Return a Cypress Chainable (for example using `cy.wrap`) that resolves whatever is idiomatic for your framework
25
+
26
+ In addition, we recommend that Mount Adapters:
27
+
28
+ - receive a second argument that extends `StyleOptions` from `@cypress/mount-utils`
29
+ - calls `injectStylesBeforeElement` from `@cypress/mount-utils` before mounting the component
30
+ - calls `setupHooks` to register the required lifecycle hooks for `@cypress/mount-utils` to work
31
+
32
+ This will let the user inject styles `<style>...</style>` and stylesheets `<link rel="stylesheet">`, which is very useful for developing components.
33
+
34
+ ### Example Mount Adapter: Web Components
35
+
36
+ Here's a simple yet realistic example of Mount Adapter targeting Web Components. It uses utilities from this package (`@cypress/mount-utils`) This is recommended, so your adapter behaves similar to the first party Mount Adapters.
37
+
38
+ ```ts
39
+ import {
40
+ ROOT_SELECTOR,
41
+ setupHooks,
42
+ injectStylesBeforeElement,
43
+ getContainerEl,
44
+ StyleOptions
45
+ } from "@cypress/mount-utils";
46
+
47
+ Cypress.on("run:start", () => {
48
+ // Consider doing a check to ensure your adapter only runs in Component Testing mode.
49
+ if (Cypress.testingType !== "component") {
50
+ return;
51
+ }
52
+
53
+ Cypress.on("test:before:run", () => {
54
+ // Do some cleanup from previous test - for example, clear the DOM.
55
+ getContainerEl().innerHTML = "";
56
+ });
57
+ });
58
+
59
+ function maybeRegisterComponent<T extends CustomElementConstructor>(
60
+ name: string,
61
+ webComponent: T
62
+ ) {
63
+ // Avoid double-registering a Web Component.
64
+ if (window.customElements.get(name)) {
65
+ return;
66
+ }
67
+
68
+ window.customElements.define(name, webComponent);
69
+ }
70
+
71
+ export function mount(
72
+ webComponent: CustomElementConstructor,
73
+ options?: Partial<StyleOptions>
74
+ ): Cypress.Chainable {
75
+ // Get root selector defined in `cypress/support.component-index.html
76
+ const $root = document.querySelector(ROOT_SELECTOR)!;
77
+
78
+ // Change to kebab-case to comply with Web Component naming convention
79
+ const name = webComponent.name
80
+ .replace(/([a-z0–9])([A-Z])/g, "$1-$2")
81
+ .toLowerCase();
82
+
83
+ /// Register Web Component
84
+ maybeRegisterComponent(name, webComponent);
85
+
86
+ // Inject user styles before mounting the component
87
+ injectStylesBeforeElement(options ?? {}, document, getContainerEl())
88
+
89
+ // Render HTML containing component.
90
+ $root.innerHTML = `<${name} id="root"></${name}>`;
91
+
92
+ // Log a messsage in the Command Log.
93
+ Cypress.log({
94
+ name: "mount",
95
+ message: [`<${name} ... />`],
96
+ });
97
+
98
+ // Return a `Cypress.Chainable` that returns whatever is idiomatic
99
+ // in the framework your mount adapter targets.
100
+ return cy.wrap(document.querySelector("#root"), { log: false });
101
+ }
102
+
103
+ // Setup Cypress lifecycle hooks. This tears down any styles
104
+ // injected by injectStylesBeforeElement, etc.
105
+ setupHooks();
106
+ ```
107
+
108
+ Usage:
109
+
110
+ ```ts
111
+ // User will generally register a `cy.mount` command in `cypress/support/component.js`:
112
+
113
+ import { mount } from '@package/cypress-web-components'
114
+
115
+ Cypress.Commands.add('mount', mount)
116
+
117
+ // Test
118
+ export class WebCounter extends HTMLElement {
119
+ constructor() {
120
+ super();
121
+ }
122
+
123
+ connectedCallback() {
124
+ this.innerHTML = `
125
+ <div>
126
+ <button>Counter</button>
127
+ </div>`;
128
+ }
129
+ }
130
+
131
+
132
+ describe('web-component.cy.ts', () => {
133
+ it('playground', () => {
134
+ cy.mount(WebCounter, {
135
+ styles: `
136
+ button {
137
+ background: lightblue;
138
+ color: white;
139
+ }
140
+ `
141
+ })
142
+ })
143
+ })
144
+ ```
145
+
146
+ For more robust, production ready examples, check out our first party adapters.
11
147
 
12
148
  ## Compatibility
13
149
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cypress",
3
- "version": "10.9.0",
3
+ "version": "10.11.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": "a75d3ec81f3405db6721a89875d89cdca0109013",
122
- "commitDate": "2022-09-27T02:16:48.000Z",
121
+ "commitSha": "75cce8187c5b888151bf06748ec03d7abf6ddfd5",
122
+ "commitDate": "2022-10-24T23:05:58.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,3 +1,10 @@
1
+ # [@cypress/react18-v1.1.1](https://github.com/cypress-io/cypress/compare/@cypress/react18-v1.1.0...@cypress/react18-v1.1.1) (2022-10-13)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * cypress/react18 rerender ([#23360](https://github.com/cypress-io/cypress/issues/23360)) ([8b8f20e](https://github.com/cypress-io/cypress/commit/8b8f20eec77d4c0a704aee7f7077dc92dbafb93f))
7
+
1
8
  # [@cypress/react18-v1.1.0](https://github.com/cypress-io/cypress/compare/@cypress/react18-v1.0.1...@cypress/react18-v1.1.0) (2022-08-30)
2
9
 
3
10
 
@@ -1,3 +1,11 @@
1
+ # [@cypress/svelte-v1.0.1](https://github.com/cypress-io/cypress/compare/@cypress/svelte-v1.0.0...@cypress/svelte-v1.0.1) (2022-09-29)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * release svelte ([b86403f](https://github.com/cypress-io/cypress/commit/b86403fcbcc85ce5be1ca96bbf42357dd24c07dd))
7
+ * **svelte:** default mount log to true ([#23771](https://github.com/cypress-io/cypress/issues/23771)) ([96b03ab](https://github.com/cypress-io/cypress/commit/96b03abc74cd7b27ef4bbd9b66d9464c1f9fc2f2))
8
+
1
9
  # @cypress/svelte-v1.0.0 (2022-08-30)
2
10
 
3
11
 
@@ -60,7 +60,7 @@ declare namespace CypressCommandLine {
60
60
  */
61
61
  headless: boolean
62
62
  /**
63
- * Specify your secret record key
63
+ * Specify your secret Record Key
64
64
  */
65
65
  key: string
66
66
  /**
@@ -641,12 +641,6 @@ declare namespace Cypress {
641
641
  */
642
642
  off: Actions
643
643
 
644
- /**
645
- * Used to import dependencies within the cy.origin() callback
646
- * @see https://on.cypress.io/origin
647
- */
648
- require: (id: string) => any
649
-
650
644
  /**
651
645
  * Trigger action
652
646
  * @private
@@ -2814,12 +2808,32 @@ declare namespace Cypress {
2814
2808
  */
2815
2809
  supportFile: string | false
2816
2810
  /**
2817
- * The test isolation level applied to ensure a clean slate between tests.
2818
- * - legacy - resets/clears aliases, intercepts, clock, viewport, cookies, and local storage before each test.
2819
- * - strict - applies all resets/clears from legacy, plus clears the page by visiting 'about:blank' to ensure clean app state before each test.
2820
- * @default "legacy", however, when experimentalSessionAndOrigin=true, the default is "strict"
2811
+ * The test isolation ensures a clean browser context between tests. This option is only available when
2812
+ * `experimentalSessionAndOrigin=true`.
2813
+ *
2814
+ * Cypress will always reset/clear aliases, intercepts, clock, and viewport before each test
2815
+ * to ensure a clean test slate; i.e. this configuration only impacts the browser context.
2816
+ *
2817
+ * Note: the [`cy.session()`](https://on.cypress.io/session) command will inherent this value to determine whether
2818
+ * or not the page is cleared when the command executes. This command is only available in end-to-end testing.
2819
+ *
2820
+ * - on - The page is cleared before each test. Cookies, local storage and session storage in all domains are cleared
2821
+ * before each test. The `cy.session()` command will also clear the page and current browser context when creating
2822
+ * or restoring the browser session.
2823
+ * - off - The current browser state will persist between tests. The page does not clear before the test and cookies, local
2824
+ * storage and session storage will be available in the next test. The `cy.session()` command will only clear the
2825
+ * current browser context when creating or restoring the browser session - the current page will not clear.
2826
+ *
2827
+ * Tradeoffs:
2828
+ * Turning test isolation off may improve performance of end-to-end tests, however, previous tests could impact the
2829
+ * browser state of the next test and cause inconsistency when using .only(). Be mindful to write isolated tests when
2830
+ * test isolation is off. If a test in the suite impacts the state of other tests and it were to fail, you could see
2831
+ * misleading errors in later tests which makes debugging clunky. See the [documentation](https://on.cypress.io/test-isolation)
2832
+ * for more information.
2833
+ *
2834
+ * @default null, when experimentalSessionAndOrigin=false. The default is 'on' when experimentalSessionAndOrigin=true.
2821
2835
  */
2822
- testIsolation: 'legacy' | 'strict'
2836
+ testIsolation: null | 'on' | 'off'
2823
2837
  /**
2824
2838
  * Path to folder where videos will be saved after a headless or CI run
2825
2839
  * @default "cypress/videos"
package/vue/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # [@cypress/vue-v4.2.1](https://github.com/cypress-io/cypress/compare/@cypress/vue-v4.2.0...@cypress/vue-v4.2.1) (2022-10-13)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * fix regression in npm/vue ([#23954](https://github.com/cypress-io/cypress/issues/23954)) ([78779a2](https://github.com/cypress-io/cypress/commit/78779a2db13ca6555a6b830dbabeefd3d37bbfe5))
7
+ * **npm/vue:** update types ([#23890](https://github.com/cypress-io/cypress/issues/23890)) ([eb8ae02](https://github.com/cypress-io/cypress/commit/eb8ae02b61304d034136f7627da1ab23537e3ba4))
8
+
1
9
  # [@cypress/vue-v4.2.0](https://github.com/cypress-io/cypress/compare/@cypress/vue-v4.1.0...@cypress/vue-v4.2.0) (2022-08-30)
2
10
 
3
11
 
@@ -13856,8 +13856,8 @@ function mount(componentOptions, options = {}) {
13856
13856
  });
13857
13857
  }
13858
13858
  /**
13859
- * Extract the compoennt name from the object passed to mount
13860
- * @param componentOptions the compoennt passed to mount
13859
+ * Extract the component name from the object passed to mount
13860
+ * @param componentOptions the component passed to mount
13861
13861
  * @returns name of the component
13862
13862
  */
13863
13863
  function getComponentDisplayName(componentOptions) {
@@ -13833,8 +13833,8 @@ function mount(componentOptions, options = {}) {
13833
13833
  });
13834
13834
  }
13835
13835
  /**
13836
- * Extract the compoennt name from the object passed to mount
13837
- * @param componentOptions the compoennt passed to mount
13836
+ * Extract the component name from the object passed to mount
13837
+ * @param componentOptions the component passed to mount
13838
13838
  * @returns name of the component
13839
13839
  */
13840
13840
  function getComponentDisplayName(componentOptions) {
package/vue2/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # [@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)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * 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))
7
+
8
+
1
9
  # [@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)
2
10
 
3
11
 
@@ -20034,11 +20034,11 @@ const resetStoreVM = (Vue, { store }) => {
20034
20034
  * @see https://github.com/cypress-io/cypress/issues/7910
20035
20035
  */
20036
20036
  function failTestOnVueError(err, vm, info) {
20037
- console.error(`Vue error`);
20038
- console.error(err);
20039
- console.error('component:', vm);
20040
- console.error('info:', info);
20041
- window.top.onerror(err);
20037
+ // Vue 2 try catches the error-handler so push the error to be caught outside
20038
+ // of the handler.
20039
+ setTimeout(() => {
20040
+ throw err;
20041
+ });
20042
20042
  }
20043
20043
  function registerAutoDestroy($destroy) {
20044
20044
  Cypress.on('test:before:run', () => {
@@ -20026,11 +20026,11 @@ const resetStoreVM = (Vue, { store }) => {
20026
20026
  * @see https://github.com/cypress-io/cypress/issues/7910
20027
20027
  */
20028
20028
  function failTestOnVueError(err, vm, info) {
20029
- console.error(`Vue error`);
20030
- console.error(err);
20031
- console.error('component:', vm);
20032
- console.error('info:', info);
20033
- window.top.onerror(err);
20029
+ // Vue 2 try catches the error-handler so push the error to be caught outside
20030
+ // of the handler.
20031
+ setTimeout(() => {
20032
+ throw err;
20033
+ });
20034
20034
  }
20035
20035
  function registerAutoDestroy($destroy) {
20036
20036
  Cypress.on('test:before:run', () => {