Skip to content

Commit 72057b6

Browse files
authored
test(angular): Add Angular 20.0.0-rc.2 e2e test (#16364)
adds an e2e test for Angular the latest Angular 20 RC -- to be promoted to Angular 20 stable once released
1 parent 3d18c8e commit 72057b6

27 files changed

+871
-0
lines changed

.github/workflows/build.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,13 @@ jobs:
886886
- uses: pnpm/action-setup@v4
887887
with:
888888
version: 9.4.0
889+
- name: Set up Node for Angular 20
890+
if: matrix.test-application == 'angular-20'
891+
uses: actions/setup-node@v4
892+
with:
893+
node-version: '20.19.2'
889894
- name: Set up Node
895+
if: matrix.test-application != 'angular-20'
890896
uses: actions/setup-node@v4
891897
with:
892898
node-version-file: 'dev-packages/e2e-tests/package.json'
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Editor configuration, see https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.ts]
12+
quote_type = single
13+
ij_typescript_use_double_quotes = false
14+
15+
[*.md]
16+
max_line_length = off
17+
trim_trailing_whitespace = false
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# See https://docs.github.com/get-started/getting-started-with-git/ignoring-files for more about ignoring files.
2+
3+
# Compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
/bazel-out
8+
9+
# Node
10+
/node_modules
11+
npm-debug.log
12+
yarn-error.log
13+
14+
# IDEs and editors
15+
.idea/
16+
.project
17+
.classpath
18+
.c9/
19+
*.launch
20+
.settings/
21+
*.sublime-workspace
22+
23+
# Visual Studio Code
24+
.vscode/*
25+
!.vscode/settings.json
26+
!.vscode/tasks.json
27+
!.vscode/launch.json
28+
!.vscode/extensions.json
29+
.history/*
30+
31+
# Miscellaneous
32+
/.angular/cache
33+
.sass-cache/
34+
/connect.lock
35+
/coverage
36+
/libpeerconnection.log
37+
testem.log
38+
/typings
39+
40+
# System files
41+
.DS_Store
42+
Thumbs.db
43+
44+
test-results
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@sentry:registry=http://127.0.0.1:4873
2+
@sentry-internal:registry=http://127.0.0.1:4873
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Angular 20
2+
3+
E2E test app for Angular 20 and `@sentry/angular`.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"angular-20": {
7+
"projectType": "application",
8+
"schematics": {},
9+
"root": "",
10+
"sourceRoot": "src",
11+
"prefix": "app",
12+
"architect": {
13+
"build": {
14+
"builder": "@angular-devkit/build-angular:application",
15+
"options": {
16+
"outputPath": "dist/angular-20",
17+
"index": "src/index.html",
18+
"browser": "src/main.ts",
19+
"polyfills": ["zone.js"],
20+
"tsConfig": "tsconfig.app.json",
21+
"assets": [
22+
{
23+
"glob": "**/*",
24+
"input": "public"
25+
}
26+
],
27+
"styles": ["src/styles.css"],
28+
"scripts": []
29+
},
30+
"configurations": {
31+
"production": {
32+
"budgets": [
33+
{
34+
"type": "initial",
35+
"maximumWarning": "500kB",
36+
"maximumError": "1MB"
37+
},
38+
{
39+
"type": "anyComponentStyle",
40+
"maximumWarning": "4kB",
41+
"maximumError": "8kB"
42+
}
43+
],
44+
"outputHashing": "all"
45+
},
46+
"development": {
47+
"optimization": false,
48+
"extractLicenses": false,
49+
"sourceMap": true
50+
}
51+
},
52+
"defaultConfiguration": "production"
53+
},
54+
"serve": {
55+
"builder": "@angular-devkit/build-angular:dev-server",
56+
"configurations": {
57+
"production": {
58+
"buildTarget": "angular-20:build:production"
59+
},
60+
"development": {
61+
"buildTarget": "angular-20:build:development"
62+
}
63+
},
64+
"defaultConfiguration": "development"
65+
},
66+
"extract-i18n": {
67+
"builder": "@angular-devkit/build-angular:extract-i18n"
68+
},
69+
"test": {
70+
"builder": "@angular-devkit/build-angular:karma",
71+
"options": {
72+
"polyfills": ["zone.js", "zone.js/testing"],
73+
"tsConfig": "tsconfig.spec.json",
74+
"assets": [
75+
{
76+
"glob": "**/*",
77+
"input": "public"
78+
}
79+
],
80+
"styles": ["src/styles.css"],
81+
"scripts": []
82+
}
83+
}
84+
}
85+
}
86+
}
87+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
{
2+
"name": "angular-20",
3+
"version": "0.0.0",
4+
"scripts": {
5+
"ng": "ng",
6+
"dev": "ng serve",
7+
"proxy": "node start-event-proxy.mjs",
8+
"preview": "http-server dist/angular-20/browser --port 8080",
9+
"build": "ng build",
10+
"watch": "ng build --watch --configuration development",
11+
"test": "playwright test",
12+
"test:build": "pnpm install && pnpm build",
13+
"test:assert": "playwright test",
14+
"clean": "npx rimraf .angular node_modules pnpm-lock.yaml dist"
15+
},
16+
"private": true,
17+
"dependencies": {
18+
"@angular/animations": "^20.0.0-rc.2",
19+
"@angular/common": "^20.0.0-rc.2",
20+
"@angular/compiler": "^20.0.0-rc.2",
21+
"@angular/core": "^20.0.0-rc.2",
22+
"@angular/forms": "^20.0.0-rc.2",
23+
"@angular/platform-browser": "^20.0.0-rc.2",
24+
"@angular/platform-browser-dynamic": "^20.0.0-rc.2",
25+
"@angular/router": "^20.0.0-rc.2",
26+
"@sentry/angular": "* || latest",
27+
"rxjs": "~7.8.0",
28+
"tslib": "^2.3.0",
29+
"zone.js": "~0.15.0"
30+
},
31+
"devDependencies": {
32+
"@angular-devkit/build-angular": "^20.0.0-rc.2",
33+
"@angular/cli": "^20.0.0-rc.2",
34+
"@angular/compiler-cli": "^20.0.0-rc.2",
35+
"@playwright/test": "~1.50.0",
36+
"@sentry-internal/test-utils": "link:../../../test-utils",
37+
"@types/jasmine": "~5.1.0",
38+
"http-server": "^14.1.1",
39+
"jasmine-core": "~5.4.0",
40+
"karma": "~6.4.0",
41+
"karma-chrome-launcher": "~3.2.0",
42+
"karma-coverage": "~2.2.0",
43+
"karma-jasmine": "~5.1.0",
44+
"karma-jasmine-html-reporter": "~2.1.0",
45+
"typescript": "~5.8.3"
46+
},
47+
"volta": {
48+
"extends": "../../package.json"
49+
}
50+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { getPlaywrightConfig } from '@sentry-internal/test-utils';
2+
3+
const config = getPlaywrightConfig({
4+
startCommand: `pnpm preview`,
5+
port: 8080,
6+
});
7+
8+
export default config;
Binary file not shown.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Component } from '@angular/core';
2+
import { RouterOutlet } from '@angular/router';
3+
4+
@Component({
5+
selector: 'app-root',
6+
standalone: true,
7+
imports: [RouterOutlet],
8+
template: `<router-outlet></router-outlet>`,
9+
})
10+
export class AppComponent {
11+
title = 'angular-20';
12+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import {
2+
ApplicationConfig,
3+
ErrorHandler,
4+
inject,
5+
provideAppInitializer,
6+
provideZoneChangeDetection,
7+
} from '@angular/core';
8+
import { Router, provideRouter } from '@angular/router';
9+
10+
import { TraceService, createErrorHandler } from '@sentry/angular';
11+
import { routes } from './app.routes';
12+
13+
export const appConfig: ApplicationConfig = {
14+
providers: [
15+
provideZoneChangeDetection({ eventCoalescing: true }),
16+
provideRouter(routes),
17+
{
18+
provide: ErrorHandler,
19+
useValue: createErrorHandler(),
20+
},
21+
{
22+
provide: TraceService,
23+
deps: [Router],
24+
},
25+
provideAppInitializer(() => {
26+
inject(TraceService);
27+
}),
28+
],
29+
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { Routes } from '@angular/router';
2+
import { cancelGuard } from './cancel-guard.guard';
3+
import { CancelComponent } from './cancel/cancel.components';
4+
import { ComponentTrackingComponent } from './component-tracking/component-tracking.components';
5+
import { HomeComponent } from './home/home.component';
6+
import { UserComponent } from './user/user.component';
7+
8+
export const routes: Routes = [
9+
{
10+
path: 'users/:id',
11+
component: UserComponent,
12+
},
13+
{
14+
path: 'home',
15+
component: HomeComponent,
16+
},
17+
{
18+
path: 'cancel',
19+
component: CancelComponent,
20+
canActivate: [cancelGuard],
21+
},
22+
{
23+
path: 'component-tracking',
24+
component: ComponentTrackingComponent,
25+
},
26+
{
27+
path: 'redirect1',
28+
redirectTo: '/redirect2',
29+
},
30+
{
31+
path: 'redirect2',
32+
redirectTo: '/redirect3',
33+
},
34+
{
35+
path: 'redirect3',
36+
redirectTo: '/users/456',
37+
},
38+
{
39+
path: '**',
40+
redirectTo: 'home',
41+
},
42+
];
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { ActivatedRouteSnapshot, CanActivateFn, RouterStateSnapshot } from '@angular/router';
2+
3+
export const cancelGuard: CanActivateFn = (_next: ActivatedRouteSnapshot, _state: RouterStateSnapshot) => {
4+
return false;
5+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { Component } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-cancel',
5+
standalone: true,
6+
template: `<div></div>`,
7+
})
8+
export class CancelComponent {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { AfterViewInit, Component, OnInit } from '@angular/core';
2+
import { TraceClass, TraceMethod, TraceModule } from '@sentry/angular';
3+
import { SampleComponent } from '../sample-component/sample-component.components';
4+
5+
@Component({
6+
selector: 'app-component-tracking',
7+
standalone: true,
8+
imports: [TraceModule, SampleComponent],
9+
template: `
10+
<app-sample-component trace="sample-component"></app-sample-component>
11+
<app-sample-component trace></app-sample-component>
12+
`,
13+
})
14+
@TraceClass({ name: 'ComponentTrackingComponent' })
15+
export class ComponentTrackingComponent implements OnInit, AfterViewInit {
16+
@TraceMethod({ name: 'ngOnInit' })
17+
ngOnInit() {}
18+
19+
@TraceMethod()
20+
ngAfterViewInit() {}
21+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { Component } from '@angular/core';
2+
import { RouterLink } from '@angular/router';
3+
4+
@Component({
5+
selector: 'app-home',
6+
standalone: true,
7+
imports: [RouterLink],
8+
template: `
9+
<main>
10+
<h1>Welcome to Sentry's Angular 20 E2E test app</h1>
11+
<ul>
12+
<li><a id="navLink" [routerLink]="['/users', '123']">Visit User 123</a></li>
13+
<li><a id="redirectLink" [routerLink]="['/redirect1']">Redirect</a></li>
14+
<li><a id="cancelLink" [routerLink]="['/cancel']">Cancel</a></li>
15+
<li><a id="nonExistentLink" [routerLink]="['/non-existent']">Error</a></li>
16+
<li><a id="componentTracking" [routerLink]="['/component-tracking']">Component Tracking</a></li>
17+
</ul>
18+
<button id="errorBtn" (click)="throwError()">Throw error</button>
19+
</main>
20+
`,
21+
})
22+
export class HomeComponent {
23+
throwError() {
24+
throw new Error('Error thrown from Angular 20 E2E test app');
25+
}
26+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { Component, OnInit } from '@angular/core';
2+
3+
@Component({
4+
selector: 'app-sample-component',
5+
standalone: true,
6+
template: `<div>Component</div>`,
7+
})
8+
export class SampleComponent implements OnInit {
9+
ngOnInit() {
10+
console.log('SampleComponent');
11+
}
12+
}

0 commit comments

Comments
 (0)