Title: While testing with Jest 29, zone.js prints an Unhandled Promise rejection using firstValueFrom · Issue #49110 · angular/angular · GitHub
Open Graph Title: While testing with Jest 29, zone.js prints an Unhandled Promise rejection using firstValueFrom · Issue #49110 · angular/angular
X Title: While testing with Jest 29, zone.js prints an Unhandled Promise rejection using firstValueFrom · Issue #49110 · angular/angular
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...
Open Graph 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 fun...
X 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 fun...
Opengraph URL: https://github.com/angular/angular/issues/49110
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"While testing with Jest 29, zone.js prints an Unhandled Promise rejection using firstValueFrom","articleBody":"### Which @angular/* package(s) are the source of the bug?\r\n\r\nzone.js\r\n\r\n### Is this a regression?\r\n\r\nYes\r\n\r\n### Description\r\n\r\nI use Jest for the app testing.\r\n\r\nAfter updating Jest 28 to 29 I found this issue: \r\n\r\nI have this function on the app component: \r\n\r\n```\r\npublic async testFunction() {\r\n await firstValueFrom(of('').pipe(\r\n map(() => {\r\n throw 'error'\r\n })\r\n ))\r\n }\r\n```\r\n\r\nand I have this test on the spec file: \r\n\r\n```\r\nit('should throw an error', async () => {\r\n const fixture = TestBed.createComponent(AppComponent);\r\n const app = fixture.componentInstance;\r\n try {\r\n await app.testFunction();\r\n } catch (e) {\r\n expect(true).toEqual(true);\r\n }\r\n });\r\n```\r\nUsing 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.\r\n\r\nThe test passes, but the console.error is annoying.\r\n\r\nPlease, read the anything else part to see my jest configuration. To compare between Jest versions you can execute: \r\n\r\n`npm uninstall jest jest-preset-angular @types/jest`\r\nJest 29 try: `npm install --save-dev jest jest-preset-angular@next @types/jest`\r\nJest 28 try: `npm install --save-dev jest jest-preset-angular @types/jest`\r\n\r\nThanks!\r\n\r\n\r\n\r\n\r\n### Please provide a link to a minimal reproduction of the bug\r\n\r\n[example-project](https://github.com/jordibaliellas/angular-jest-29)\r\n\r\n### Please provide the exception or error you saw\r\n\r\n```true\r\nconsole.error\r\n Unhandled Promise rejection: error ; Zone: ProxyZone ; Task: null ; Value: error undefined\r\n\r\n at Object.api.onUnhandledError (node_modules/zone.js/bundles/zone-testing-bundle.umd.js:1109:29)\r\n at handleUnhandledRejection (node_modules/zone.js/bundles/zone-testing-bundle.umd.js:1137:17)\r\n at _loop_2 (node_modules/zone.js/bundles/zone-testing-bundle.umd.js:1128:21)\r\n at Object.api.microtaskDrainDone (node_modules/zone.js/bundles/zone-testing-bundle.umd.js:1132:17)\r\n at drainMicroTaskQueue (node_modules/zone.js/bundles/zone-testing-bundle.umd.js:639:22)\r\n```\r\n\r\n\r\n### Please provide the environment you discovered this bug in (run `ng version`)\r\n\r\n```true\r\nAngular CLI: 14.2.10\r\nNode: 18.13.0 (Unsupported)\r\nPackage Manager: npm 8.19.3\r\nOS: darwin arm64\r\n\r\nAngular: 14.2.12\r\n... animations, common, compiler, compiler-cli, core, forms\r\n... platform-browser, platform-browser-dynamic, router\r\n\r\nPackage Version\r\n---------------------------------------------------------\r\n@angular-devkit/architect 0.1402.10\r\n@angular-devkit/build-angular 14.2.10\r\n@angular-devkit/core 14.2.10\r\n@angular-devkit/schematics 14.2.10\r\n@angular/cli 14.2.10\r\n@schematics/angular 14.2.10\r\nrxjs 7.5.7\r\ntypescript 4.7.4\r\n```\r\n\r\n\r\n### Anything else?\r\n\r\nUsing Jest 29 for testing: \r\n\r\n```\r\n\"@types/jest\": \"^29.4.0\",\r\n\"jest\": \"^29.4.3\",\r\n\"jest-preset-angular\": \"^13.0.0-next.1\",\r\n```\r\n\r\njest.config.ts file: \r\n\r\n```\r\nimport type { Config } from '@jest/types'\r\n\r\nexport default \u003cConfig.InitialOptions>{\r\n preset: 'jest-preset-angular',\r\n setupFilesAfterEnv: ['\u003crootDir>/setup-jest.ts'],\r\n}\r\n```\r\n\r\nsetup-jest.ts file: \r\n\r\n```\r\nimport 'jest-preset-angular/setup-jest';\r\n```","author":{"url":"https://github.com/jordibaliellas","@type":"Person","name":"jordibaliellas"},"datePublished":"2023-02-16T13:29:54Z","url":"https://github.com/angular/angular/issues/49110"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:5c07119e-09be-45c4-11b1-b58e44e4113d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 916C:63875:18B15F7:209A940:6B0140AB |
| html-safe-nonce | a8716753935ee4f48c47cfb6e03862b85839724b6a27491ab3ead02d20c30ec2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MTZDOjYzODc1OjE4QjE1Rjc6MjA5QTk0MDo2QjAxNDBBQiIsInZpc2l0b3JfaWQiOiI4Mzg3MDY5MzM4MzUxMzg2Nzk1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 751392f94ba0d94ceb9820222ce6a4bb54957ebd5ee2079ba05cc48445bef803 |
| hovercard-subject-tag | issue:1587684085 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/49110/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cb84b42a2d153c2170e1a87866185e10a8745868d5de997aaa86d5384b67bff3/angular/angular/issues/49110 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cb84b42a2d153c2170e1a87866185e10a8745868d5de997aaa86d5384b67bff3/angular/angular/issues/49110 |
| og:image:alt | 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 fun... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jordibaliellas |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width