cypress 10.11.0 → 11.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. package/angular/CHANGELOG.md +20 -0
  2. package/angular/README.md +2 -77
  3. package/angular/dist/index.d.ts +124 -1
  4. package/angular/dist/index.js +59 -59
  5. package/lib/cli.js +15 -1
  6. package/lib/tasks/download.js +3 -7
  7. package/lib/util.js +2 -2
  8. package/mount-utils/CHANGELOG.md +14 -0
  9. package/mount-utils/README.md +7 -24
  10. package/mount-utils/dist/index.d.ts +25 -39
  11. package/mount-utils/dist/index.js +33 -112
  12. package/mount-utils/package.json +1 -0
  13. package/package.json +3 -3
  14. package/react/CHANGELOG.md +27 -0
  15. package/react/README.md +2 -107
  16. package/react/dist/cypress-react.cjs.js +92 -219
  17. package/react/dist/cypress-react.esm-bundler.js +92 -220
  18. package/react/dist/index.d.ts +111 -4
  19. package/react18/CHANGELOG.md +13 -0
  20. package/react18/README.md +7 -0
  21. package/react18/dist/cypress-react.cjs.js +117 -180
  22. package/react18/dist/cypress-react.esm-bundler.js +103 -167
  23. package/react18/dist/index.d.ts +78 -6
  24. package/react18/package.json +1 -0
  25. package/svelte/CHANGELOG.md +20 -0
  26. package/svelte/README.md +1 -69
  27. package/svelte/dist/cypress-svelte.cjs.js +19 -114
  28. package/svelte/dist/cypress-svelte.esm-bundler.js +19 -114
  29. package/svelte/dist/index.d.ts +201 -1
  30. package/types/cypress.d.ts +18 -10
  31. package/vue/CHANGELOG.md +34 -0
  32. package/vue/README.md +2 -76
  33. package/vue/dist/cypress-vue.cjs.js +68 -151
  34. package/vue/dist/cypress-vue.esm-bundler.js +68 -151
  35. package/vue/dist/index.d.ts +1352 -104
  36. package/vue/package.json +1 -1
  37. package/vue2/CHANGELOG.md +27 -0
  38. package/vue2/README.md +2 -72
  39. package/vue2/dist/cypress-vue2.cjs.js +87 -211
  40. package/vue2/dist/cypress-vue2.esm-bundler.js +86 -210
  41. package/vue2/dist/index.d.ts +341 -172
  42. package/vue2/package.json +1 -3
  43. package/angular/dist/mount.d.ts +0 -112
  44. package/react/dist/createMount.d.ts +0 -31
  45. package/react/dist/getDisplayName.d.ts +0 -8
  46. package/react/dist/mount.d.ts +0 -8
  47. package/react/dist/mountHook.d.ts +0 -12
  48. package/react/dist/types.d.ts +0 -45
  49. package/svelte/dist/mount.d.ts +0 -30
  50. package/vue/dist/@vue/test-utils/baseWrapper.d.ts +0 -63
  51. package/vue/dist/@vue/test-utils/components/RouterLinkStub.d.ts +0 -21
  52. package/vue/dist/@vue/test-utils/config.d.ts +0 -30
  53. package/vue/dist/@vue/test-utils/constants/dom-events.d.ts +0 -900
  54. package/vue/dist/@vue/test-utils/createDomEvent.d.ts +0 -9
  55. package/vue/dist/@vue/test-utils/domWrapper.d.ts +0 -18
  56. package/vue/dist/@vue/test-utils/emit.d.ts +0 -5
  57. package/vue/dist/@vue/test-utils/errorWrapper.d.ts +0 -1
  58. package/vue/dist/@vue/test-utils/index.d.ts +0 -11
  59. package/vue/dist/@vue/test-utils/interfaces/wrapperLike.d.ts +0 -56
  60. package/vue/dist/@vue/test-utils/mount.d.ts +0 -35
  61. package/vue/dist/@vue/test-utils/stubs.d.ts +0 -22
  62. package/vue/dist/@vue/test-utils/types.d.ts +0 -125
  63. package/vue/dist/@vue/test-utils/utils/autoUnmount.d.ts +0 -5
  64. package/vue/dist/@vue/test-utils/utils/compileSlots.d.ts +0 -2
  65. package/vue/dist/@vue/test-utils/utils/componentName.d.ts +0 -4
  66. package/vue/dist/@vue/test-utils/utils/find.d.ts +0 -10
  67. package/vue/dist/@vue/test-utils/utils/flushPromises.d.ts +0 -1
  68. package/vue/dist/@vue/test-utils/utils/getRootNodes.d.ts +0 -2
  69. package/vue/dist/@vue/test-utils/utils/isElement.d.ts +0 -1
  70. package/vue/dist/@vue/test-utils/utils/isElementVisible.d.ts +0 -6
  71. package/vue/dist/@vue/test-utils/utils/matchName.d.ts +0 -1
  72. package/vue/dist/@vue/test-utils/utils/stringifyNode.d.ts +0 -1
  73. package/vue/dist/@vue/test-utils/utils/vueCompatSupport.d.ts +0 -8
  74. package/vue/dist/@vue/test-utils/utils/vueShared.d.ts +0 -3
  75. package/vue/dist/@vue/test-utils/utils.d.ts +0 -13
  76. package/vue/dist/@vue/test-utils/vueWrapper.d.ts +0 -35
  77. package/vue/dist/@vue/test-utils/wrapperFactory.d.ts +0 -14
