简体   繁体   中英

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. 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://scriptverse.academy/tutorials/jasmine-spyon.html

Hope this will help.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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