Title: feat(zone.js): patch jasmine.createSpyObj to make properties enumerable to be true by JiaLiPassion · Pull Request #34624 · angular/angular · GitHub
Open Graph Title: feat(zone.js): patch jasmine.createSpyObj to make properties enumerable to be true by JiaLiPassion · Pull Request #34624 · angular/angular
X Title: feat(zone.js): patch jasmine.createSpyObj to make properties enumerable to be true by JiaLiPassion · Pull Request #34624 · angular/angular
Description: 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: #33657 Close #33657 in jasmine 3.5, there is a new feature, user can pass a properties object to jasmine.createSpyObj const spy = jasmine.createSpyObj('spy', ['method1'], {prop1: 'foo'}); expect(spy.prop1).toEqual('foo'); This case will not work for Angular TestBed, for example, describe('AppComponent', () => { beforeEach(() => { //Note the third parameter // @ts-ignore const someServiceSpy = jasmine.createSpyObj('SomeService', ['someFunction'], ['aProperty']); TestBed.configureTestingModule({ declarations: [ AppComponent ], providers: [ {provide: SomeService, useValue: someServiceSpy}, ] }).compileComponents(); }); it('should create the app', () => { //spyObj will have someFunction, but will not have aProperty let spyObj = TestBed.get(SomeService); }); Because jasmine.createSpyObj will create the aProperty with enumerable=false, and TestBed.configureTestingModule will try to copy all the properties from spyObj to the injected service instance. And because enumerable is false, so the property (here is aProperty) will not be copied. This PR will monkey patch the jasmine.createSpyObj and make sure the new property's enumerable=true.
Open Graph Description: 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 f...
X Description: 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 f...
Opengraph URL: https://github.com/angular/angular/pull/34624
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:1fdd7ed2-053a-a480-c712-3ce3ea4c1f2d |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | DF0C:3D97C8:1F3DF30:2985FC5:6B0176C0 |
| html-safe-nonce | abfaac18a84e5af66bd5cbaa384a59b0c10984a66697fa849a90e0346e1b9065 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERjBDOjNEOTdDODoxRjNERjMwOjI5ODVGQzU6NkIwMTc2QzAiLCJ2aXNpdG9yX2lkIjoiODEzOTk4MzQ4NjE3NDk4Mzg3MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | fcdc1a9aa4dca0310c6924c6b7f4632e332024865acb019029f386b5fb168110 |
| hovercard-subject-tag | pull_request:358876485 |
| 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/34624/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 | 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 f... |
| 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