Content-Length: 302473 | pFad | https://github.com/angular/angular/issues/37178

FF Improve TestModuleMetadata typings · Issue #37178 · angular/angular · GitHub
Skip to content

Improve TestModuleMetadata typings #37178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
fvoska opened this issue May 18, 2020 · 2 comments
Open

Improve TestModuleMetadata typings #37178

fvoska opened this issue May 18, 2020 · 2 comments
Labels
area: testing Issues related to Angular testing features, such as TestBed cross-cutting: types feature: under consideration Feature request for which voting has completed and the request is now under consideration feature Issue that requests a new feature
Milestone

Comments

@fvoska
Copy link

fvoska commented May 18, 2020

🚀 feature request

Relevant Package

This feature request is for @angular/core

Description

Typings for TestModuleMetadata are too loose and they do not provide proper type-checking. Ths can lead to hard-to-track bugs in tests in case there is a typo or some other error in TestBed configuration object.

Example issue:

TestBed.configureTestingModule({
  providers: [{
    provibe: SomeService,
    useClass: SomeServiceMock,
  }],
})

If SomeService is decorated as @Injectable({ providedIn: 'root' }), the test for the above TestBed configuration will actually create an instance of SomeService instead of SomeServiceMock because there is a typo (provibe instead of provide) in the provider so this provider is basically ignored. This kind of an error can be hard to pin down and could be easily caught by stricter typings for TestModuleMetadata.

Describe the solution you'd like

I suggest updating typings of TestModuleMetadata to match the typings of NgModule interface. Please check the related PR I created.

Describe alternatives you've considered

Alternative solution is to explicitly type the providers yourself:

const testProviders: Array<Provider> = [{
  provibe: SomeService, // now this typo will be caught
  useClass: SomeServiceMock,
}];

TestBed.configureTestingModule({
  providers: testProviders,
})
fvoska added a commit to fvoska/angular that referenced this issue May 18, 2020
Update TestModuleMetadata typings to be stricter and in-line with
NgModule interface typings.

Issue Close angular#37178
@pkozlowski-opensource pkozlowski-opensource added area: testing Issues related to Angular testing features, such as TestBed cross-cutting: types labels May 18, 2020
@ngbot ngbot bot added this to the needsTriage milestone May 18, 2020
@AndrewKushnir AndrewKushnir added the feature Issue that requests a new feature label May 18, 2020
@ngbot ngbot bot modified the milestones: needsTriage, Backlog May 18, 2020
@angular-robot angular-robot bot added the feature: votes required Feature request which is currently still in the voting phase label Jun 4, 2021
@angular-robot
Copy link
Contributor

angular-robot bot commented Jun 4, 2021

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

@angular-robot
Copy link
Contributor

angular-robot bot commented Jun 24, 2021

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

@angular-robot angular-robot bot added the feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors label Jun 24, 2021
@dylhunn dylhunn added feature: under consideration Feature request for which voting has completed and the request is now under consideration and removed feature: insufficient votes Label to add when the not a sufficient number of votes or comments from unique authors feature: votes required Feature request which is currently still in the voting phase labels Sep 29, 2022
JeanMeche added a commit to JeanMeche/angular that referenced this issue Sep 13, 2023
To improve compiler errors on `TestModuleMetadata`, lets replace `any`  for `providers`, `declarations` and `imports`

fixes angular#37178
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: testing Issues related to Angular testing features, such as TestBed cross-cutting: types feature: under consideration Feature request for which voting has completed and the request is now under consideration feature Issue that requests a new feature
Projects
None yet
5 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/angular/angular/issues/37178

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy