Skip to content

Commit

Permalink
test: ✅ reinstate angular_17 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gingerbenw committed Jan 10, 2025
1 parent a29d9f5 commit d36884e
Show file tree
Hide file tree
Showing 21 changed files with 386 additions and 6 deletions.
7 changes: 4 additions & 3 deletions bin/local-test-util
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ async function updateNotifiers (notifier) {
await buildNotifiers(notifier)
await packNotifiers(notifier)
await installNotifiers(notifier)
await installNgNotifier(notifier)
await installNgNotifier(notifier, '12')
await installNgNotifier(notifier, '17')
}

async function updateFixtures (fixture) {
Expand Down Expand Up @@ -148,7 +149,7 @@ async function installNotifiers (notifier) {
})
}

async function installNgNotifier (notifier) {
async function installNgNotifier (notifier, version = '12') {
trace('install ng notifier')
if (notifier && ![ 'browser', 'node', 'js', 'plugin-angular', 'web-worker' ].includes(notifier)) return
await ex(`npm`, [
Expand All @@ -161,7 +162,7 @@ async function installNgNotifier (notifier) {
`../../../../../../bugsnag-web-worker-${require('../packages/web-worker/package.json').version}.tgz`,
`../../../../../../bugsnag-plugin-angular-${require('../packages/plugin-angular/package.json').version}.tgz`
], {
cwd: `${__dirname}/../test/browser/features/fixtures/plugin_angular/angular_12`
cwd: `${__dirname}/../test/browser/features/fixtures/plugin_angular/angular_${version}`
})
}

Expand Down
9 changes: 8 additions & 1 deletion dockerfiles/Dockerfile.browser
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,14 @@ RUN npm install --no-package-lock --no-save \
../../../../bugsnag-plugin-vue-*.tgz \
../../../../bugsnag-web-worker-*.tgz

WORKDIR plugin_angular/angular_12
WORKDIR /app/test/browser/features/fixtures/plugin_angular/angular_12
RUN npm install --no-package-lock --no-save \
../../../../../../bugsnag-plugin-angular-*.tgz \
../../../../../../bugsnag-node-*.tgz \
../../../../../../bugsnag-browser-*.tgz \
../../../../../../bugsnag-js-*.tgz

WORKDIR /app/test/browser/features/fixtures/plugin_angular/angular_17
RUN npm install --no-package-lock --no-save \
../../../../../../bugsnag-plugin-angular-*.tgz \
../../../../../../bugsnag-node-*.tgz \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node-options="--openssl-legacy-provider"
114 changes: 114 additions & 0 deletions test/browser/features/fixtures/plugin_angular/angular_17/angular.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"example": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"allowedCommonJsDependencies": [
"@bugsnag/browser"
],
"assets": [
"src/assets",
"src/favicon.ico"
],
"styles": [
"src/styles.css"
],
"scripts": []
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"buildTarget": "example:build:development"
},
"configurations": {
"production": {
"buildTarget": "example:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"buildTarget": "example:build"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"tsconfig.app.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"example-e2e": {
"root": "e2e",
"sourceRoot": "e2e",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.conf.js",
"devServerTarget": "example:serve"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"e2e/tsconfig.e2e.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"schematics": {
"@schematics/angular:component": {
"prefix": "app"
},
"@schematics/angular:directive": {
"prefix": "app"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "example",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^17.0.0",
"@angular/common": "^17.0.0",
"@angular/compiler": "^17.0.0",
"@angular/core": "^17.0.0",
"@angular/forms": "^17.0.0",
"@angular/platform-browser": "^17.0.0",
"@angular/platform-browser-dynamic": "^17.0.0",
"@angular/router": "^17.0.0",
"rxjs": "^7.4.0",
"tslib": "^2.0.0",
"zone.js": "~0.14.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "^17.0.0",
"@angular/cli": "^17.0.0",
"@angular/compiler-cli": "^17.0.0",
"@types/node": "^12.11.1",
"codelyzer": "^6.0.0",
"core-js": "^3.39.0",
"globalthis": "^1.0.4",
"protractor": "~7.0.0",
"ts-node": "~8.3.0",
"tslint": "~6.1.0",
"typescript": "~5.2.0"
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>Hello world</h1>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Component } from '@angular/core';
import bugsnagClient from './bugsnag';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})

export class AppComponent {
title = 'app';
ngOnInit() {
// @ts-expect-error
this.nothing.here = 'will cause an error'
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { BrowserModule } from '@angular/platform-browser';
import { NgModule, ErrorHandler } from '@angular/core';
import { BugsnagErrorHandler } from '@bugsnag/plugin-angular';
import bugsnagClient from './bugsnag';

export function errorHandlerFactory() {
return new BugsnagErrorHandler(bugsnagClient);
}
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule
],
providers: [
{ provide: ErrorHandler, useFactory: errorHandlerFactory }
],
bootstrap: [AppComponent]
})
export class AppModule { }
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Bugsnag from '@bugsnag/js';

var NOTIFY = decodeURIComponent(window.location.search.match(/NOTIFY=([^&]+)/)[1])
var SESSIONS = decodeURIComponent(window.location.search.match(/SESSIONS=([^&]+)/)[1])
var API_KEY = decodeURIComponent(window.location.search.match(/API_KEY=([^&]+)/)[1])

const bugsnagClient = Bugsnag.createClient({
apiKey: API_KEY,
endpoints: {
notify: NOTIFY,
sessions: SESSIONS
},
onError: (event) => {
}
});

export default bugsnagClient;
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const environment = {
production: true
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// This file can be replaced during build by using the `fileReplacements` array.
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.

export const environment = {
production: false
};

/*
* For easier debugging in development mode, you can import the following file
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
*
* This import should be commented out in production mode because it will have a negative impact
* on performance if an error is thrown.
*/
// import 'zone.js/dist/zone-error'; // Included with Angular CLI.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Bugsnag Angular Example</title>
<base href="/docs/plugin_angular/angular_19/dist/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
</head>
<body>
<pre id="bugsnag-test-should-run">PENDING</pre>
<script>
var el = document.getElementById('bugsnag-test-should-run')
el.textContent = el.innerText = (
typeof Set !== 'undefined' &&
typeof Promise !== 'undefined' &&
typeof Array.from === 'function'
) ? 'YES' : 'NO'
</script>
<app-root></app-root>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';

import { AppModule } from './app/app.module';
import { environment } from './environments/environment';

if (environment.production) {
enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule);
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* This file includes polyfills needed by Angular and is loaded before the app.
* You can add your own extra polyfills to this file.
*
* This file is divided into 2 sections:
* 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
* 2. Application imports. Files imported after ZoneJS that should be loaded before your main
* file.
*
* The current setup is for so-called "evergreen" browsers; the last versions of browsers that
* automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
* Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
*
* Learn more in https://angular.io/guide/browser-support
*/

/***************************************************************************************************
* BROWSER POLYFILLS
*/

import 'globalthis/auto';
import 'core-js/modules/web.queue-microtask';

/**
* IE11 requires the following for NgClass support on SVG elements
*/
// import 'classlist.js'; // Run `npm install --save classlist.js`.

/**
* Web Animations `@angular/platform-browser/animations`
* Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
* Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
*/
// import 'web-animations-js'; // Run `npm install --save web-animations-js`.

/**
* By default, zone.js will patch all possible macroTask and DomEvents
* user can disable parts of macroTask/DomEvents patch by setting following flags
* because those flags need to be set before `zone.js` being loaded, and webpack
* will put import in the top of bundle, so user need to create a separate file
* in this directory (for example: zone-flags.ts), and put the following flags
* into that file, and then add the following code before importing zone.js.
* import './zone-flags';
*
* The flags allowed in zone-flags.ts are listed here.
*
* The following flags will work for all browsers.
*
* (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
* (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
* (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
*
* in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
* with the following flag, it will bypass `zone.js` patch for IE/Edge
*
* (window as any).__Zone_enable_cross_context_check = true;
*
*/

/***************************************************************************************************
* Zone JS is required by default for Angular itself.
*/
import 'zone.js'; // Included with Angular CLI.


/***************************************************************************************************
* APPLICATION IMPORTS
*/
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* You can add global styles to this file, and also import other style files */
Loading

0 comments on commit d36884e

Please sign in to comment.