简体   繁体   English

如何在不调用量角器中的后端服务的情况下测试登录页面?

[英]How to Test login page without calling Backend services in Protractor?

I have a login page which authenticates the user by sending a token from the backend.我有一个登录页面,它通过从后端发送令牌来对用户进行身份验证。 But I want to test my login page with protractor without calling backend service with a dummy token.但我想用量角器测试我的登录页面,而不用虚拟令牌调用后端服务。 How to do that??怎么做??

You need to use spyON , here what we do is, we won't make any API calls.您需要使用spyON ,在这里我们所做的是,我们不会进行任何 API 调用。 Instead we will spy and return a mock data.相反,我们将监视并返回模拟数据。 Example:例子:

spyOn(someObj, 'func').and.returnValue(42);

You can refer below links for more details:您可以参考以下链接了解更多详情:

https://jasmine.github.io/api/edge/Spy.html https://jasmine.github.io/api/edge/Spy.html

https://scriptverse.academy/tutorials/jasmine-spyon.html https://scriptverse.academy/tutorials/jasmine-spyon.html

Hope this will help.希望这会有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM