Stratal API Reference
    Preparing search index...

    Class ProviderOverrideBuilder<T>

    Fluent builder for provider overrides

    Provides a NestJS-style API for overriding providers in tests.

    const module = await Test.createTestingModule({
    imports: [RegistrationModule],
    })
    .overrideProvider(EMAIL_TOKENS.EmailService)
    .useValue(mockEmailService)
    .compile()

    Type Parameters

    • T
    Index

    Constructors

    Methods

    • Use an existing token as the provider (alias)

      The override token will resolve to the same instance as the target token.

      Parameters

      • existingToken: InjectionToken<T>

        The token to alias

      Returns TestingModuleBuilder

      The parent TestingModuleBuilder for chaining

      const module = await Test.createTestingModule({
      imports: [MyModule],
      })
      .overrideProvider(ABSTRACT_TOKEN)
      .useExisting(ConcreteService)
      .compile()