@@ -1,3 +1,23 @@
1
+ # [@cypress/angular-v2.0.1](https://github.com/cypress-io/cypress/compare/@cypress/angular-v2.0.0...@cypress/angular-v2.0.1) (2022-11-08)
2
+
3
+
4
+ ### Bug Fixes
5
+
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))
7
+
8
+ # [@cypress/angular-v2.0.0](https://github.com/cypress-io/cypress/compare/@cypress/angular-v1.1.2...@cypress/angular-v2.0.0) (2022-11-07)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * possibility to override global services in Angular component tests ([#24394](https://github.com/cypress-io/cypress/issues/24394)) ([54d2853](https://github.com/cypress-io/cypress/commit/54d285321723450920e0f1d50374c4bd0590e72a))
14
+ * 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))
15
+
16
+
17
+ ### BREAKING CHANGES
18
+
19
+ * remove last mounted component upon subsequent mount calls of mount
20
+
1
21
  # [@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
22
 
3
23
 
package/angular/README.md CHANGED
@@ -1,85 +1,10 @@
1
1
  # @cypress/angular
2
2
 
3
- Mount Angular components in the open source [Cypress.io](https://www.cypress.io/) test runner **v7.0.0+**
4
-
5
- > **Note:** This package is bundled with the `cypress` package and should not need to be installed separately. See the [Angular Component Testing Docs](https://docs.cypress.io/guides/component-testing/quickstart-angular#Configuring-Component-Testing) for mounting Angular components. Installing and importing `mount` from `@cypress/angular` should only be used for advanced use-cases.
6
-
7
- ## Install
8
-
9
- - Requires Cypress v7.0.0 or later
10
- - Requires [Node](https://nodejs.org/en/) version 12 or above
11
-
12
- ```sh
13
- npm install --save-dev @cypress/angular
14
- ```
15
-
16
- ## Run
17
-
18
- Open cypress test runner
19
- ```
20
- npx cypress open --component
21
- ```
22
-
23
- If you need to run test in CI
24
- ```
25
- npx cypress run --component
26
- ```
27
-
28
- For more information, please check the official docs for [running Cypress](https://on.cypress.io/guides/getting-started/opening-the-app#Quick-Configuration) and for [component testing](https://on.cypress.io/guides/component-testing/writing-your-first-component-test).
29
-
30
- ## API
31
-
32
- - `mount` is the most important function, allows to mount a given Angular component as a mini web application and interact with it using Cypress commands
33
- - `MountConfig` Configuration used to configure your test
34
- - `createOutputSpy` factory function that creates new EventEmitter for your component and spies on it's `emit` method.
35
-
36
- ## Examples
37
-
38
- ```ts
39
- import { mount } from '@cypress/angular'
40
- import { HelloWorldComponent } from './hello-world.component'
41
-
42
- describe('HelloWorldComponent', () => {
43
- it('works', () => {
44
- mount(HelloWorldComponent)
45
- // now use standard Cypress commands
46
- cy.contains('Hello World!').should('be.visible')
47
- })
48
- })
49
- ```
50
-
51
- ```ts
52
- import { mount } from '@cypress/angular'
53
- import { HelloWorldComponent } from './hello-world.component'
54
-
55
- describe('HelloWorldComponent', () => {
56
- it('works', () => {
57
- mount('<app-hello-world></app-hello-world>', {
58
- declarations: [HelloWorldComponent]
59
- })
60
- // now use standard Cypress commands
61
- cy.contains('Hello World!').should('be.visible')
62
- })
63
- })
64
- ```
65
-
66
- Look at the examples in [cypress-component-testing-apps](https://github.com/cypress-io/cypress-component-testing-apps) repo. Here in the `angular` and `angular-standalone` folders are the two example applications showing various testing scenarios.
67
-
68
-
69
- ## Compatibility
70
-
71
- | @cypress/angular | cypress |
72
- | -------------- | ------- |
73
- | >= v1 | >= v10.5 |
3
+ Mount Angular components in the open source [Cypress.io](https://www.cypress.io/) test runner
74
4
 
5
+ > **Note:** This package is bundled with the `cypress` package and should not need to be installed separately. See the [Angular Component Testing Docs](https://docs.cypress.io/guides/component-testing/angular/overview) for mounting Angular components. Installing and importing `mount` from `@cypress/angular` should only be done for advanced use-cases.
75
6
  ## Development
76
7
 
77
8
  Run `yarn build` to compile and sync packages to the `cypress` cli package.
78
9
 
79
- ## License
80
-
81
- [![license](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/cypress-io/cypress/blob/develop/LICENSE)
82
-
83
- This project is licensed under the terms of the [MIT license](/LICENSE).
84
-
85
10
  ## [Changelog](./CHANGELOG.md)
@@ -1 +1,124 @@
1
- export * from './mount';
1
+ /// <reference types="cypress" />
2
+
3
+ import { Type } from '@angular/core';
4
+ import { TestModuleMetadata, ComponentFixture } from '@angular/core/testing';
5
+
6
+ /**
7
+ * Additional module configurations needed while mounting the component, like
8
+ * providers, declarations, imports and even component @Inputs()
9
+ *
10
+ *
11
+ * @interface MountConfig
12
+ * @see https://angular.io/api/core/testing/TestModuleMetadata
13
+ */
14
+ interface MountConfig<T> extends TestModuleMetadata {
15
+ /**
16
+ * @memberof MountConfig
17
+ * @description flag to automatically create a cy.spy() for every component @Output() property
18
+ * @example
19
+ * export class ButtonComponent {
20
+ * @Output clicked = new EventEmitter()
21
+ * }
22
+ *
23
+ * cy.mount(ButtonComponent, { autoSpyOutputs: true })
24
+ * cy.get('@clickedSpy).should('have.been.called')
25
+ */
26
+ autoSpyOutputs?: boolean;
27
+ /**
28
+ * @memberof MountConfig
29
+ * @description flag defaulted to true to automatically detect changes in your components
30
+ */
31
+ autoDetectChanges?: boolean;
32
+ /**
33
+ * @memberof MountConfig
34
+ * @example
35
+ * import { ButtonComponent } from 'button/button.component'
36
+ * it('renders a button with Save text', () => {
37
+ * cy.mount(ButtonComponent, { componentProperties: { text: 'Save' }})
38
+ * cy.get('button').contains('Save')
39
+ * })
40
+ *
41
+ * it('renders a button with a cy.spy() replacing EventEmitter', () => {
42
+ * cy.mount(ButtonComponent, {
43
+ * componentProperties: {
44
+ * clicked: cy.spy().as('mySpy)
45
+ * }
46
+ * })
47
+ * cy.get('button').click()
48
+ * cy.get('@mySpy').should('have.been.called')
49
+ * })
50
+ */
51
+ componentProperties?: Partial<{
52
+ [P in keyof T]: T[P];
53
+ }>;
54
+ }
55
+ /**
56
+ * Type that the `mount` function returns
57
+ * @type MountResponse<T>
58
+ */
59
+ declare type MountResponse<T> = {
60
+ /**
61
+ * Fixture for debugging and testing a component.
62
+ *
63
+ * @memberof MountResponse
64
+ * @see https://angular.io/api/core/testing/ComponentFixture
65
+ */
66
+ fixture: ComponentFixture<T>;
67
+ /**
68
+ * The instance of the root component class
69
+ *
70
+ * @memberof MountResponse
71
+ * @see https://angular.io/api/core/testing/ComponentFixture#componentInstance
72
+ */
73
+ component: T;
74
+ };
75
+ /**
76
+ * Mounts an Angular component inside Cypress browser
77
+ *
78
+ * @param component Angular component being mounted or its template
79
+ * @param config configuration used to configure the TestBed
80
+ * @example
81
+ * import { mount } from '@cypress/angular'
82
+ * import { StepperComponent } from './stepper.component'
83
+ * import { MyService } from 'services/my.service'
84
+ * import { SharedModule } from 'shared/shared.module';
85
+ * it('mounts', () => {
86
+ * mount(StepperComponent, {
87
+ * providers: [MyService],
88
+ * imports: [SharedModule]
89
+ * })
90
+ * cy.get('[data-cy=increment]').click()
91
+ * cy.get('[data-cy=counter]').should('have.text', '1')
92
+ * })
93
+ *
94
+ * // or
95
+ *
96
+ * it('mounts with template', () => {
97
+ * mount('<app-stepper></app-stepper>', {
98
+ * declarations: [StepperComponent],
99
+ * })
100
+ * })
101
+ *
102
+ * @see {@link https://on.cypress.io/mounting-angular} for more details.
103
+ *
104
+ * @returns A component and component fixture
105
+ */
106
+ declare function mount<T>(component: Type<T> | string, config?: MountConfig<T>): Cypress.Chainable<MountResponse<T>>;
107
+ /**
108
+ * Creates a new Event Emitter and then spies on it's `emit` method
109
+ *
110
+ * @param {string} alias name you want to use for your cy.spy() alias
111
+ * @returns EventEmitter<T>
112
+ * @example
113
+ * import { StepperComponent } from './stepper.component'
114
+ * import { mount, createOutputSpy } from '@cypress/angular'
115
+ *
116
+ * it('Has spy', () => {
117
+ * mount(StepperComponent, { change: createOutputSpy('changeSpy') })
118
+ * cy.get('[data-cy=increment]').click()
119
+ * cy.get('@changeSpy').should('have.been.called')
120
+ * })
121
+ */
122
+ declare const createOutputSpy: <T>(alias: string) => any;
123
+
124
+ export { MountConfig, MountResponse, createOutputSpy, mount };
@@ -47,27 +47,11 @@ function __decorate(decorators, target, key, desc) {
47
47
  }
48
48
 
49
49
  /**
50
- * Remove any style or extra link elements from the iframe placeholder
51
- * left from any previous test
52
- *
50
+ * Utility function to register CT side effects and run cleanup code during the "test:before:run" Cypress hook
51
+ * @param optionalCallback Callback to be called before the next test runs
53
52
  */
54
- function cleanupStyles() {
55
- const styles = document.body.querySelectorAll('[data-cy=injected-style-tag]');
56
- styles.forEach((styleElement) => {
57
- if (styleElement.parentElement) {
58
- styleElement.parentElement.removeChild(styleElement);
59
- }
60
- });
61
- const links = document.body.querySelectorAll('[data-cy=injected-stylesheet]');
62
- links.forEach((link) => {
63
- if (link.parentElement) {
64
- link.parentElement.removeChild(link);
65
- }
66
- });
67
- }
68
53
  function setupHooks(optionalCallback) {
69
- // Consumed by the framework "mount" libs. A user might register their own mount in the scaffolded 'commands.js'
70
- // file that is imported by e2e and component support files by default. We don't want CT side effects to run when e2e
54
+ // We don't want CT side effects to run when e2e
71
55
  // testing so we early return.
72
56
  // System test to verify CT side effects do not pollute e2e: system-tests/test/e2e_with_mount_import_spec.ts
73
57
  if (Cypress.testingType !== 'component') {
@@ -82,7 +66,6 @@ function setupHooks(optionalCallback) {
82
66
  // @ts-ignore
83
67
  Cypress.on('test:before:run', () => {
84
68
  optionalCallback === null || optionalCallback === void 0 ? void 0 : optionalCallback();
85
- cleanupStyles();
86
69
  });
87
70
  }
88
71
 
@@ -91,6 +74,20 @@ function setupHooks(optionalCallback) {
91
74
  */
92
75
  // @ts-ignore
93
76
  window.Mocha['__zone_patch__'] = false;
77
+ let activeFixture = null;
78
+ function cleanup() {
79
+ // Not public, we need to call this to remove the last component from the DOM
80
+ try {
81
+ getTestBed().tearDownTestingModule();
82
+ }
83
+ catch (e) {
84
+ const notSupportedError = new Error(`Failed to teardown component. The version of Angular you are using may not be officially supported.`);
85
+ notSupportedError.docsUrl = 'https://on.cypress.io/component-framework-configuration';
86
+ throw notSupportedError;
87
+ }
88
+ getTestBed().resetTestingModule();
89
+ activeFixture = null;
90
+ }
94
91
  // 'zone.js/testing' is not properly aliasing `it.skip` but it does provide `xit`/`xspecify`
95
92
  // Written up under https://github.com/angular/angular/issues/46297 but is not seeing movement
96
93
  // so we'll patch here pending a fix in that library
@@ -111,6 +108,7 @@ CypressAngularErrorHandler = __decorate([
111
108
  * @returns {MountConfig} MountConfig
112
109
  */
113
110
  function bootstrapModule(component, config) {
111
+ var _a;
114
112
  const testModuleMetaData = __rest(config, ["componentProperties"]);
115
113
  if (!testModuleMetaData.declarations) {
116
114
  testModuleMetaData.declarations = [];
@@ -128,7 +126,7 @@ function bootstrapModule(component, config) {
128
126
  useClass: CypressAngularErrorHandler,
129
127
  });
130
128
  // check if the component is a standalone component
131
- if (component.ɵcmp.standalone) {
129
+ if ((_a = component.ɵcmp) === null || _a === void 0 ? void 0 : _a.standalone) {
132
130
  testModuleMetaData.imports.push(component);
133
131
  }
134
132
  else {
@@ -147,16 +145,8 @@ function bootstrapModule(component, config) {
147
145
  * @returns {Type<T>} componentFixture
148
146
  */
149
147
  function initTestBed(component, config) {
150
- const { providers } = config, configRest = __rest(config, ["providers"]);
151
148
  const componentFixture = createComponentFixture(component);
152
- getTestBed().configureTestingModule(Object.assign({}, bootstrapModule(componentFixture, configRest)));
153
- if (providers != null) {
154
- getTestBed().overrideComponent(componentFixture, {
155
- add: {
156
- providers,
157
- },
158
- });
159
- }
149
+ getTestBed().configureTestingModule(Object.assign({}, bootstrapModule(componentFixture, config)));
160
150
  return componentFixture;
161
151
  }
162
152
  let WrapperComponent = class WrapperComponent {
@@ -189,6 +179,7 @@ function createComponentFixture(component) {
189
179
  */
190
180
  function setupFixture(component, config) {
191
181
  const fixture = getTestBed().createComponent(component);
182
+ setupComponent(config, fixture);
192
183
  fixture.whenStable().then(() => {
193
184
  var _a;
194
185
  fixture.autoDetectChanges((_a = config.autoDetectChanges) !== null && _a !== void 0 ? _a : true);
@@ -208,7 +199,7 @@ function setupComponent(config, fixture) {
208
199
  component = Object.assign(component, config.componentProperties);
209
200
  }
210
201
  if (config.autoSpyOutputs) {
211
- Object.keys(component).forEach((key, index, keys) => {
202
+ Object.keys(component).forEach((key) => {
212
203
  const property = component[key];
213
204
  if (property instanceof EventEmitter) {
214
205
  component[key] = createOutputSpy(`${key}Spy`);
@@ -228,44 +219,48 @@ function setupComponent(config, fixture) {
228
219
  component.ngOnChanges(simpleChanges);
229
220
  }
230
221
  }
231
- return component;
232
222
  }
233
223
  /**
234
224
  * Mounts an Angular component inside Cypress browser
235
225
  *
236
- * @param {Type<T> | string} component Angular component being mounted or its template
237
- * @param {MountConfig<T>} config configuration used to configure the TestBed
226
+ * @param component Angular component being mounted or its template
227
+ * @param config configuration used to configure the TestBed
238
228
  * @example
239
- * import { HelloWorldComponent } from 'hello-world/hello-world.component'
229
+ * import { mount } from '@cypress/angular'
230
+ * import { StepperComponent } from './stepper.component'
240
231
  * import { MyService } from 'services/my.service'
241
232
  * import { SharedModule } from 'shared/shared.module';
242
- * import { mount } from '@cypress/angular'
243
- * it('can mount', () => {
244
- * mount(HelloWorldComponent, {
245
- * providers: [MyService],
246
- * imports: [SharedModule]
247
- * })
248
- * cy.get('h1').contains('Hello World')
233
+ * it('mounts', () => {
234
+ * mount(StepperComponent, {
235
+ * providers: [MyService],
236
+ * imports: [SharedModule]
237
+ * })
238
+ * cy.get('[data-cy=increment]').click()
239
+ * cy.get('[data-cy=counter]').should('have.text', '1')
249
240
  * })
250
241
  *
251
- * or
242
+ * // or
252
243
  *
253
- * it('can mount with template', () => {
254
- * mount('<app-hello-world></app-hello-world>', {
255
- * declarations: [HelloWorldComponent],
256
- * providers: [MyService],
257
- * imports: [SharedModule]
258
- * })
244
+ * it('mounts with template', () => {
245
+ * mount('<app-stepper></app-stepper>', {
246
+ * declarations: [StepperComponent],
247
+ * })
259
248
  * })
260
- * @returns Cypress.Chainable<MountResponse<T>>
249
+ *
250
+ * @see {@link https://on.cypress.io/mounting-angular} for more details.
251
+ *
252
+ * @returns A component and component fixture
261
253
  */
262
254
  function mount(component, config = {}) {
255
+ // Remove last mounted component if cy.mount is called more than once in a test
256
+ if (activeFixture) {
257
+ cleanup();
258
+ }
263
259
  const componentFixture = initTestBed(component, config);
264
- const fixture = setupFixture(componentFixture, config);
265
- const componentInstance = setupComponent(config, fixture);
260
+ activeFixture = setupFixture(componentFixture, config);
266
261
  const mountResponse = {
267
- fixture,
268
- component: componentInstance,
262
+ fixture: activeFixture,
263
+ component: activeFixture.componentInstance,
269
264
  };
270
265
  const logMessage = typeof component === 'string' ? 'Component' : componentFixture.name;
271
266
  Cypress.log({
@@ -280,6 +275,15 @@ function mount(component, config = {}) {
280
275
  *
281
276
  * @param {string} alias name you want to use for your cy.spy() alias
282
277
  * @returns EventEmitter<T>
278
+ * @example
279
+ * import { StepperComponent } from './stepper.component'
280
+ * import { mount, createOutputSpy } from '@cypress/angular'
281
+ *
282
+ * it('Has spy', () => {
283
+ * mount(StepperComponent, { change: createOutputSpy('changeSpy') })
284
+ * cy.get('[data-cy=increment]').click()
285
+ * cy.get('@changeSpy').should('have.been.called')
286
+ * })
283
287
  */
284
288
  const createOutputSpy = (alias) => {
285
289
  const emitter = new EventEmitter();
@@ -290,10 +294,6 @@ const createOutputSpy = (alias) => {
290
294
  getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {
291
295
  teardown: { destroyAfterEach: false },
292
296
  });
293
- setupHooks(() => {
294
- // Not public, we need to call this to remove the last component from the DOM
295
- getTestBed()['tearDownTestingModule']();
296
- getTestBed().resetTestingModule();
297
- });
297
+ setupHooks(cleanup);
298
298
 
299
299
  export { createOutputSpy, mount };
package/lib/cli.js CHANGED
@@ -331,9 +331,23 @@ module.exports = {
331
331
  }
332
332
 
333
333
  const {
334
- CYPRESS_INTERNAL_ENV
334
+ CYPRESS_INTERNAL_ENV,
335
+ CYPRESS_DOWNLOAD_USE_CA
335
336
  } = process.env;
336
337
 
338
+ if (process.env.CYPRESS_DOWNLOAD_USE_CA) {
339
+ let msg = `
340
+ ${logSymbols.warning} Warning: It looks like you're setting CYPRESS_DOWNLOAD_USE_CA=${CYPRESS_DOWNLOAD_USE_CA}
341
+
342
+ The environment variable "CYPRESS_DOWNLOAD_USE_CA" is no longer required to be set.
343
+
344
+ You can safely unset this environment variable.
345
+ `;
346
+ logger.log();
347
+ logger.warn(stripIndent(msg));
348
+ logger.log();
349
+ }
350
+
337
351
  if (!util.isValidCypressInternalEnvValue(CYPRESS_INTERNAL_ENV)) {
338
352
  debug('invalid CYPRESS_INTERNAL_ENV value', CYPRESS_INTERNAL_ENV);
339
353
  return errors.exitWithError(errors.errors.invalidCypressEnv)(`CYPRESS_INTERNAL_ENV=${CYPRESS_INTERNAL_ENV}`);
@@ -56,18 +56,14 @@ const getBaseUrl = () => {
56
56
 
57
57
  const getCA = () => {
58
58
  return new Promise(resolve => {
59
- if (!util.getEnv('CYPRESS_DOWNLOAD_USE_CA')) {
60
- resolve();
61
- }
62
-
63
- if (process.env.npm_config_ca) {
64
- resolve(process.env.npm_config_ca);
65
- } else if (process.env.npm_config_cafile) {
59
+ if (process.env.npm_config_cafile) {
66
60
  fs.readFile(process.env.npm_config_cafile, 'utf8').then(cafileContent => {
67
61
  resolve(cafileContent);
68
62
  }).catch(() => {
69
63
  resolve();
70
64
  });
65
+ } else if (process.env.npm_config_ca) {
66
+ resolve(process.env.npm_config_ca);
71
67
  } else {
72
68
  resolve();
73
69
  }
package/lib/util.js CHANGED
@@ -151,7 +151,7 @@ function isValidCypressInternalEnvValue(value) {
151
151
  if (_.isUndefined(value)) {
152
152
  // will get default value
153
153
  return true;
154
- } // names of config environments, see "packages/server/config/app.yml"
154
+ } // names of config environments, see "packages/server/config/app.json"
155
155
 
156
156
 
157
157
  const names = ['development', 'test', 'staging', 'production'];
@@ -245,7 +245,7 @@ const getApplicationDataFolder = (...paths) => {
245
245
  env
246
246
  } = process; // allow overriding the app_data folder
247
247
 
248
- let folder = env.CYPRESS_KONFIG_ENV || env.CYPRESS_INTERNAL_ENV || 'development';
248
+ let folder = env.CYPRESS_CONFIG_ENV || env.CYPRESS_INTERNAL_ENV || 'development';
249
249
  const PRODUCT_NAME = pkg.productName || pkg.name;
250
250
  const OS_DATA_PATH = ospath.data();
251
251
  const ELECTRON_APP_DATA_PATH = path.join(OS_DATA_PATH, PRODUCT_NAME);
@@ -1,3 +1,17 @@
1
+ # [@cypress/mount-utils-v3.0.0](https://github.com/cypress-io/cypress/compare/@cypress/mount-utils-v2.1.0...@cypress/mount-utils-v3.0.0) (2022-11-07)
2
+
3
+
4
+ ### Bug Fixes
5
+
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))
9
+
10
+
11
+ ### BREAKING CHANGES
12
+
13
+ * remove last mounted component upon subsequent mount calls of mount
14
+
1
15
  # [@cypress/mount-utils-v2.1.0](https://github.com/cypress-io/cypress/compare/@cypress/mount-utils-v2.0.1...@cypress/mount-utils-v2.1.0) (2022-08-30)
2
16
 
3
17
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  > **Note** this package is not meant to be used outside of cypress component testing.
4
4
 
5
- This librares exports some shared types and utility functions designed to build adapters for components frameworks.
5
+ This library exports some shared types and utility functions designed to build adapters for components frameworks.
6
6
 
7
7
  It is used in:
8
8
 
@@ -22,14 +22,11 @@ All the functionality used to create the first party Mount adapters is available
22
22
 
23
23
  - Receive a component as the first argument. This could be class, function etc - depends on the framework.
24
24
  - Return a Cypress Chainable (for example using `cy.wrap`) that resolves whatever is idiomatic for your framework
25
+ - Call `getContainerEl` to access the root DOM element
25
26
 
26
27
  In addition, we recommend that Mount Adapters:
27
28
 
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.
29
+ - call `setupHooks` to register the required lifecycle hooks for `@cypress/mount-utils` to work
33
30
 
34
31
  ### Example Mount Adapter: Web Components
35
32
 
@@ -39,9 +36,7 @@ Here's a simple yet realistic example of Mount Adapter targeting Web Components.
39
36
  import {
40
37
  ROOT_SELECTOR,
41
38
  setupHooks,
42
- injectStylesBeforeElement,
43
- getContainerEl,
44
- StyleOptions
39
+ getContainerEl
45
40
  } from "@cypress/mount-utils";
46
41
 
47
42
  Cypress.on("run:start", () => {
@@ -69,8 +64,7 @@ function maybeRegisterComponent<T extends CustomElementConstructor>(
69
64
  }
70
65
 
71
66
  export function mount(
72
- webComponent: CustomElementConstructor,
73
- options?: Partial<StyleOptions>
67
+ webComponent: CustomElementConstructor
74
68
  ): Cypress.Chainable {
75
69
  // Get root selector defined in `cypress/support.component-index.html
76
70
  const $root = document.querySelector(ROOT_SELECTOR)!;
@@ -83,9 +77,6 @@ export function mount(
83
77
  /// Register Web Component
84
78
  maybeRegisterComponent(name, webComponent);
85
79
 
86
- // Inject user styles before mounting the component
87
- injectStylesBeforeElement(options ?? {}, document, getContainerEl())
88
-
89
80
  // Render HTML containing component.
90
81
  $root.innerHTML = `<${name} id="root"></${name}>`;
91
82
 
@@ -100,8 +91,7 @@ export function mount(
100
91
  return cy.wrap(document.querySelector("#root"), { log: false });
101
92
  }
102
93
 
103
- // Setup Cypress lifecycle hooks. This tears down any styles
104
- // injected by injectStylesBeforeElement, etc.
94
+ // Setup Cypress lifecycle hooks.
105
95
  setupHooks();
106
96
  ```
107
97
 
@@ -131,14 +121,7 @@ export class WebCounter extends HTMLElement {
131
121
 
132
122
  describe('web-component.cy.ts', () => {
133
123
  it('playground', () => {
134
- cy.mount(WebCounter, {
135
- styles: `
136
- button {
137
- background: lightblue;
138
- color: white;
139
- }
140
- `
141
- })
124
+ cy.mount(WebCounter)
142
125
  })
143
126
  })
144
127
  ```