-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Changes from 5 commits
22edc86
c5184df
66c3370
2e82058
7f9c829
09ccfcd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 |
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 |
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 |
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`. |
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": [] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
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", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wdyt about generally adding canary tests here with There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; |
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'); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not ideal because we should use the same Node version to build the SDK and to build && run the app. But since we're blocked on upgrading to 20.19.0, I think this is a fair compromise for now.