Skip to content

Commit 42a1adb

Browse files
committed
Merge remote-tracking branch 'upstream/master' into feat/move-hub
2 parents 568707d + 7304215 commit 42a1adb

34 files changed

+9988
-150
lines changed

packages/angular/.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ module.exports = {
33
browser: true,
44
},
55
extends: ['../../.eslintrc.js'],
6+
ignorePatterns: ['setup-jest.ts'],
67
};

packages/angular/jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ const baseConfig = require('../../jest/jest.config.js');
33
module.exports = {
44
...baseConfig,
55
testEnvironment: 'jsdom',
6+
setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
67
};

packages/angular/package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,12 @@
3333
"@angular/compiler": "^10.2.5",
3434
"@angular/compiler-cli": "~10.2.5",
3535
"@angular/core": "~10.2.5",
36+
"@angular/platform-browser": "~10.2.5",
37+
"@angular/platform-browser-dynamic": "~10.2.5",
3638
"@angular/router": "~10.2.5",
3739
"ng-packagr": "^10.1.0",
38-
"typescript": "~4.0.2"
40+
"typescript": "~4.0.2",
41+
"zone.js": "^0.11.8"
3942
},
4043
"scripts": {
4144
"build": "yarn build:ngc",

packages/angular/setup-jest.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import 'zone.js';
2+
3+
import { TestBed } from '@angular/core/testing';
4+
import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing';
5+
6+
TestBed.resetTestEnvironment();
7+
TestBed.initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());

packages/angular/test/errorhandler.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,28 @@ describe('SentryErrorHandler', () => {
121121
expect.any(Function),
122122
);
123123
});
124+
125+
it('handleError method shows report dialog', () => {
126+
const showReportDialogSpy = jest.spyOn(SentryBrowser, 'showReportDialog');
127+
128+
const errorHandler = createErrorHandler({ showDialog: true });
129+
errorHandler.handleError(new Error('test'));
130+
131+
expect(showReportDialogSpy).toBeCalledTimes(1);
132+
});
133+
134+
it('handleError method extracts error with a custom extractor', () => {
135+
const customExtractor = (error: unknown) => {
136+
if (typeof error === 'string') {
137+
return new Error(`custom ${error}`);
138+
}
139+
return error;
140+
};
141+
142+
const errorHandler = createErrorHandler({ extractor: customExtractor });
143+
errorHandler.handleError('error');
144+
145+
expect(captureExceptionSpy).toHaveBeenCalledTimes(1);
146+
expect(captureExceptionSpy).toHaveBeenCalledWith(new Error('custom error'), expect.any(Function));
147+
});
124148
});

0 commit comments

Comments
 (0)