-
Notifications
You must be signed in to change notification settings - Fork 27k
Description
Which @angular/* package(s) are the source of the bug?
zone.js
Is this a regression?
Yes
Description
I use Jest for the app testing.
After updating Jest 28 to 29 I found this issue:
I have this function on the app component:
public async testFunction() {
await firstValueFrom(of('').pipe(
map(() => {
throw 'error'
})
))
}
and I have this test on the spec file:
it('should throw an error', async () => {
const fixture = TestBed.createComponent(AppComponent);
const app = fixture.componentInstance;
try {
await app.testFunction();
} catch (e) {
expect(true).toEqual(true);
}
});
Using Jest 28 it works perfect, but If I update to Jest 29 Zone.js prints a console.error like the promise was unhandled but as you can see on the test I handle the promise.
The test passes, but the console.error is annoying.
Please, read the anything else part to see my jest configuration. To compare between Jest versions you can execute:
npm uninstall jest jest-preset-angular @types/jest
Jest 29 try: npm install --save-dev jest jest-preset-angular@next @types/jest
Jest 28 try: npm install --save-dev jest jest-preset-angular @types/jest
Thanks!
Please provide a link to a minimal reproduction of the bug
Please provide the exception or error you saw
console.error
Unhandled Promise rejection: error ; Zone: ProxyZone ; Task: null ; Value: error undefined
at Object.api.onUnhandledError (node_modules/zone.js/bundles/zone-testing-bundle.umd.js:1109:29)
at handleUnhandledRejection (node_modules/zone.js/bundles/zone-testing-bundle.umd.js:1137:17)
at _loop_2 (node_modules/zone.js/bundles/zone-testing-bundle.umd.js:1128:21)
at Object.api.microtaskDrainDone (node_modules/zone.js/bundles/zone-testing-bundle.umd.js:1132:17)
at drainMicroTaskQueue (node_modules/zone.js/bundles/zone-testing-bundle.umd.js:639:22)
Please provide the environment you discovered this bug in (run ng version)
Angular CLI: 14.2.10
Node: 18.13.0 (Unsupported)
Package Manager: npm 8.19.3
OS: darwin arm64
Angular: 14.2.12
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1402.10
@angular-devkit/build-angular 14.2.10
@angular-devkit/core 14.2.10
@angular-devkit/schematics 14.2.10
@angular/cli 14.2.10
@schematics/angular 14.2.10
rxjs 7.5.7
typescript 4.7.4
Anything else?
Using Jest 29 for testing:
"@types/jest": "^29.4.0",
"jest": "^29.4.3",
"jest-preset-angular": "^13.0.0-next.1",
jest.config.ts file:
import type { Config } from '@jest/types'
export default <Config.InitialOptions>{
preset: 'jest-preset-angular',
setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
}
setup-jest.ts file:
import 'jest-preset-angular/setup-jest';