Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support Angular 19 with Cypress Component Testing #30675

Merged
merged 1 commit into from
Dec 2, 2024

Conversation

AtofStryker
Copy link
Contributor

@AtofStryker AtofStryker commented Nov 25, 2024

Additional details

Cypress 14 will support Angular 19 Component Testing OOTB, with autodetected framework, scaffolding, and setup

Screenshot 2024-11-26 at 9 54 09 AM Screenshot 2024-11-26 at 9 54 14 AM Screenshot 2024-11-26 at 1 39 11 PM

Steps to test

take the built binary and test this against a new angular 19 project with the angular cli with ng new (or run the project tests).

How has the user experience changed?

Cypress Component Testing users will now have angular 19 support built into scaffolding

The main difference with Angular 19 is that standalone components are the new default via setting standalone to true, effectively making the ngModule pattern obsolete. Angular 18 started scaffolding standalone components by default.

To make our system tests backwards compatible , I have set the standalone option in the component tests to false since they use the ngModule pattern since Angular 17.2-19 use the same project fixture directory. The standalone component option has been around since Angular 14, so this is not an issue for our supported older versions.

I also needed to move the angular.json out of the angular project fixture and into the angular-17-angular-19 directories since there are some slight differences in the json structure that are required to get the cypress-schematic to work correctly (buildTarget vs browserTarget

PR Tasks

@AtofStryker AtofStryker self-assigned this Nov 25, 2024
@AtofStryker AtofStryker added npm: @cypress/angular @cypress/angular package issues Cypress 14 Issues scoped for Cypress 14 labels Nov 25, 2024
Copy link

cypress bot commented Nov 25, 2024

cypress    Run #58606

Run Properties:  status check passed Passed #58606  •  git commit 7f453d7414: feat: support angular 19 and update tests [run ci]
Project cypress
Branch Review feat/support_angular_19
Run status status check passed Passed #58606
Run duration 19m 35s
Commit git commit 7f453d7414: feat: support angular 19 and update tests [run ci]
Committer AtofStryker
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 5
Tests that did not run due to a developer annotating a test with .skip  Pending 1326
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 29379
View all changes introduced in this branch ↗︎
UI Coverage  46.07%
  Untested elements 187  
  Tested elements 164  
Accessibility  92.55%
  Failed rules  3 critical   8 serious   2 moderate   2 minor
  Failed elements 892  

}).catch((e) => {
// If this promise does not settle in Angular 19 it is rejected
// https://github.com/angular/angular/blob/main/CHANGELOG.md#1900-2024-11-19
// eslint-disable-next-line no-console
Copy link
Contributor Author

@AtofStryker AtofStryker Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whenStable now rejects if it doesn't settle in Angular 19

we likely don't want to propagate this failure up and fail, just log it to the console. some users trigger stability manually for some difference use cases (see #30327)

@Component({ selector: 'cy-wrapper-component', template: '' })
// if using the Wrapper Component (template strings), the component itself cannot be
// a standalone component
@Component({ selector: 'cy-wrapper-component', template: '', standalone: false })
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since template strings require a references to the actual component in the test module, the component cannot be a standalone component

@@ -25,7 +25,7 @@ const runCommandInProject = (command: string, projectPath: string) => {

const cypressSchematicPackagePath = path.join(__dirname, '..')

const ANGULAR_PROJECTS: ProjectFixtureDir[] = ['angular-17', 'angular-18']
const ANGULAR_PROJECTS: ProjectFixtureDir[] = ['angular-18', 'angular-19']
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dropped 17 here for the schematic testing since it is time consuming and the schematic in 18 follows almost an identical pattern of that in 17

@@ -0,0 +1,96 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved from project-fixtures/angular/angular.json

@@ -104,6 +104,13 @@ describe(`Angular CLI versions`, () => {
browser: 'chrome',
expectedExitCode: 0,
})

systemTests.it('angular signals', {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I made a booboo when I merged #29621. I wrote the system test but didn't actually add the code to run it 🙈

@AtofStryker AtofStryker force-pushed the feat/support_angular_19 branch from 5cf8490 to 438f978 Compare November 26, 2024 14:58
@AtofStryker AtofStryker marked this pull request as ready for review November 26, 2024 18:40
@AtofStryker AtofStryker linked an issue Dec 2, 2024 that may be closed by this pull request
@AtofStryker AtofStryker force-pushed the feat/support_angular_19 branch from 438f978 to 0abd1d7 Compare December 2, 2024 16:07
@AtofStryker AtofStryker force-pushed the feat/support_angular_19 branch from 0abd1d7 to 7f453d7 Compare December 2, 2024 17:57
@AtofStryker AtofStryker merged commit dcdefb4 into release/14.0.0 Dec 2, 2024
113 of 117 checks passed
@AtofStryker AtofStryker deleted the feat/support_angular_19 branch December 2, 2024 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cypress 14 Issues scoped for Cypress 14 npm: @cypress/angular @cypress/angular package issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Angular 19 Component Testing
2 participants