Title: fix(zone.js): zone.js patch jest should handle done correctly by JiaLiPassion · Pull Request #36022 · angular/angular · GitHub
Open Graph Title: fix(zone.js): zone.js patch jest should handle done correctly by JiaLiPassion · Pull Request #36022 · angular/angular
X Title: fix(zone.js): zone.js patch jest should handle done correctly by JiaLiPassion · Pull Request #36022 · angular/angular
Description: zone.js support jest test.each() methods, but it introduces a bug, which is the done() function will not be handled correctly. it('should work with done', done => { // done will be undefined. }); The reason is the logic of monkey patching test method is different from jasmine patch // jasmine patch return testBody.length === 0 ? () => testProxyZone.run(testBody, null) : done => testProxyZone.run(testBody, null, [done]); // jest patch return function(...args) { return testProxyZone.run(testBody, null, args); }; the purpose of this change is to handle the following cases. test.each([1, 2])('test.each', (arg1, arg2) => { expect(arg1).toBe(1); expect(arg2).toBe(2); }); so in jest, it is a little complex, because the testBody's parameter may be bigger than 1, so the logic in jasmine return testBody.length === 0 ? () => testProxyZone.run(testBody, null) : done => testProxyZone.run(testBody, null, [done]); will not work for test.each in jest. So in this PR, I created a dynamic Function to return the correct length of paramters (which is required by jest core), to handle normal test with or without done. each with parameters with or without done. PR Checklist Please check if your PR fulfills the following requirements: The commit message follows our guidelines: https://github.com/angular/angular/blob/master/CONTRIBUTING.md#commit Tests for the changes have been added (for bug fixes / features) Docs have been added / updated (for bug fixes / features) PR Type What kind of change does this PR introduce? Bugfix Feature Code style update (formatting, local variables) Refactoring (no functional changes, no api changes) Build related changes CI related changes Documentation content changes angular.io application / infrastructure changes Other... Please describe: What is the current behavior? Issue Number: The issue is found at jest-preset-angular repo here, thymikee/jest-preset-angular#356
Open Graph Description: zone.js support jest test.each() methods, but it introduces a bug, which is the done() function will not be handled correctly. it('should work with done', done => { // done will be und...
X Description: zone.js support jest test.each() methods, but it introduces a bug, which is the done() function will not be handled correctly. it('should work with done', done => { // done...
Opengraph URL: https://github.com/angular/angular/pull/36022
X: @github
Domain: github.com
| 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 | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:39269c55-f395-cdd4-1eba-62b4ff1c0dc7 |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | BFA6:1D86C4:1ECEEC9:27155A9:6B0165D6 |
| html-safe-nonce | 6804c7fa1dbe6d91b5537d76f20699b49a77fb6c41ab14b7234408a52bdc8f9e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRkE2OjFEODZDNDoxRUNFRUM5OjI3MTU1QTk6NkIwMTY1RDYiLCJ2aXNpdG9yX2lkIjoiMzM3NTMxNDU4OTU0NDcwMzQ0NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | aa66ce5ae72a1b9d309d65f8fd2d236ed86e9d02ad7b8e6db7c5cf6bea8d37f5 |
| hovercard-subject-tag | pull_request:386803937 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,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/angular/angular/pull/36022/files |
| twitter:image | https://avatars.githubusercontent.com/u/1442575?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/1442575?s=400&v=4 |
| og:image:alt | zone.js support jest test.each() methods, but it introduces a bug, which is the done() function will not be handled correctly. it('should work with done', done => { // done will be und... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| diff-view | unified |
| 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 full-width |
| disable-turbo | true |
| 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 |
Links:
Viewport: width=device-width