cypress 10.4.0 → 10.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. package/angular/CHANGELOG.md +86 -0
  2. package/angular/README.md +85 -0
  3. package/angular/dist/index.d.ts +1 -0
  4. package/angular/dist/index.js +265 -0
  5. package/angular/dist/mount.d.ts +112 -0
  6. package/angular/package.json +68 -0
  7. package/lib/tasks/download.js +4 -3
  8. package/mount-utils/CHANGELOG.md +7 -0
  9. package/mount-utils/package.json +5 -1
  10. package/package.json +16 -4
  11. package/react/CHANGELOG.md +20 -0
  12. package/react/dist/createMount.d.ts +7 -6
  13. package/react/dist/cypress-react.cjs.js +653 -140
  14. package/react/dist/cypress-react.esm-bundler.js +640 -127
  15. package/react/dist/mount.d.ts +2 -1
  16. package/react/dist/mountHook.d.ts +1 -0
  17. package/react/dist/types.d.ts +2 -7
  18. package/react/package.json +4 -6
  19. package/react18/CHANGELOG.md +13 -0
  20. package/react18/dist/cypress-react.cjs.js +300 -118
  21. package/react18/dist/cypress-react.esm-bundler.js +286 -104
  22. package/react18/dist/index.d.ts +2 -1
  23. package/react18/package.json +2 -2
  24. package/svelte/CHANGELOG.md +0 -0
  25. package/svelte/README.md +83 -0
  26. package/svelte/dist/cypress-svelte.cjs.js +213 -0
  27. package/svelte/dist/cypress-svelte.esm-bundler.js +209 -0
  28. package/svelte/dist/index.d.ts +1 -0
  29. package/svelte/dist/mount.d.ts +30 -0
  30. package/svelte/package.json +43 -0
  31. package/types/cypress-type-helpers.d.ts +3 -1
  32. package/types/cypress.d.ts +61 -5
  33. package/vue/CHANGELOG.md +14 -0
  34. package/vue/dist/cypress-vue.cjs.js +30 -38
  35. package/vue/dist/cypress-vue.esm-bundler.js +30 -38
  36. package/vue/dist/index.d.ts +1 -0
  37. package/vue/package.json +2 -8
  38. package/vue2/CHANGELOG.md +7 -0
  39. package/vue2/dist/cypress-vue2.cjs.js +53 -84
  40. package/vue2/dist/cypress-vue2.esm-bundler.js +53 -84
  41. package/vue2/dist/index.d.ts +1 -0
  42. package/vue2/package.json +2 -5
  43. package/vue2/dist/cypress-vue2.browser.js +0 -20197
