NG2 RC5: HTTP_PROVIDERS is deprecated

前端 未结 2 499
囚心锁ツ
囚心锁ツ 2020-12-16 16:26

So, in version RC5 of Angular2, they deprecated the HTTP_PROVIDERS and introduced the HttpModule. For my application code, this is working fine, b

2条回答
  •  执笔经年
    2020-12-16 16:39

    The now deprecated HTTP_PROVIDERS is replaced with the HttpModule is RC5.

    Within your describe block, add the TestBed.configureTestingModule with the requisite imports and providers array attributes like below:

    describe("test description", () => {
        beforeEach(() => {
            TestBed.configureTestingModule({
                imports: [HttpModule],
                providers: [SomeService]
            });
        });
        it("expect something..", () => {
            // some expectation here
            ...
        })
    })
    

    This is how I got my unit service tests to work with RC5, hopefully this won't have to change between the next release candidates and the final version. If you are like me, you are probably frustrated with the amount of deprecation that is going on between release candidates. I hope things stabilize soon!

提交回复
热议问题