Skip to content

test(angular): Add Angular 20.0.0-rc.2 e2e test #16364

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

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,13 @@ jobs:
- uses: pnpm/action-setup@v4
with:
version: 9.4.0
- name: Set up Node for Angular 20
if: matrix.test-application == 'angular-20'
uses: actions/setup-node@v4
with:
node-version: '20.19.2'
- name: Set up Node
if: matrix.test-application != 'angular-20'
uses: actions/setup-node@v4
with:
node-version-file: 'dev-packages/e2e-tests/package.json'
Expand Down
17 changes: 17 additions & 0 deletions dev-packages/e2e-tests/test-applications/angular-20/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Editor configuration, see https://editorconfig.org
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

[*.ts]
quote_type = single
ij_typescript_use_double_quotes = false

[*.md]
max_line_length = off
trim_trailing_whitespace = false
44 changes: 44 additions & 0 deletions dev-packages/e2e-tests/test-applications/angular-20/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.

# Compiled output
/dist
/tmp
/out-tsc
/bazel-out

# Node
/node_modules
npm-debug.log
yarn-error.log

# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# Miscellaneous
/.angular/cache
.sass-cache/
/connect.lock
/coverage
/libpeerconnection.log
testem.log
/typings

# System files
.DS_Store
Thumbs.db

test-results
2 changes: 2 additions & 0 deletions dev-packages/e2e-tests/test-applications/angular-20/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@sentry:registry=http://127.0.0.1:4873
@sentry-internal:registry=http://127.0.0.1:4873
3 changes: 3 additions & 0 deletions dev-packages/e2e-tests/test-applications/angular-20/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Angular 20