@@ -0,0 +1,86 @@
1
+ # @cypress/angular-v1.0.0 (2022-08-17)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **angular:** set rxjs versions > 6.6.0 as dependency ([#16676](https://github.com/cypress-io/cypress/issues/16676)) ([46de81e](https://github.com/cypress-io/cypress/commit/46de81e75fd18bc37cb884e9a751106fff4d08ad))
7
+ * remove dependency causing semantic-release to fail ([#23142](https://github.com/cypress-io/cypress/issues/23142)) ([20f89bf](https://github.com/cypress-io/cypress/commit/20f89bfa32636baa8922896e719962c703129abd))
8
+ * scaffold correct config file ([#19776](https://github.com/cypress-io/cypress/issues/19776)) ([8f32960](https://github.com/cypress-io/cypress/commit/8f32960ef803f539f065d41f01fff33bfe33ed5d))
9
+ * scope config to current testing type ([#20677](https://github.com/cypress-io/cypress/issues/20677)) ([61f7cfc](https://github.com/cypress-io/cypress/commit/61f7cfc59284a2938e0a1c15d74ee75215ba5f8b))
10
+ * terminal error message for non migrated config ([#21467](https://github.com/cypress-io/cypress/issues/21467)) ([3274da7](https://github.com/cypress-io/cypress/commit/3274da7842f5ef1ddad62b1c630d0ff9120e4289))
11
+ * update scaffold template to use correct path ([#20047](https://github.com/cypress-io/cypress/issues/20047)) ([6e80359](https://github.com/cypress-io/cypress/commit/6e803597a379222cf936e5977c8314d693ee1912))
12
+
13
+
14
+ ### Features
15
+
16
+ * add devServer to config file ([#18962](https://github.com/cypress-io/cypress/issues/18962)) ([2573375](https://github.com/cypress-io/cypress/commit/2573375b5b6616efd2d213a94cd55fd8e0385864))
17
+ * add template support, teardown & standalone ([#23117](https://github.com/cypress-io/cypress/issues/23117)) ([d201b37](https://github.com/cypress-io/cypress/commit/d201b37b3d6b1e37a15a8d21d853acca47bfc666))
18
+ * **angular:** angular mount ([#22858](https://github.com/cypress-io/cypress/issues/22858)) ([4131b1f](https://github.com/cypress-io/cypress/commit/4131b1fa8482ae08113bef337965baa1ac12f66c))
19
+ * Deprecate run-ct / open-ct, and update all examples to use --ct instead ([#18422](https://github.com/cypress-io/cypress/issues/18422)) ([196e8f6](https://github.com/cypress-io/cypress/commit/196e8f62cc6d27974f235945cb5700624b3dae41))
20
+ * enable Angular CT support ([#23089](https://github.com/cypress-io/cypress/issues/23089)) ([94e78eb](https://github.com/cypress-io/cypress/commit/94e78eba0430eae97529058c40611e5f24dbf140))
21
+ * ProjectLifecycleManager & general launchpad cleanup ([#19347](https://github.com/cypress-io/cypress/issues/19347)) ([4626f74](https://github.com/cypress-io/cypress/commit/4626f7481c9904fec484aa167a02e0197a3095c4))
22
+ * remove testFiles reference ([#20565](https://github.com/cypress-io/cypress/issues/20565)) ([5670344](https://github.com/cypress-io/cypress/commit/567034459089d9d53dfab5556cb9369fb335c3db))
23
+ * support specPattern, deprecate integrationFolder and componentFolder ([#19319](https://github.com/cypress-io/cypress/issues/19319)) ([792980a](https://github.com/cypress-io/cypress/commit/792980ac12746ef47b9c944ebe4c6c353a187ab2))
24
+ * support webpack-dev-server v4 ([#17918](https://github.com/cypress-io/cypress/issues/17918)) ([16e4759](https://github.com/cypress-io/cypress/commit/16e4759e0196f68c5f0525efb020211337748f94))
25
+ * swap the #__cy_root id selector to become data-cy-root for component mounting ([#20951](https://github.com/cypress-io/cypress/issues/20951)) ([0e7b555](https://github.com/cypress-io/cypress/commit/0e7b555f93fb403f431c5de4a07ae7ad6ac89ba2))
26
+ * Use .config files ([#18578](https://github.com/cypress-io/cypress/issues/18578)) ([081dd19](https://github.com/cypress-io/cypress/commit/081dd19cc6da3da229a7af9c84f62730c85a5cd6))
27
+ * use devServer instad of startDevServer ([#20092](https://github.com/cypress-io/cypress/issues/20092)) ([8a6768f](https://github.com/cypress-io/cypress/commit/8a6768fee6f46b908c5a9daf23da8b804a6c627f))
28
+ * use hoisted yarn install in binary build ([#17285](https://github.com/cypress-io/cypress/issues/17285)) ([e4f5b10](https://github.com/cypress-io/cypress/commit/e4f5b106d49d6ac0857c5fdac886f83b99558c88))
29
+ * Use plugins on config files ([#18798](https://github.com/cypress-io/cypress/issues/18798)) ([bb8251b](https://github.com/cypress-io/cypress/commit/bb8251b752ac44f1184f9160194cf12d41fc867f))
30
+ * use supportFile by testingType ([#19364](https://github.com/cypress-io/cypress/issues/19364)) ([0366d4f](https://github.com/cypress-io/cypress/commit/0366d4fa8971e5e5189c6fd6450cc3c8d72dcfe1))
31
+
32
+ # @cypress/angular-v1.0.0 (2022-08-04)
33
+
34
+
35
+ ### Bug Fixes
36
+
37
+ * **angular:** set rxjs versions > 6.6.0 as dependency ([#16676](https://github.com/cypress-io/cypress/issues/16676)) ([46de81e](https://github.com/cypress-io/cypress/commit/46de81e75fd18bc37cb884e9a751106fff4d08ad))
38
+ * scaffold correct config file ([#19776](https://github.com/cypress-io/cypress/issues/19776)) ([8f32960](https://github.com/cypress-io/cypress/commit/8f32960ef803f539f065d41f01fff33bfe33ed5d))
39
+ * scope config to current testing type ([#20677](https://github.com/cypress-io/cypress/issues/20677)) ([61f7cfc](https://github.com/cypress-io/cypress/commit/61f7cfc59284a2938e0a1c15d74ee75215ba5f8b))
40
+ * terminal error message for non migrated config ([#21467](https://github.com/cypress-io/cypress/issues/21467)) ([3274da7](https://github.com/cypress-io/cypress/commit/3274da7842f5ef1ddad62b1c630d0ff9120e4289))
41
+ * update scaffold template to use correct path ([#20047](https://github.com/cypress-io/cypress/issues/20047)) ([6e80359](https://github.com/cypress-io/cypress/commit/6e803597a379222cf936e5977c8314d693ee1912))
42
+
43
+
44
+ ### Features
45
+
46
+ * add devServer to config file ([#18962](https://github.com/cypress-io/cypress/issues/18962)) ([2573375](https://github.com/cypress-io/cypress/commit/2573375b5b6616efd2d213a94cd55fd8e0385864))
47
+ * **angular:** angular mount ([#22858](https://github.com/cypress-io/cypress/issues/22858)) ([4131b1f](https://github.com/cypress-io/cypress/commit/4131b1fa8482ae08113bef337965baa1ac12f66c))
48
+ * Deprecate run-ct / open-ct, and update all examples to use --ct instead ([#18422](https://github.com/cypress-io/cypress/issues/18422)) ([196e8f6](https://github.com/cypress-io/cypress/commit/196e8f62cc6d27974f235945cb5700624b3dae41))
49
+ * ProjectLifecycleManager & general launchpad cleanup ([#19347](https://github.com/cypress-io/cypress/issues/19347)) ([4626f74](https://github.com/cypress-io/cypress/commit/4626f7481c9904fec484aa167a02e0197a3095c4))
50
+ * remove testFiles reference ([#20565](https://github.com/cypress-io/cypress/issues/20565)) ([5670344](https://github.com/cypress-io/cypress/commit/567034459089d9d53dfab5556cb9369fb335c3db))
51
+ * support specPattern, deprecate integrationFolder and componentFolder ([#19319](https://github.com/cypress-io/cypress/issues/19319)) ([792980a](https://github.com/cypress-io/cypress/commit/792980ac12746ef47b9c944ebe4c6c353a187ab2))
52
+ * support webpack-dev-server v4 ([#17918](https://github.com/cypress-io/cypress/issues/17918)) ([16e4759](https://github.com/cypress-io/cypress/commit/16e4759e0196f68c5f0525efb020211337748f94))
53
+ * swap the #__cy_root id selector to become data-cy-root for component mounting ([#20951](https://github.com/cypress-io/cypress/issues/20951)) ([0e7b555](https://github.com/cypress-io/cypress/commit/0e7b555f93fb403f431c5de4a07ae7ad6ac89ba2))
54
+ * Use .config files ([#18578](https://github.com/cypress-io/cypress/issues/18578)) ([081dd19](https://github.com/cypress-io/cypress/commit/081dd19cc6da3da229a7af9c84f62730c85a5cd6))
55
+ * use devServer instad of startDevServer ([#20092](https://github.com/cypress-io/cypress/issues/20092)) ([8a6768f](https://github.com/cypress-io/cypress/commit/8a6768fee6f46b908c5a9daf23da8b804a6c627f))
56
+ * use hoisted yarn install in binary build ([#17285](https://github.com/cypress-io/cypress/issues/17285)) ([e4f5b10](https://github.com/cypress-io/cypress/commit/e4f5b106d49d6ac0857c5fdac886f83b99558c88))
57
+ * Use plugins on config files ([#18798](https://github.com/cypress-io/cypress/issues/18798)) ([bb8251b](https://github.com/cypress-io/cypress/commit/bb8251b752ac44f1184f9160194cf12d41fc867f))
58
+ * use supportFile by testingType ([#19364](https://github.com/cypress-io/cypress/issues/19364)) ([0366d4f](https://github.com/cypress-io/cypress/commit/0366d4fa8971e5e5189c6fd6450cc3c8d72dcfe1))
59
+
60
+ # @cypress/angular-v1.0.0 (2022-08-04)
61
+
62
+
63
+ ### Bug Fixes
64
+
65
+ * **angular:** set rxjs versions > 6.6.0 as dependency ([#16676](https://github.com/cypress-io/cypress/issues/16676)) ([46de81e](https://github.com/cypress-io/cypress/commit/46de81e75fd18bc37cb884e9a751106fff4d08ad))
66
+ * scaffold correct config file ([#19776](https://github.com/cypress-io/cypress/issues/19776)) ([8f32960](https://github.com/cypress-io/cypress/commit/8f32960ef803f539f065d41f01fff33bfe33ed5d))
67
+ * scope config to current testing type ([#20677](https://github.com/cypress-io/cypress/issues/20677)) ([61f7cfc](https://github.com/cypress-io/cypress/commit/61f7cfc59284a2938e0a1c15d74ee75215ba5f8b))
68
+ * terminal error message for non migrated config ([#21467](https://github.com/cypress-io/cypress/issues/21467)) ([3274da7](https://github.com/cypress-io/cypress/commit/3274da7842f5ef1ddad62b1c630d0ff9120e4289))
69
+ * update scaffold template to use correct path ([#20047](https://github.com/cypress-io/cypress/issues/20047)) ([6e80359](https://github.com/cypress-io/cypress/commit/6e803597a379222cf936e5977c8314d693ee1912))
70
+
71
+
72
+ ### Features
73
+
74
+ * add devServer to config file ([#18962](https://github.com/cypress-io/cypress/issues/18962)) ([2573375](https://github.com/cypress-io/cypress/commit/2573375b5b6616efd2d213a94cd55fd8e0385864))
75
+ * **angular:** angular mount ([#22858](https://github.com/cypress-io/cypress/issues/22858)) ([4131b1f](https://github.com/cypress-io/cypress/commit/4131b1fa8482ae08113bef337965baa1ac12f66c))
76
+ * Deprecate run-ct / open-ct, and update all examples to use --ct instead ([#18422](https://github.com/cypress-io/cypress/issues/18422)) ([196e8f6](https://github.com/cypress-io/cypress/commit/196e8f62cc6d27974f235945cb5700624b3dae41))
77
+ * ProjectLifecycleManager & general launchpad cleanup ([#19347](https://github.com/cypress-io/cypress/issues/19347)) ([4626f74](https://github.com/cypress-io/cypress/commit/4626f7481c9904fec484aa167a02e0197a3095c4))
78
+ * remove testFiles reference ([#20565](https://github.com/cypress-io/cypress/issues/20565)) ([5670344](https://github.com/cypress-io/cypress/commit/567034459089d9d53dfab5556cb9369fb335c3db))
79
+ * support specPattern, deprecate integrationFolder and componentFolder ([#19319](https://github.com/cypress-io/cypress/issues/19319)) ([792980a](https://github.com/cypress-io/cypress/commit/792980ac12746ef47b9c944ebe4c6c353a187ab2))
80
+ * support webpack-dev-server v4 ([#17918](https://github.com/cypress-io/cypress/issues/17918)) ([16e4759](https://github.com/cypress-io/cypress/commit/16e4759e0196f68c5f0525efb020211337748f94))
81
+ * swap the #__cy_root id selector to become data-cy-root for component mounting ([#20951](https://github.com/cypress-io/cypress/issues/20951)) ([0e7b555](https://github.com/cypress-io/cypress/commit/0e7b555f93fb403f431c5de4a07ae7ad6ac89ba2))
82
+ * Use .config files ([#18578](https://github.com/cypress-io/cypress/issues/18578)) ([081dd19](https://github.com/cypress-io/cypress/commit/081dd19cc6da3da229a7af9c84f62730c85a5cd6))
83
+ * use devServer instad of startDevServer ([#20092](https://github.com/cypress-io/cypress/issues/20092)) ([8a6768f](https://github.com/cypress-io/cypress/commit/8a6768fee6f46b908c5a9daf23da8b804a6c627f))
84
+ * use hoisted yarn install in binary build ([#17285](https://github.com/cypress-io/cypress/issues/17285)) ([e4f5b10](https://github.com/cypress-io/cypress/commit/e4f5b106d49d6ac0857c5fdac886f83b99558c88))
85
+ * Use plugins on config files ([#18798](https://github.com/cypress-io/cypress/issues/18798)) ([bb8251b](https://github.com/cypress-io/cypress/commit/bb8251b752ac44f1184f9160194cf12d41fc867f))
86
+ * use supportFile by testingType ([#19364](https://github.com/cypress-io/cypress/issues/19364)) ([0366d4f](https://github.com/cypress-io/cypress/commit/0366d4fa8971e5e5189c6fd6450cc3c8d72dcfe1))
@@ -0,0 +1,85 @@
1
+ # @cypress/angular
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 |
74
+
75
+ ## Development
76
+
77
+ Run `yarn build` to compile and sync packages to the `cypress` cli package.
78
+
79
+ ## License
80
+
81
+ [![license](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/cypress-io/cypress/blob/master/LICENSE)
82
+
83
+ This project is licensed under the terms of the [MIT license](/LICENSE).
84
+
85
+ ## [Changelog](./CHANGELOG.md)
@@ -0,0 +1 @@
1
+ export * from './mount';
@@ -0,0 +1,265 @@
1
+
2
+ /**
3
+ * @cypress/angular v0.0.0-development
4
+ * (c) 2022 Cypress.io
5
+ * Released under the MIT License
6
+ */
7
+
8
+ import 'zone.js';
9
+ import 'zone.js/testing';
10
+ import { CommonModule } from '@angular/common';
11
+ import { Component, EventEmitter } from '@angular/core';
12
+ import { getTestBed, TestBed } from '@angular/core/testing';
13
+ import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
14
+
15
+ /******************************************************************************
16
+ Copyright (c) Microsoft Corporation.
17
+
18
+ Permission to use, copy, modify, and/or distribute this software for any
19
+ purpose with or without fee is hereby granted.
20
+
21
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
22
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
23
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
24
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
25
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
26
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
27
+ PERFORMANCE OF THIS SOFTWARE.
28
+ ***************************************************************************** */
29
+
30
+ function __rest(s, e) {
31
+ var t = {};
32
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
33
+ t[p] = s[p];
34
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
35
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
36
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
37
+ t[p[i]] = s[p[i]];
38
+ }
39
+ return t;
40
+ }
41
+
42
+ function __decorate(decorators, target, key, desc) {
43
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
44
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
45
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
46
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
47
+ }
48
+
49
+ /**
50
+ * Remove any style or extra link elements from the iframe placeholder
51
+ * left from any previous test
52
+ *
53
+ */
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
+ 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
71
+ // testing so we early return.
72
+ // System test to verify CT side effects do not pollute e2e: system-tests/test/e2e_with_mount_import_spec.ts
73
+ if (Cypress.testingType !== 'component') {
74
+ return;
75
+ }
76
+ // When running component specs, we cannot allow "cy.visit"
77
+ // because it will wipe out our preparation work, and does not make much sense
78
+ // thus we overwrite "cy.visit" to throw an error
79
+ Cypress.Commands.overwrite('visit', () => {
80
+ throw new Error('cy.visit from a component spec is not allowed');
81
+ });
82
+ // @ts-ignore
83
+ Cypress.on('test:before:run', () => {
84
+ optionalCallback === null || optionalCallback === void 0 ? void 0 : optionalCallback();
85
+ cleanupStyles();
86
+ });
87
+ }
88
+
89
+ /**
90
+ * @hack fixes "Mocha has already been patched with Zone" error.
91
+ */
92
+ // @ts-ignore
93
+ window.Mocha['__zone_patch__'] = false;
94
+ /**
95
+ * Bootstraps the TestModuleMetaData passed to the TestBed
96
+ *
97
+ * @param {Type<T>} component Angular component being mounted
98
+ * @param {MountConfig} config TestBed configuration passed into the mount function
99
+ * @returns {MountConfig} MountConfig
100
+ */
101
+ function bootstrapModule(component, config) {
102
+ const testModuleMetaData = __rest(config, ["componentProperties"]);
103
+ if (!testModuleMetaData.declarations) {
104
+ testModuleMetaData.declarations = [];
105
+ }
106
+ if (!testModuleMetaData.imports) {
107
+ testModuleMetaData.imports = [];
108
+ }
109
+ // check if the component is a standalone component
110
+ if (component.ɵcmp.standalone) {
111
+ testModuleMetaData.imports.push(component);
112
+ }
113
+ else {
114
+ testModuleMetaData.declarations.push(component);
115
+ }
116
+ if (!testModuleMetaData.imports.includes(CommonModule)) {
117
+ testModuleMetaData.imports.push(CommonModule);
118
+ }
119
+ return testModuleMetaData;
120
+ }
121
+ /**
122
+ * Initializes the TestBed
123
+ *
124
+ * @param {Type<T> | string} component Angular component being mounted or its template
125
+ * @param {MountConfig} config TestBed configuration passed into the mount function
126
+ * @returns {Type<T>} componentFixture
127
+ */
128
+ function initTestBed(component, config) {
129
+ const { providers } = config, configRest = __rest(config, ["providers"]);
130
+ const componentFixture = createComponentFixture(component);
131
+ getTestBed().configureTestingModule(Object.assign({}, bootstrapModule(componentFixture, configRest)));
132
+ if (providers != null) {
133
+ getTestBed().overrideComponent(componentFixture, {
134
+ add: {
135
+ providers,
136
+ },
137
+ });
138
+ }
139
+ return componentFixture;
140
+ }
141
+ let WrapperComponent = class WrapperComponent {
142
+ };
143
+ WrapperComponent = __decorate([
144
+ Component({ selector: 'cy-wrapper-component', template: '' })
145
+ ], WrapperComponent);
146
+ /**
147
+ * Returns the Component if Type<T> or creates a WrapperComponent
148
+ *
149
+ * @param {Type<T> | string} component The component you want to create a fixture of
150
+ * @returns {Type<T> | WrapperComponent}
151
+ */
152
+ function createComponentFixture(component) {
153
+ if (typeof component === 'string') {
154
+ // getTestBed().overrideTemplate is available in v14+
155
+ // The static TestBed.overrideTemplate is available across versions
156
+ TestBed.overrideTemplate(WrapperComponent, component);
157
+ return WrapperComponent;
158
+ }
159
+ return component;
160
+ }
161
+ /**
162
+ * Creates the ComponentFixture
163
+ *
164
+ * @param {Type<T>} component Angular component being mounted
165
+ * @param {MountConfig<T>} config MountConfig
166
+
167
+ * @returns {ComponentFixture<T>} ComponentFixture
168
+ */
169
+ function setupFixture(component, config) {
170
+ const fixture = getTestBed().createComponent(component);
171
+ fixture.whenStable().then(() => {
172
+ var _a;
173
+ fixture.autoDetectChanges((_a = config.autoDetectChanges) !== null && _a !== void 0 ? _a : true);
174
+ });
175
+ return fixture;
176
+ }
177
+ /**
178
+ * Gets the componentInstance and Object.assigns any componentProperties() passed in the MountConfig
179
+ *
180
+ * @param {MountConfig} config TestBed configuration passed into the mount function
181
+ * @param {ComponentFixture<T>} fixture Fixture for debugging and testing a component.
182
+ * @returns {T} Component being mounted
183
+ */
184
+ function setupComponent(config, fixture) {
185
+ let component = fixture.componentInstance;
186
+ if (config === null || config === void 0 ? void 0 : config.componentProperties) {
187
+ component = Object.assign(component, config.componentProperties);
188
+ }
189
+ if (config.autoSpyOutputs) {
190
+ Object.keys(component).forEach((key, index, keys) => {
191
+ const property = component[key];
192
+ if (property instanceof EventEmitter) {
193
+ component[key] = createOutputSpy(`${key}Spy`);
194
+ }
195
+ });
196
+ }
197
+ return component;
198
+ }
199
+ /**
200
+ * Mounts an Angular component inside Cypress browser
201
+ *
202
+ * @param {Type<T> | string} component Angular component being mounted or its template
203
+ * @param {MountConfig<T>} config configuration used to configure the TestBed
204
+ * @example
205
+ * import { HelloWorldComponent } from 'hello-world/hello-world.component'
206
+ * import { MyService } from 'services/my.service'
207
+ * import { SharedModule } from 'shared/shared.module';
208
+ * import { mount } from '@cypress/angular'
209
+ * it('can mount', () => {
210
+ * mount(HelloWorldComponent, {
211
+ * providers: [MyService],
212
+ * imports: [SharedModule]
213
+ * })
214
+ * cy.get('h1').contains('Hello World')
215
+ * })
216
+ *
217
+ * or
218
+ *
219
+ * it('can mount with template', () => {
220
+ * mount('<app-hello-world></app-hello-world>', {
221
+ * declarations: [HelloWorldComponent],
222
+ * providers: [MyService],
223
+ * imports: [SharedModule]
224
+ * })
225
+ * })
226
+ * @returns Cypress.Chainable<MountResponse<T>>
227
+ */
228
+ function mount(component, config = {}) {
229
+ const componentFixture = initTestBed(component, config);
230
+ const fixture = setupFixture(componentFixture, config);
231
+ const componentInstance = setupComponent(config, fixture);
232
+ const mountResponse = {
233
+ fixture,
234
+ component: componentInstance,
235
+ };
236
+ const logMessage = typeof component === 'string' ? 'Component' : componentFixture.name;
237
+ Cypress.log({
238
+ name: 'mount',
239
+ message: logMessage,
240
+ consoleProps: () => ({ result: mountResponse }),
241
+ });
242
+ return cy.wrap(mountResponse, { log: false });
243
+ }
244
+ /**
245
+ * Creates a new Event Emitter and then spies on it's `emit` method
246
+ *
247
+ * @param {string} alias name you want to use for your cy.spy() alias
248
+ * @returns EventEmitter<T>
249
+ */
250
+ const createOutputSpy = (alias) => {
251
+ const emitter = new EventEmitter();
252
+ cy.spy(emitter, 'emit').as(alias);
253
+ return emitter;
254
+ };
255
+ // Only needs to run once, we reset before each test
256
+ getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting(), {
257
+ teardown: { destroyAfterEach: false },
258
+ });
259
+ setupHooks(() => {
260
+ // Not public, we need to call this to remove the last component from the DOM
261
+ getTestBed()['tearDownTestingModule']();
262
+ getTestBed().resetTestingModule();
263
+ });
264
+
265
+ export { createOutputSpy, mount };
@@ -0,0 +1,112 @@
1
+ /// <reference types="cypress" />
2
+ /// <reference types="cypress" />
3
+ import 'zone.js';
4
+ import 'zone.js/testing';
5
+ import { Type } from '@angular/core';
6
+ import { ComponentFixture, TestModuleMetadata } from '@angular/core/testing';
7
+ /**
8
+ * Additional module configurations needed while mounting the component, like
9
+ * providers, declarations, imports and even component @Inputs()
10
+ *
11
+ *
12
+ * @interface MountConfig
13
+ * @see https://angular.io/api/core/testing/TestModuleMetadata
14
+ */
15
+ export interface MountConfig<T> extends TestModuleMetadata {
16
+ /**
17
+ * @memberof MountConfig
18
+ * @description flag to automatically create a cy.spy() for every component @Output() property
19
+ * @example
20
+ * export class ButtonComponent {
21
+ * @Output clicked = new EventEmitter()
22
+ * }
23
+ *
24
+ * cy.mount(ButtonComponent, { autoSpyOutputs: true })
25
+ * cy.get('@clickedSpy).should('have.been.called')
26
+ */
27
+ autoSpyOutputs?: boolean;
28
+ /**
29
+ * @memberof MountConfig
30
+ * @description flag defaulted to true to automatically detect changes in your components
31
+ */
32
+ autoDetectChanges?: boolean;
33
+ /**
34
+ * @memberof MountConfig
35
+ * @example
36
+ * import { ButtonComponent } from 'button/button.component'
37
+ * it('renders a button with Save text', () => {
38
+ * cy.mount(ButtonComponent, { componentProperties: { text: 'Save' }})
39
+ * cy.get('button').contains('Save')
40
+ * })
41
+ *
42
+ * it('renders a button with a cy.spy() replacing EventEmitter', () => {
43
+ * cy.mount(ButtonComponent, {
44
+ * componentProperties: {
45
+ * clicked: cy.spy().as('mySpy)
46
+ * }
47
+ * })
48
+ * cy.get('button').click()
49
+ * cy.get('@mySpy').should('have.been.called')
50
+ * })
51
+ */
52
+ componentProperties?: Partial<{
53
+ [P in keyof T]: T[P];
54
+ }>;
55
+ }
56
+ /**
57
+ * Type that the `mount` function returns
58
+ * @type MountResponse<T>
59
+ */
60
+ export declare type MountResponse<T> = {
61
+ /**
62
+ * Fixture for debugging and testing a component.
63
+ *
64
+ * @memberof MountResponse
65
+ * @see https://angular.io/api/core/testing/ComponentFixture
66
+ */
67
+ fixture: ComponentFixture<T>;
68
+ /**
69
+ * The instance of the root component class
70
+ *
71
+ * @memberof MountResponse
72
+ * @see https://angular.io/api/core/testing/ComponentFixture#componentInstance
73
+ */
74
+ component: T;
75
+ };
76
+ /**
77
+ * Mounts an Angular component inside Cypress browser
78
+ *
79
+ * @param {Type<T> | string} component Angular component being mounted or its template
80
+ * @param {MountConfig<T>} config configuration used to configure the TestBed
81
+ * @example
82
+ * import { HelloWorldComponent } from 'hello-world/hello-world.component'
83
+ * import { MyService } from 'services/my.service'
84
+ * import { SharedModule } from 'shared/shared.module';
85
+ * import { mount } from '@cypress/angular'
86
+ * it('can mount', () => {
87
+ * mount(HelloWorldComponent, {
88
+ * providers: [MyService],
89
+ * imports: [SharedModule]
90
+ * })
91
+ * cy.get('h1').contains('Hello World')
92
+ * })
93
+ *
94
+ * or
95
+ *
96
+ * it('can mount with template', () => {
97
+ * mount('<app-hello-world></app-hello-world>', {
98
+ * declarations: [HelloWorldComponent],
99
+ * providers: [MyService],
100
+ * imports: [SharedModule]
101
+ * })
102
+ * })
103
+ * @returns Cypress.Chainable<MountResponse<T>>
104
+ */
105
+ export declare function mount<T>(component: Type<T> | string, config?: MountConfig<T>): Cypress.Chainable<MountResponse<T>>;
106
+ /**
107
+ * Creates a new Event Emitter and then spies on it's `emit` method
108
+ *
109
+ * @param {string} alias name you want to use for your cy.spy() alias
110
+ * @returns EventEmitter<T>
111
+ */
112
+ export declare const createOutputSpy: <T>(alias: string) => any;
@@ -0,0 +1,68 @@
1
+ {
2
+ "name": "@cypress/angular",
3
+ "version": "0.0.0-development",
4
+ "description": "Test Angular Components using Cypress",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "prebuild": "rimraf dist",
8
+ "build": "rollup -c rollup.config.mjs",
9
+ "postbuild": "node ../../scripts/sync-exported-npm-with-cli.js",
10
+ "build-prod": "yarn build",
11
+ "check-ts": "tsc --noEmit"
12
+ },
13
+ "dependencies": {},
14
+ "devDependencies": {
15
+ "@angular/common": "^14.2.0",
16
+ "@angular/core": "^14.2.0",
17
+ "@angular/platform-browser-dynamic": "^14.2.0",
18
+ "@cypress/mount-utils": "0.0.0-development",
19
+ "typescript": "^4.7.4",
20
+ "zone.js": "~0.11.4"
21
+ },
22
+ "peerDependencies": {
23
+ "@angular/common": ">=13",
24
+ "@angular/core": ">=13",
25
+ "@angular/platform-browser-dynamic": ">=13",
26
+ "zone.js": ">=0.11.0"
27
+ },
28
+ "files": [
29
+ "dist"
30
+ ],
31
+ "types": "dist/index.d.ts",
32
+ "license": "MIT",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/cypress-io/cypress.git"
36
+ },
37
+ "homepage": "https://github.com/cypress-io/cypress/blob/master/npm/angular/#readme",
38
+ "author": "Jordan Powell",
39
+ "bugs": "https://github.com/cypress-io/cypress/issues/new?assignees=&labels=npm%3A%20%40cypress%2Fangular&template=1-bug-report.md&title=",
40
+ "keywords": [
41
+ "angular",
42
+ "cypress",
43
+ "cypress-io",
44
+ "test",
45
+ "testing"
46
+ ],
47
+ "contributors": [
48
+ {
49
+ "name": "Jordan Powell",
50
+ "social": "@jordanpowell88"
51
+ },
52
+ {
53
+ "name": "Zach Williams",
54
+ "social": "@ZachJW34"
55
+ }
56
+ ],
57
+ "module": "dist/index.js",
58
+ "publishConfig": {
59
+ "access": "public"
60
+ },
61
+ "standard": {
62
+ "globals": [
63
+ "Cypress",
64
+ "cy",
65
+ "expect"
66
+ ]
67
+ }
68
+ }
@@ -74,11 +74,11 @@ const getCA = () => {
74
74
  });
75
75
  };
76
76
 
77
- const prepend = (arch, urlPath) => {
77
+ const prepend = (arch, urlPath, version) => {
78
78
  const endpoint = url.resolve(getBaseUrl(), urlPath);
79
79
  const platform = os.platform();
80
80
  const pathTemplate = util.getEnv('CYPRESS_DOWNLOAD_PATH_TEMPLATE', true);
81
- return pathTemplate ? pathTemplate.replace(/\\?\$\{endpoint\}/, endpoint).replace(/\\?\$\{platform\}/, platform).replace(/\\?\$\{arch\}/, arch) : `${endpoint}?platform=${platform}&arch=${arch}`;
81
+ return pathTemplate ? pathTemplate.replace(/\\?\$\{endpoint\}/, endpoint).replace(/\\?\$\{platform\}/, platform).replace(/\\?\$\{arch\}/, arch).replace(/\\?\$\{version\}/, version) : `${endpoint}?platform=${platform}&arch=${arch}`;
82
82
  };
83
83
 
84
84
  const getUrl = (arch, version) => {
@@ -87,7 +87,8 @@ const getUrl = (arch, version) => {
87
87
  return version;
88
88
  }
89
89
 
90
- return version ? prepend(arch, `desktop/${version}`) : prepend(arch, 'desktop');
90
+ const urlPath = version ? `desktop/${version}` : 'desktop';
91
+ return prepend(arch, urlPath, version);
91
92
  };
92
93
 
93
94
  const statusMessage = err => {
@@ -1,3 +1,10 @@
1
+ # [@cypress/mount-utils-v2.0.1](https://github.com/cypress-io/cypress/compare/@cypress/mount-utils-v2.0.0...@cypress/mount-utils-v2.0.1) (2022-08-11)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * remove CT side effects from mount when e2e testing ([#22633](https://github.com/cypress-io/cypress/issues/22633)) ([a9476ec](https://github.com/cypress-io/cypress/commit/a9476ecb3d43f628b689e060294a1952937cb1a7))
7
+
1
8
  # [@cypress/mount-utils-v2.0.0](https://github.com/cypress-io/cypress/compare/@cypress/mount-utils-v1.0.2...@cypress/mount-utils-v2.0.0) (2022-06-13)
2
9
 
3
10