Angular Testing provider useValue for environment throws NullInjectionError

问题描述 投票:0回答:0

我在我们的 Angular 应用程序中有一个环境提供者,我们有这样的:

{ provide: 'environment', useValue: environment }

除此之外,我们还有许多其他提供商作为服务。现在这在应用程序中工作正常但是当我运行

ng test
它会为使用它的任何服务抛出错误。

NullInjectorError: No provider for environment

@Inject('environment') environment: Environment

我如何在这方面取得进展,因为我也需要自动注入环境。

angular typescript dependency-injection jasmine angular-test
© www.soinside.com 2019 - 2024. All rights reserved.