Skip to content

Commit

Permalink
feat(zone.js): jest 29 should ignore uncaught error console log
Browse files Browse the repository at this point in the history
Close #49110

From jest 29 and jest-preset-angular v13, the module transform logic
changed, and now jest-preset-angular use the use the tsconfig target
other than the hardcoded one, thymikee/jest-preset-angular#2010
But jest-angular-preset doesn't introduce the @babel/plugin-transform-async-to-generator
which is needed by angular since `async/await` still need to be transformed
to promise for ES2017+ target.
So for now, we disable to output the uncaught error console log for a temp solution,
until jest-preset-angular find a proper solution.
  • Loading branch information
JiaLiPassion committed Mar 25, 2023
1 parent 8d99ad0 commit 6cd069a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/zone.js/lib/jest/jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,16 @@ Zone.__load_patch('jest', (context: any, Zone: ZoneType, api: _ZonePrivate) => {
return;
}


// From jest 29 and jest-preset-angular v13, the module transform logic
// changed, and now jest-preset-angular use the use the tsconfig target
// other than the hardcoded one, https://github.com/thymikee/jest-preset-angular/issues/2010
// But jest-angular-preset doesn't introduce the @babel/plugin-transform-async-to-generator
// which is needed by angular since `async/await` still need to be transformed
// to promise for ES2017+ target.
// So for now, we disable to output the uncaught error console log for a temp solution,
// until jest-preset-angular find a proper solution.
(Zone as any)[api.symbol('ignoreConsoleErrorUncaughtError')] = true;
jest['__zone_patch__'] = true;

const ProxyZoneSpec = (Zone as any)['ProxyZoneSpec'];
Expand Down

0 comments on commit 6cd069a

Please sign in to comment.