且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

角度e2e测试:如何测试Service注入(使用)其他服务

更新时间:2022-03-10 02:57:23

所以e2e测试的目的是在构建形式中实际试用您的应用程序,基本上您已经完成了

So the purpose of the e2e testing is to actually try out your app in it's build form, basically you have done a

ng构建

ng build

在您的应用程序上,然后在其上本地托管(您也可以在外部进行)刚创建的构建程序.

on your application where you then afterwards host locally(you can do it externally aswell) that build you just created.

因此,基本上,您的服务都包含在这些捆绑包中(在主捆绑包中更精确),因此您不需要设置任何配置,而是开始使用带有

So basically you service is included in those bundles(more precise in your main bundle) so you dont need to setup any configs instead start testing your app with the protractor api with browser and so on. So your test file could look more like this on when looking at your question:

  describe('workspace-project App', () => {
   let page: AppPage;
   this.chronoInfo = new ALChrono(); //it's a class

   beforeEach(() => {
     page = new AppPage();
   });

   it('should display welcome message', () => {
     page.navigateTo();
     expect(page.getParagraphText()).toEqual('Welcome to MyProject!');
   });
  }

因此,包括服务测试在内的代码应包含在您的单元测试中 如果您不确定量角器的工作方式,建议您阅读有关设置如何工作的文档的更多信息.

So the code including the service test should include in your unit-testing If you are not sure how protractor works I suggest you to read up more on the documentation on how the setup works.