ngneat / spectator

🦊 🚀 A Powerful Tool to Simplify Your Angular Tests
https://ngneat.github.io/spectator
MIT License
2.08k stars 177 forks source link

createRoutingFactory doesn't work with overrideComponents #592

Closed rpanadero closed 1 year ago

rpanadero commented 1 year ago

Is this a regression?

Yes

Description

If I create a component instance using createComponentFactory and try to override standalone component deps by removing some components from standalone component imports array like that:

  const createComponent = createRoutingFactory({
    component: BreadcrumbComponent,
    overrideComponents: [
      [
        BreadcrumbComponent,
        {
          remove: {
            imports: [MyCustomComponent],
          },
add: {
            imports: [MyMockCustomComponent],
          },
        },
      ],
    ],
  });

MyCustomComponent is still initialized, its ngOnInit is fired, when it should be initialized MyMockCustomComponent instead. However, if I don't use createRoutingFactory and I use createComponentFactory, then it works as expected. Therefore, it seems a bug with createRoutingFactory.

Sorry, I haven't had time to provide the issue with a PoC of the bug, but if you consider it important I will try to do it asap.

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in

No response

Anything else?

No response

Do you want to create a pull request?

No

rpanadero commented 1 year ago

Fixed!