diff --git a/npm/angular18/.eslintignore b/npm/angular18/.eslintignore new file mode 100644 index 000000000000..79afe972da7d --- /dev/null +++ b/npm/angular18/.eslintignore @@ -0,0 +1,5 @@ +**/dist +**/*.d.ts +**/package-lock.json +**/tsconfig.json +**/cypress/fixtures \ No newline at end of file diff --git a/npm/angular18/.eslintrc b/npm/angular18/.eslintrc new file mode 100644 index 000000000000..f044f320923e --- /dev/null +++ b/npm/angular18/.eslintrc @@ -0,0 +1,8 @@ +{ + "plugins": [ + "cypress" + ], + "extends": [ + "plugin:@cypress/dev/tests" + ] +} diff --git a/npm/angular18/.npmignore b/npm/angular18/.npmignore new file mode 100644 index 000000000000..d4372c984ed9 --- /dev/null +++ b/npm/angular18/.npmignore @@ -0,0 +1,3 @@ +examples +src +cypress \ No newline at end of file diff --git a/npm/angular18/.releaserc.js b/npm/angular18/.releaserc.js new file mode 100644 index 000000000000..17d3bb871472 --- /dev/null +++ b/npm/angular18/.releaserc.js @@ -0,0 +1,3 @@ +module.exports = { + ...require('../../.releaserc'), +} diff --git a/npm/angular18/CHANGELOG.md b/npm/angular18/CHANGELOG.md new file mode 100644 index 000000000000..5e701e80e586 --- /dev/null +++ b/npm/angular18/CHANGELOG.md @@ -0,0 +1,185 @@ +# [@cypress/angular-v2.0.3](https://github.com/cypress-io/cypress/compare/@cypress/angular-v2.0.2...@cypress/angular-v2.0.3) (2023-03-14) + + +### Bug Fixes + +* **angular:** mount cy-root in original location ([#25965](https://github.com/cypress-io/cypress/issues/25965)) ([e674f43](https://github.com/cypress-io/cypress/commit/e674f43040ad95d2745601aa0f36eab4703c837e)) + +# [@cypress/angular-v2.0.2](https://github.com/cypress-io/cypress/compare/@cypress/angular-v2.0.1...@cypress/angular-v2.0.2) (2023-02-17) + + +### Bug Fixes + +* mount component in [data-cy-root] ([#25807](https://github.com/cypress-io/cypress/issues/25807)) ([104eef5](https://github.com/cypress-io/cypress/commit/104eef5dfb4b619a748e7ddd59534eadb1044ae7)) + +# [@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) + + +### Bug Fixes + +* make component derived info not throw ([#24571](https://github.com/cypress-io/cypress/issues/24571)) ([838dd4f](https://github.com/cypress-io/cypress/commit/838dd4fa2e0ec56633d0af2faf10a47d190b5594)) + +# [@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) + + +### Bug Fixes + +* 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)) +* 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)) + + +### BREAKING CHANGES + +* remove last mounted component upon subsequent mount calls of mount + +# [@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) + + +### Bug Fixes + +* 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)) + +# [@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) + + +### Bug Fixes + +* **angular:** call ngOnChanges after mount ([#23596](https://github.com/cypress-io/cypress/issues/23596)) ([670d438](https://github.com/cypress-io/cypress/commit/670d43830947c3ea93ef9fdc9c90932a817eb453)) + +# [@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) + + +### Bug Fixes + +* angular 14.2 mount compilation error ([#23593](https://github.com/cypress-io/cypress/issues/23593)) ([2f337db](https://github.com/cypress-io/cypress/commit/2f337dbfa2bb212754c8fa82e3f4548a2f3a07a4)) +* 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)) + + +### Features + +* adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8)) + +# [@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) + + +### Bug Fixes + +* angular 14.2 mount compilation error ([#23593](https://github.com/cypress-io/cypress/issues/23593)) ([2f337db](https://github.com/cypress-io/cypress/commit/2f337dbfa2bb212754c8fa82e3f4548a2f3a07a4)) +* 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)) + + +### Features + +* adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8)) + +# [@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) + + +### Bug Fixes + +* angular 14.2 mount compilation error ([#23593](https://github.com/cypress-io/cypress/issues/23593)) ([2f337db](https://github.com/cypress-io/cypress/commit/2f337dbfa2bb212754c8fa82e3f4548a2f3a07a4)) +* 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)) + + +### Features + +* adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8)) + +# [@cypress/angular-v1.1.0](https://github.com/cypress-io/cypress/compare/@cypress/angular-v1.0.0...@cypress/angular-v1.1.0) (2022-08-30) + + +### Bug Fixes + +* angular 14.2 mount compilation error ([#23593](https://github.com/cypress-io/cypress/issues/23593)) ([2f337db](https://github.com/cypress-io/cypress/commit/2f337dbfa2bb212754c8fa82e3f4548a2f3a07a4)) + + +### Features + +* adding svelte component testing support ([#23553](https://github.com/cypress-io/cypress/issues/23553)) ([f6eaad4](https://github.com/cypress-io/cypress/commit/f6eaad40e1836fa9db87c60defa5ae6f390c8fd8)) + +# @cypress/angular-v1.0.0 (2022-08-17) + + +### Bug Fixes + +* **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)) +* 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)) +* scaffold correct config file ([#19776](https://github.com/cypress-io/cypress/issues/19776)) ([8f32960](https://github.com/cypress-io/cypress/commit/8f32960ef803f539f065d41f01fff33bfe33ed5d)) +* scope config to current testing type ([#20677](https://github.com/cypress-io/cypress/issues/20677)) ([61f7cfc](https://github.com/cypress-io/cypress/commit/61f7cfc59284a2938e0a1c15d74ee75215ba5f8b)) +* 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)) +* 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)) + + +### Features + +* add devServer to config file ([#18962](https://github.com/cypress-io/cypress/issues/18962)) ([2573375](https://github.com/cypress-io/cypress/commit/2573375b5b6616efd2d213a94cd55fd8e0385864)) +* add template support, teardown & standalone ([#23117](https://github.com/cypress-io/cypress/issues/23117)) ([d201b37](https://github.com/cypress-io/cypress/commit/d201b37b3d6b1e37a15a8d21d853acca47bfc666)) +* **angular:** angular mount ([#22858](https://github.com/cypress-io/cypress/issues/22858)) ([4131b1f](https://github.com/cypress-io/cypress/commit/4131b1fa8482ae08113bef337965baa1ac12f66c)) +* 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)) +* enable Angular CT support ([#23089](https://github.com/cypress-io/cypress/issues/23089)) ([94e78eb](https://github.com/cypress-io/cypress/commit/94e78eba0430eae97529058c40611e5f24dbf140)) +* ProjectLifecycleManager & general launchpad cleanup ([#19347](https://github.com/cypress-io/cypress/issues/19347)) ([4626f74](https://github.com/cypress-io/cypress/commit/4626f7481c9904fec484aa167a02e0197a3095c4)) +* remove testFiles reference ([#20565](https://github.com/cypress-io/cypress/issues/20565)) ([5670344](https://github.com/cypress-io/cypress/commit/567034459089d9d53dfab5556cb9369fb335c3db)) +* support specPattern, deprecate integrationFolder and componentFolder ([#19319](https://github.com/cypress-io/cypress/issues/19319)) ([792980a](https://github.com/cypress-io/cypress/commit/792980ac12746ef47b9c944ebe4c6c353a187ab2)) +* support webpack-dev-server v4 ([#17918](https://github.com/cypress-io/cypress/issues/17918)) ([16e4759](https://github.com/cypress-io/cypress/commit/16e4759e0196f68c5f0525efb020211337748f94)) +* 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)) +* Use .config files ([#18578](https://github.com/cypress-io/cypress/issues/18578)) ([081dd19](https://github.com/cypress-io/cypress/commit/081dd19cc6da3da229a7af9c84f62730c85a5cd6)) +* use devServer instad of startDevServer ([#20092](https://github.com/cypress-io/cypress/issues/20092)) ([8a6768f](https://github.com/cypress-io/cypress/commit/8a6768fee6f46b908c5a9daf23da8b804a6c627f)) +* 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)) +* Use plugins on config files ([#18798](https://github.com/cypress-io/cypress/issues/18798)) ([bb8251b](https://github.com/cypress-io/cypress/commit/bb8251b752ac44f1184f9160194cf12d41fc867f)) +* use supportFile by testingType ([#19364](https://github.com/cypress-io/cypress/issues/19364)) ([0366d4f](https://github.com/cypress-io/cypress/commit/0366d4fa8971e5e5189c6fd6450cc3c8d72dcfe1)) + +# @cypress/angular-v1.0.0 (2022-08-04) + + +### Bug Fixes + +* **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)) +* scaffold correct config file ([#19776](https://github.com/cypress-io/cypress/issues/19776)) ([8f32960](https://github.com/cypress-io/cypress/commit/8f32960ef803f539f065d41f01fff33bfe33ed5d)) +* scope config to current testing type ([#20677](https://github.com/cypress-io/cypress/issues/20677)) ([61f7cfc](https://github.com/cypress-io/cypress/commit/61f7cfc59284a2938e0a1c15d74ee75215ba5f8b)) +* 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)) +* 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)) + + +### Features + +* add devServer to config file ([#18962](https://github.com/cypress-io/cypress/issues/18962)) ([2573375](https://github.com/cypress-io/cypress/commit/2573375b5b6616efd2d213a94cd55fd8e0385864)) +* **angular:** angular mount ([#22858](https://github.com/cypress-io/cypress/issues/22858)) ([4131b1f](https://github.com/cypress-io/cypress/commit/4131b1fa8482ae08113bef337965baa1ac12f66c)) +* 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)) +* ProjectLifecycleManager & general launchpad cleanup ([#19347](https://github.com/cypress-io/cypress/issues/19347)) ([4626f74](https://github.com/cypress-io/cypress/commit/4626f7481c9904fec484aa167a02e0197a3095c4)) +* remove testFiles reference ([#20565](https://github.com/cypress-io/cypress/issues/20565)) ([5670344](https://github.com/cypress-io/cypress/commit/567034459089d9d53dfab5556cb9369fb335c3db)) +* support specPattern, deprecate integrationFolder and componentFolder ([#19319](https://github.com/cypress-io/cypress/issues/19319)) ([792980a](https://github.com/cypress-io/cypress/commit/792980ac12746ef47b9c944ebe4c6c353a187ab2)) +* support webpack-dev-server v4 ([#17918](https://github.com/cypress-io/cypress/issues/17918)) ([16e4759](https://github.com/cypress-io/cypress/commit/16e4759e0196f68c5f0525efb020211337748f94)) +* 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)) +* Use .config files ([#18578](https://github.com/cypress-io/cypress/issues/18578)) ([081dd19](https://github.com/cypress-io/cypress/commit/081dd19cc6da3da229a7af9c84f62730c85a5cd6)) +* use devServer instad of startDevServer ([#20092](https://github.com/cypress-io/cypress/issues/20092)) ([8a6768f](https://github.com/cypress-io/cypress/commit/8a6768fee6f46b908c5a9daf23da8b804a6c627f)) +* 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)) +* Use plugins on config files ([#18798](https://github.com/cypress-io/cypress/issues/18798)) ([bb8251b](https://github.com/cypress-io/cypress/commit/bb8251b752ac44f1184f9160194cf12d41fc867f)) +* use supportFile by testingType ([#19364](https://github.com/cypress-io/cypress/issues/19364)) ([0366d4f](https://github.com/cypress-io/cypress/commit/0366d4fa8971e5e5189c6fd6450cc3c8d72dcfe1)) + +# @cypress/angular-v1.0.0 (2022-08-04) + + +### Bug Fixes + +* **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)) +* scaffold correct config file ([#19776](https://github.com/cypress-io/cypress/issues/19776)) ([8f32960](https://github.com/cypress-io/cypress/commit/8f32960ef803f539f065d41f01fff33bfe33ed5d)) +* scope config to current testing type ([#20677](https://github.com/cypress-io/cypress/issues/20677)) ([61f7cfc](https://github.com/cypress-io/cypress/commit/61f7cfc59284a2938e0a1c15d74ee75215ba5f8b)) +* 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)) +* 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)) + + +### Features + +* add devServer to config file ([#18962](https://github.com/cypress-io/cypress/issues/18962)) ([2573375](https://github.com/cypress-io/cypress/commit/2573375b5b6616efd2d213a94cd55fd8e0385864)) +* **angular:** angular mount ([#22858](https://github.com/cypress-io/cypress/issues/22858)) ([4131b1f](https://github.com/cypress-io/cypress/commit/4131b1fa8482ae08113bef337965baa1ac12f66c)) +* 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)) +* ProjectLifecycleManager & general launchpad cleanup ([#19347](https://github.com/cypress-io/cypress/issues/19347)) ([4626f74](https://github.com/cypress-io/cypress/commit/4626f7481c9904fec484aa167a02e0197a3095c4)) +* remove testFiles reference ([#20565](https://github.com/cypress-io/cypress/issues/20565)) ([5670344](https://github.com/cypress-io/cypress/commit/567034459089d9d53dfab5556cb9369fb335c3db)) +* support specPattern, deprecate integrationFolder and componentFolder ([#19319](https://github.com/cypress-io/cypress/issues/19319)) ([792980a](https://github.com/cypress-io/cypress/commit/792980ac12746ef47b9c944ebe4c6c353a187ab2)) +* support webpack-dev-server v4 ([#17918](https://github.com/cypress-io/cypress/issues/17918)) ([16e4759](https://github.com/cypress-io/cypress/commit/16e4759e0196f68c5f0525efb020211337748f94)) +* 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)) +* Use .config files ([#18578](https://github.com/cypress-io/cypress/issues/18578)) ([081dd19](https://github.com/cypress-io/cypress/commit/081dd19cc6da3da229a7af9c84f62730c85a5cd6)) +* use devServer instad of startDevServer ([#20092](https://github.com/cypress-io/cypress/issues/20092)) ([8a6768f](https://github.com/cypress-io/cypress/commit/8a6768fee6f46b908c5a9daf23da8b804a6c627f)) +* 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)) +* Use plugins on config files ([#18798](https://github.com/cypress-io/cypress/issues/18798)) ([bb8251b](https://github.com/cypress-io/cypress/commit/bb8251b752ac44f1184f9160194cf12d41fc867f)) +* use supportFile by testingType ([#19364](https://github.com/cypress-io/cypress/issues/19364)) ([0366d4f](https://github.com/cypress-io/cypress/commit/0366d4fa8971e5e5189c6fd6450cc3c8d72dcfe1)) diff --git a/npm/angular18/README.md b/npm/angular18/README.md new file mode 100644 index 000000000000..2e75bfe830b1 --- /dev/null +++ b/npm/angular18/README.md @@ -0,0 +1,10 @@ +# @cypress/angular + +Mount Angular components in the open source [Cypress.io](https://www.cypress.io/) test runner + +> **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. +## Development + +Run `yarn build` to compile and sync packages to the `cypress` cli package. + +## [Changelog](./CHANGELOG.md) diff --git a/npm/angular18/package.json b/npm/angular18/package.json new file mode 100644 index 000000000000..525a1ef748a9 --- /dev/null +++ b/npm/angular18/package.json @@ -0,0 +1,76 @@ +{ + "name": "@cypress/angular", + "version": "0.0.0-development", + "description": "Test Angular Components using Cypress", + "main": "dist/index.js", + "scripts": { + "prebuild": "rimraf dist", + "build": "rollup -c rollup.config.mjs", + "postbuild": "node ../../scripts/sync-exported-npm-with-cli.js", + "check-ts": "tsc --noEmit", + "lint": "eslint --ext .js,.ts,.json, ." + }, + "dependencies": {}, + "devDependencies": { + "@angular/common": "^14.2.0", + "@angular/core": "^14.2.0", + "@angular/platform-browser-dynamic": "^14.2.0", + "@cypress/mount-utils": "0.0.0-development", + "typescript": "^4.7.4", + "zone.js": "~0.11.4" + }, + "peerDependencies": { + "@angular/common": ">=13", + "@angular/core": ">=13", + "@angular/platform-browser-dynamic": ">=13", + "zone.js": ">=0.11.0" + }, + "files": [ + "dist" + ], + "types": "dist/index.d.ts", + "license": "MIT", + "repository": { + "type": "git", + "url": "https://github.com/cypress-io/cypress.git" + }, + "homepage": "https://github.com/cypress-io/cypress/blob/develop/npm/angular/#readme", + "bugs": "https://github.com/cypress-io/cypress/issues/new?assignees=&labels=npm%3A%20%40cypress%2Fangular&template=1-bug-report.md&title=", + "keywords": [ + "angular", + "cypress", + "cypress-io", + "test", + "testing" + ], + "contributors": [ + { + "name": "Jordan Powell", + "social": "@jordanpowell88" + }, + { + "name": "Zach Williams", + "social": "@ZachJW34" + } + ], + "module": "dist/index.js", + "publishConfig": { + "access": "public" + }, + "nx": { + "targets": { + "build": { + "outputs": [ + "{workspaceRoot}/cli/angular" + ] + } + } + }, + "standard": { + "globals": [ + "Cypress", + "cy", + "expect" + ] + } +} diff --git a/npm/angular18/rollup.config.mjs b/npm/angular18/rollup.config.mjs new file mode 100644 index 000000000000..4ef324cfd1a3 --- /dev/null +++ b/npm/angular18/rollup.config.mjs @@ -0,0 +1,14 @@ +import { createEntries } from '@cypress/mount-utils/create-rollup-entry.mjs' + +const config = { + external: [ + '@angular/core', + '@angular/core/testing', + '@angular/common', + '@angular/platform-browser-dynamic/testing', + 'zone.js', + 'zone.js/testing', + ], +} + +export default createEntries({ formats: ['es'], input: 'src/index.ts', config }) diff --git a/npm/angular18/src/index.ts b/npm/angular18/src/index.ts new file mode 100644 index 000000000000..1af962e1d530 --- /dev/null +++ b/npm/angular18/src/index.ts @@ -0,0 +1 @@ +export * from './mount' diff --git a/npm/angular18/src/mount.ts b/npm/angular18/src/mount.ts new file mode 100644 index 000000000000..8ba0f0dab89a --- /dev/null +++ b/npm/angular18/src/mount.ts @@ -0,0 +1,395 @@ +import 'zone.js' + +/** + * @hack fixes "Mocha has already been patched with Zone" error. + */ +// @ts-ignore +window.Mocha['__zone_patch__'] = false +import 'zone.js/testing' + +import { CommonModule } from '@angular/common' +import { Component, ErrorHandler, EventEmitter, Injectable, SimpleChange, SimpleChanges, Type, OnChanges } from '@angular/core' +import { + ComponentFixture, + getTestBed, + TestModuleMetadata, + TestBed, + TestComponentRenderer, +} from '@angular/core/testing' +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting, +} from '@angular/platform-browser-dynamic/testing' +import { + setupHooks, + getContainerEl, +} from '@cypress/mount-utils' + +/** + * Additional module configurations needed while mounting the component, like + * providers, declarations, imports and even component @Inputs() + * + * + * @interface MountConfig + * @see https://angular.io/api/core/testing/TestModuleMetadata + */ +export interface MountConfig extends TestModuleMetadata { + /** + * @memberof MountConfig + * @description flag to automatically create a cy.spy() for every component @Output() property + * @example + * export class ButtonComponent { + * @Output clicked = new EventEmitter() + * } + * + * cy.mount(ButtonComponent, { autoSpyOutputs: true }) + * cy.get('@clickedSpy).should('have.been.called') + */ + autoSpyOutputs?: boolean + + /** + * @memberof MountConfig + * @description flag defaulted to true to automatically detect changes in your components + */ + autoDetectChanges?: boolean + /** + * @memberof MountConfig + * @example + * import { ButtonComponent } from 'button/button.component' + * it('renders a button with Save text', () => { + * cy.mount(ButtonComponent, { componentProperties: { text: 'Save' }}) + * cy.get('button').contains('Save') + * }) + * + * it('renders a button with a cy.spy() replacing EventEmitter', () => { + * cy.mount(ButtonComponent, { + * componentProperties: { + * clicked: cy.spy().as('mySpy) + * } + * }) + * cy.get('button').click() + * cy.get('@mySpy').should('have.been.called') + * }) + */ + componentProperties?: Partial<{ [P in keyof T]: T[P] }> +} + +let activeFixture: ComponentFixture | null = null + +function cleanup () { + // Not public, we need to call this to remove the last component from the DOM + try { + (getTestBed() as any).tearDownTestingModule() + } catch (e) { + const notSupportedError = new Error(`Failed to teardown component. The version of Angular you are using may not be officially supported.`) + + ;(notSupportedError as any).docsUrl = 'https://on.cypress.io/component-framework-configuration' + throw notSupportedError + } + + getTestBed().resetTestingModule() + activeFixture = null +} + +/** + * Type that the `mount` function returns + * @type MountResponse + */ +export type MountResponse = { + /** + * Fixture for debugging and testing a component. + * + * @memberof MountResponse + * @see https://angular.io/api/core/testing/ComponentFixture + */ + fixture: ComponentFixture + + /** + * The instance of the root component class + * + * @memberof MountResponse + * @see https://angular.io/api/core/testing/ComponentFixture#componentInstance + */ + component: T +}; + +// 'zone.js/testing' is not properly aliasing `it.skip` but it does provide `xit`/`xspecify` +// Written up under https://github.com/angular/angular/issues/46297 but is not seeing movement +// so we'll patch here pending a fix in that library +// @ts-ignore Ignore so that way we can bypass semantic error TS7017: Element implicitly has an 'any' type because type 'typeof globalThis' has no index signature. +globalThis.it.skip = globalThis.xit + +@Injectable() +class CypressAngularErrorHandler implements ErrorHandler { + handleError (error: Error): void { + throw error + } +} + +/** + * Bootstraps the TestModuleMetaData passed to the TestBed + * + * @param {Type} component Angular component being mounted + * @param {MountConfig} config TestBed configuration passed into the mount function + * @returns {MountConfig} MountConfig + */ +function bootstrapModule ( + component: Type, + config: MountConfig, +): MountConfig { + const { componentProperties, ...testModuleMetaData } = config + + if (!testModuleMetaData.declarations) { + testModuleMetaData.declarations = [] + } + + if (!testModuleMetaData.imports) { + testModuleMetaData.imports = [] + } + + if (!testModuleMetaData.providers) { + testModuleMetaData.providers = [] + } + + // Replace default error handler since it will swallow uncaught exceptions. + // We want these to be uncaught so Cypress catches it and fails the test + testModuleMetaData.providers.push({ + provide: ErrorHandler, + useClass: CypressAngularErrorHandler, + }) + + // check if the component is a standalone component + if ((component as any).ɵcmp?.standalone) { + testModuleMetaData.imports.push(component) + } else { + testModuleMetaData.declarations.push(component) + } + + if (!testModuleMetaData.imports.includes(CommonModule)) { + testModuleMetaData.imports.push(CommonModule) + } + + return testModuleMetaData +} + +@Injectable() +export class CypressTestComponentRenderer extends TestComponentRenderer { + override insertRootElement (rootElId: string) { + this.removeAllRootElements() + + const rootElement = getContainerEl() + + rootElement.setAttribute('id', rootElId) + } + + override removeAllRootElements () { + getContainerEl().innerHTML = '' + } +} + +/** + * Initializes the TestBed + * + * @param {Type | string} component Angular component being mounted or its template + * @param {MountConfig} config TestBed configuration passed into the mount function + * @returns {Type} componentFixture + */ +function initTestBed ( + component: Type | string, + config: MountConfig, +): Type { + const componentFixture = createComponentFixture(component) as Type + + getTestBed().configureTestingModule({ + ...bootstrapModule(componentFixture, config), + }) + + getTestBed().overrideProvider(TestComponentRenderer, { useValue: new CypressTestComponentRenderer() }) + + return componentFixture +} + +@Component({ selector: 'cy-wrapper-component', template: '' }) +class WrapperComponent { } + +/** + * Returns the Component if Type or creates a WrapperComponent + * + * @param {Type | string} component The component you want to create a fixture of + * @returns {Type | WrapperComponent} + */ +function createComponentFixture ( + component: Type | string, +): Type { + if (typeof component === 'string') { + // getTestBed().overrideTemplate is available in v14+ + // The static TestBed.overrideTemplate is available across versions + TestBed.overrideTemplate(WrapperComponent, component) + + return WrapperComponent + } + + return component +} + +/** + * Creates the ComponentFixture + * + * @param {Type} component Angular component being mounted + * @param {MountConfig} config MountConfig + + * @returns {ComponentFixture} ComponentFixture + */ +function setupFixture ( + component: Type, + config: MountConfig, +): ComponentFixture { + const fixture = getTestBed().createComponent(component) + + setupComponent(config, fixture) + + fixture.whenStable().then(() => { + fixture.autoDetectChanges(config.autoDetectChanges ?? true) + }) + + return fixture +} + +/** + * Gets the componentInstance and Object.assigns any componentProperties() passed in the MountConfig + * + * @param {MountConfig} config TestBed configuration passed into the mount function + * @param {ComponentFixture} fixture Fixture for debugging and testing a component. + * @returns {T} Component being mounted + */ +function setupComponent ( + config: MountConfig, + fixture: ComponentFixture, +): void { + let component = fixture.componentInstance as unknown as { [key: string]: any } & Partial + + if (config?.componentProperties) { + component = Object.assign(component, config.componentProperties) + } + + if (config.autoSpyOutputs) { + Object.keys(component).forEach((key) => { + const property = component[key] + + if (property instanceof EventEmitter) { + component[key] = createOutputSpy(`${key}Spy`) + } + }) + } + + // Manually call ngOnChanges when mounting components using the class syntax. + // This is necessary because we are assigning input values to the class directly + // on mount and therefore the ngOnChanges() lifecycle is not triggered. + if (component.ngOnChanges && config.componentProperties) { + const { componentProperties } = config + + const simpleChanges: SimpleChanges = Object.entries(componentProperties).reduce((acc, [key, value]) => { + acc[key] = new SimpleChange(null, value, true) + + return acc + }, {} as {[key: string]: SimpleChange}) + + if (Object.keys(componentProperties).length > 0) { + component.ngOnChanges(simpleChanges) + } + } +} + +/** + * Mounts an Angular component inside Cypress browser + * + * @param component Angular component being mounted or its template + * @param config configuration used to configure the TestBed + * @example + * import { mount } from '@cypress/angular' + * import { StepperComponent } from './stepper.component' + * import { MyService } from 'services/my.service' + * import { SharedModule } from 'shared/shared.module'; + * it('mounts', () => { + * mount(StepperComponent, { + * providers: [MyService], + * imports: [SharedModule] + * }) + * cy.get('[data-cy=increment]').click() + * cy.get('[data-cy=counter]').should('have.text', '1') + * }) + * + * // or + * + * it('mounts with template', () => { + * mount('', { + * declarations: [StepperComponent], + * }) + * }) + * + * @see {@link https://on.cypress.io/mounting-angular} for more details. + * + * @returns A component and component fixture + */ +export function mount ( + component: Type | string, + config: MountConfig = { }, +): Cypress.Chainable> { + // Remove last mounted component if cy.mount is called more than once in a test + if (activeFixture) { + cleanup() + } + + const componentFixture = initTestBed(component, config) + + activeFixture = setupFixture(componentFixture, config) + + const mountResponse: MountResponse = { + fixture: activeFixture, + component: activeFixture.componentInstance, + } + + const logMessage = typeof component === 'string' ? 'Component' : componentFixture.name + + Cypress.log({ + name: 'mount', + message: logMessage, + consoleProps: () => ({ result: mountResponse }), + }) + + return cy.wrap(mountResponse, { log: false }) +} + +/** + * Creates a new Event Emitter and then spies on it's `emit` method + * + * @param {string} alias name you want to use for your cy.spy() alias + * @returns EventEmitter + * @example + * import { StepperComponent } from './stepper.component' + * import { mount, createOutputSpy } from '@cypress/angular' + * + * it('Has spy', () => { + * mount(StepperComponent, { componentProperties: { change: createOutputSpy('changeSpy') } }) + * cy.get('[data-cy=increment]').click() + * cy.get('@changeSpy').should('have.been.called') + * }) + */ +export const createOutputSpy = (alias: string) => { + const emitter = new EventEmitter() + + cy.spy(emitter, 'emit').as(alias) + + return emitter as any +} + +// Only needs to run once, we reset before each test +getTestBed().initTestEnvironment( + BrowserDynamicTestingModule, + platformBrowserDynamicTesting(), + { + teardown: { destroyAfterEach: false }, + }, +) + +setupHooks(cleanup) diff --git a/npm/angular18/tsconfig.json b/npm/angular18/tsconfig.json new file mode 100644 index 000000000000..a73e01dcecc9 --- /dev/null +++ b/npm/angular18/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "experimentalDecorators": true, + "target": "es2020", + "module": "es2020", + "skipLibCheck": true, + "lib": [ + "ESNext", + "DOM" + ], + "allowJs": true, + "declaration": true, + "outDir": "dist", + "strict": true, + "baseUrl": "./", + "types": [ + "cypress" + ], + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "moduleResolution": "node", + "noPropertyAccessFromIndexSignature": true, + }, + "include": ["src/**/*.*"], + "exclude": ["src/**/*-spec.*"] +}