addInjector method

NgTestBed<T> addInjector(
  1. InjectorFactory factory
)

Returns a new instance of NgTestBed with the root injector wrapped.

That is, factory will supplement the existing injector(s). In most cases this is likely not required unless you are re-using test configuration across many tests with subtle differences.

Implementation

NgTestBed<T> addInjector(InjectorFactory factory) {
  return fork(
    rootInjector: (Injector parent) => _rootInjector(factory(parent)),
  );
}