Skip to content
Closed
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
43 changes: 0 additions & 43 deletions packages/zone.js/lib/jasmine/jasmine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,49 +55,6 @@ export function patchJasmine(Zone: ZoneType): void {
(global[symbol('fakeAsyncPatchLock')] === true ||
global[symbol('fakeAsyncAutoFakeAsyncWhenClockPatched')] === true);

const ignoreUnhandledRejection = global[symbol('ignoreUnhandledRejection')] === true;

if (!ignoreUnhandledRejection) {
const globalErrors = (jasmine as any).GlobalErrors;
if (globalErrors && !(jasmine as any)[symbol('GlobalErrors')]) {
(jasmine as any)[symbol('GlobalErrors')] = globalErrors;
(jasmine as any).GlobalErrors = function () {
const instance = new globalErrors();
const originalInstall = instance.install;
if (originalInstall && !instance[symbol('install')]) {
instance[symbol('install')] = originalInstall;
instance.install = function () {
const isNode = typeof process !== 'undefined' && !!process.on;
// Note: Jasmine checks internally if `process` and `process.on` is defined.
// Otherwise, it installs the browser rejection handler through the
// `global.addEventListener`. This code may be run in the browser environment where
// `process` is not defined, and this will lead to a runtime exception since webpack 5
// removed automatic Node.js polyfills. Note, that events are named differently, it's
// `unhandledRejection` in Node.js and `unhandledrejection` in the browser.
const originalHandlers: any[] = isNode
? process.listeners('unhandledRejection')
: global.eventListeners('unhandledrejection');
const result = originalInstall.apply(this, arguments);
isNode
? process.removeAllListeners('unhandledRejection')
: global.removeAllListeners('unhandledrejection');
if (originalHandlers) {
originalHandlers.forEach((handler) => {
if (isNode) {
process.on('unhandledRejection', handler);
} else {
global.addEventListener('unhandledrejection', handler);
}
});
}
return result;
};
}
return instance;
};
}
}

// Monkey patch all of the jasmine DSL so that each function runs in appropriate zone.
const jasmineEnv: any = jasmine.getEnv();
['describe', 'xdescribe', 'fdescribe'].forEach((methodName) => {
Expand Down
23 changes: 0 additions & 23 deletions packages/zone.js/test/node_bluebird_entry_point.init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,3 @@ patchTaskTracking(Zone);
patchWtf(Zone);
patchRxJs(Zone);
patchPromiseTesting(Zone);

const globalErrors = (jasmine as any).GlobalErrors;
const symbol = Zone.__symbol__;
if (globalErrors && !(jasmine as any)[symbol('GlobalErrors')]) {
(jasmine as any)[symbol('GlobalErrors')] = globalErrors;
(jasmine as any).GlobalErrors = function () {
const instance = new globalErrors();
const originalInstall = instance.install;
if (originalInstall && !instance[symbol('install')]) {
instance[symbol('install')] = originalInstall;
instance.install = function () {
const originalHandlers = process.listeners('unhandledRejection');
const r = originalInstall.apply(this, arguments);
process.removeAllListeners('unhandledRejection');
if (originalHandlers) {
originalHandlers.forEach((h) => process.on('unhandledRejection', h));
}
return r;
};
}
return instance;
};
}