E2E test app for Angular 20 and `@sentry/angular`.
87 changes: 87 additions & 0 deletions dev-packages/e2e-tests/test-applications/angular-20/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"angular-20": {
"projectType": "application",
"schematics": {},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:application",
"options": {
"outputPath": "dist/angular-20",
"index": "src/index.html",
"browser": "src/main.ts",
"polyfills": ["zone.js"],
"tsConfig": "tsconfig.app.json",
"assets": [
{
"glob": "**/*",
"input": "public"
}
],
"styles": ["src/styles.css"],
"scripts": []
},
"configurations": {
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kB",
"maximumError": "1MB"
},
{
"type": "anyComponentStyle",
"maximumWarning": "4kB",
"maximumError": "8kB"
}
],
"outputHashing": "all"
},
"development": {
"optimization": false,
"extractLicenses": false,
"sourceMap": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"production": {
"buildTarget": "angular-20:build:production"
},
"development": {
"buildTarget": "angular-20:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n"
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"polyfills": ["zone.js", "zone.js/testing"],
"tsConfig": "tsconfig.spec.json",
"assets": [
{
"glob": "**/*",
"input": "public"
}
],
"styles": ["src/styles.css"],
"scripts": []
}
}
}
}
}
}
50 changes: 50 additions & 0 deletions dev-packages/e2e-tests/test-applications/angular-20/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"name": "angular-20",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"dev": "ng serve",
"proxy": "node start-event-proxy.mjs",
"preview": "http-server dist/angular-20/browser --port 8080",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "playwright test",
"test:build": "pnpm install && pnpm build",
"test:assert": "playwright test",
"clean": "npx rimraf .angular node_modules pnpm-lock.yaml dist"
},
"private": true,
"dependencies": {
"@angular/animations": "^20.0.0-rc.2",
"@angular/common": "^20.0.0-rc.2",
"@angular/compiler": "^20.0.0-rc.2",
"@angular/core": "^20.0.0-rc.2",
Copy link
Member

Choose a reason for hiding this comment

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

wdyt about generally adding canary tests here with "@angular/<package>": "next"?

Copy link
Member Author

Choose a reason for hiding this comment

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

we could! Let me take a look how easy this would be. My only concern is that sometimes, it's not just the package versions that need updating but also the app config/module files. But I guess we'd probably see this in the canary tests. Will open a separate PR for canary tests though, as I wanna convert this application to 20 stable when it's released.

Copy link
Member

Choose a reason for hiding this comment

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

we can use the same format we use for other tests to run this for actual canary, the "normal" tests should not use canary as that may fail and we do not want to block on this!

"@angular/forms": "^20.0.0-rc.2",
"@angular/platform-browser": "^20.0.0-rc.2",
"@angular/platform-browser-dynamic": "^20.0.0-rc.2",
"@angular/router": "^20.0.0-rc.2",
"@sentry/angular": "* || latest",
"rxjs": "~7.8.0",
"tslib": "^2.3.0",
"zone.js": "~0.15.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^20.0.0-rc.2",
"@angular/cli": "^20.0.0-rc.2",
"@angular/compiler-cli": "^20.0.0-rc.2",
"@playwright/test": "~1.50.0",
"@sentry-internal/test-utils": "link:../../../test-utils",
"@types/jasmine": "~5.1.0",
"http-server": "^14.1.1",
"jasmine-core": "~5.4.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.2.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.1.0",
"typescript": "~5.8.3"
},
"volta": {
"extends": "../../package.json"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { getPlaywrightConfig } from '@sentry-internal/test-utils';

const config = getPlaywrightConfig({
startCommand: `pnpm preview`,
port: 8080,
});

export default config;
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';

@Component({
selector: 'app-root',
standalone: true,
imports: [RouterOutlet],
template: `<router-outlet></router-outlet>`,
})
export class AppComponent {
title = 'angular-20';
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import {
ApplicationConfig,
ErrorHandler,
inject,
provideAppInitializer,
provideZoneChangeDetection,
} from '@angular/core';
import { Router, provideRouter } from '@angular/router';

import { TraceService, createErrorHandler } from '@sentry/angular';
import { routes } from './app.routes';

export const appConfig: ApplicationConfig = {
providers: [
provideZoneChangeDetection({ eventCoalescing: true }),
provideRouter(routes),
{
provide: ErrorHandler,
useValue: createErrorHandler(),
},
{
provide: TraceService,
deps: [Router],
},
provideAppInitializer(() => {
inject(TraceService);
}),
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Routes } from '@angular/router';
import { cancelGuard } from './cancel-guard.guard';
import { CancelComponent } from './cancel/cancel.components';
import { ComponentTrackingComponent } from './component-tracking/component-tracking.components';
import { HomeComponent } from './home/home.component';
import { UserComponent } from './user/user.component';

export const routes: Routes = [
{
path: 'users/:id',
component: UserComponent,
},
{
path: 'home',
component: HomeComponent,
},
{
path: 'cancel',
component: CancelComponent,
canActivate: [cancelGuard],
},
{
path: 'component-tracking',
component: ComponentTrackingComponent,
},
{
path: 'redirect1',
redirectTo: '/redirect2',
},
{
path: 'redirect2',
redirectTo: '/redirect3',
},
{
path: 'redirect3',
redirectTo: '/users/456',
},
{
path: '**',
redirectTo: 'home',
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { ActivatedRouteSnapshot, CanActivateFn, RouterStateSnapshot } from '@angular/router';

export const cancelGuard: CanActivateFn = (_next: ActivatedRouteSnapshot, _state: RouterStateSnapshot) => {
return false;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-cancel',
standalone: true,
template: `<div></div>`,
})
export class CancelComponent {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { AfterViewInit, Component, OnInit } from '@angular/core';
import { TraceClass, TraceMethod, TraceModule } from '@sentry/angular';
import { SampleComponent } from '../sample-component/sample-component.components';

@Component({
selector: 'app-component-tracking',
standalone: true,
imports: [TraceModule, SampleComponent],
template: `
<app-sample-component trace="sample-component"></app-sample-component>
<app-sample-component trace></app-sample-component>
`,
})
@TraceClass({ name: 'ComponentTrackingComponent' })
export class ComponentTrackingComponent implements OnInit, AfterViewInit {
@TraceMethod({ name: 'ngOnInit' })
ngOnInit() {}

@TraceMethod()
ngAfterViewInit() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Component } from '@angular/core';
import { RouterLink } from '@angular/router';

@Component({
selector: 'app-home',
standalone: true,
imports: [RouterLink],
template: `
<main>
<h1>Welcome to Sentry's Angular 20 E2E test app</h1>
<ul>
<li><a id="navLink" [routerLink]="['/users', '123']">Visit User 123</a></li>
<li><a id="redirectLink" [routerLink]="['/redirect1']">Redirect</a></li>
<li><a id="cancelLink" [routerLink]="['/cancel']">Cancel</a></li>
<li><a id="nonExistentLink" [routerLink]="['/non-existent']">Error</a></li>
<li><a id="componentTracking" [routerLink]="['/component-tracking']">Component Tracking</a></li>
</ul>
<button id="errorBtn" (click)="throwError()">Throw error</button>
</main>
`,
})
export class HomeComponent {
throwError() {
throw new Error('Error thrown from Angular 20 E2E test app');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-sample-component',
standalone: true,
template: `<div>Component</div>`,
})
export class SampleComponent implements OnInit {
ngOnInit() {
console.log('SampleComponent');
}
}
Loading
Loading