You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For many projects I use NG-Mocks to easily create components to override my components, but often I need more than just a mock and want to do some custom logic in there. But it would be nice if we could do the following solution.
In this case when the second parameter is provided, it will do the overriding itself and it prevents me from writing a lot of boilerplate to do it.
For the array of components, perhaps a similar setup could be done by providing an array, but I don't think many people are using that yet, but here's an example:
By using this setup, it becomes a lot easier to figure out what role your mocked component is going to play and make the tests use less boilerplate and code to set up.
The text was updated successfully, but these errors were encountered:
Hi @Martinspire, from what you've described, it sounds like you need to use MockBuilder and simply create TestBed via MockBuilder(ChildComponent) to avoid many lines of code.
I'm already using Angular Standalone and as far as I know Mockbuilder is more for non-standalone. Plus I'm also using Spectator, which puts some improvements on Testbed, but also doesn't really support mockbuilder in the same way.
I would also be fine with MockComponent(ChildComponent).replace(MockChildComponent) but it just seems logical to me to also be able to use the Mock... functions to replace my components with my own mocks. Often times I'm trying to replace a very complex dependency with a simple mock that just has the functions I'm looking for instead of all of the logic and sub dependencies that this complex dependency offers. Like a Charting library or for displaying maps. Its a lot faster to just create a small mock.
But right now I'm also blocked because of the whole mock child with signal issue, so I wanted to use my own temporary mocks, but found it was tedious to implement it, when I had hoped that NGMocks would have a simpler replacement option.
Describe the feature or problem you'd like to solve
Ever since Angular Standalone was introduced, I found the boilerplate for overriding components to be a bit tedious.
For example:
For many projects I use NG-Mocks to easily create components to override my components, but often I need more than just a mock and want to do some custom logic in there. But it would be nice if we could do the following solution.
Proposed solution
In this case when the second parameter is provided, it will do the overriding itself and it prevents me from writing a lot of boilerplate to do it.
For the array of components, perhaps a similar setup could be done by providing an array, but I don't think many people are using that yet, but here's an example:
Additional context
By using this setup, it becomes a lot easier to figure out what role your mocked component is going to play and make the tests use less boilerplate and code to set up.
The text was updated successfully, but these errors were encountered: