Skip to content

bindToComponentInputs does not work when using RouterTestingModule #54461

@wawyed

Description

@wawyed

Which @angular/* package(s) are the source of the bug?

router

Is this a regression?

No

Description

it looks like the code in RouterTestingModule does not take into account bindToComponentInputs so having Input for resolvables results in failing unit tests even if you define the correct resolves in the route definition.

I'd expect something similar to RouterModule:

config?.bindToComponentInputs ? withComponentInputBinding().ɵproviders : [],

in https://github.com/angular/angular/blob/main/packages/router/testing/src/router_testing_module.ts#L88

export class RouterTestingModule {
  static withRoutes(
    routes: Routes,
    config?: ExtraOptions,
  ): ModuleWithProviders<RouterTestingModule> {
    return {
      ngModule: RouterTestingModule,
      providers: [
        {provide: ROUTES, multi: true, useValue: routes},
        {provide: ROUTER_CONFIGURATION, useValue: config ? config : {}},
        ...config?.bindToComponentInputs ? withComponentInputBinding().ɵproviders : [], <--- this is missing
      ],
    };
  }
}

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 (run ng version)

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions