This article mainly introduces e2e testing instances in angularjs. This article uses Protractor to complete e2e testing. For more information, see ng unit testing in the previous article, today we will talk about e2e (end-to-end) testing.
When we test a single function point of a module, unit testing is the most suitable. However, when users encounter a bug when performing multiple page interactions, unit testing will not work, at this time, e2e is used to simulate user operations to restore the problem site. of course, e2e testing can also be used to test program robustness. Many tasks that cannot be done by unit testing can be done by e2e testing.
Previously, ng used Angular Scenario Runner to run e2e testing. Now it has been replaced with Protractor to run e2e.
Protractor
Protractor is the framework used to test e2e in Angularjs. It is an npm module and is built on WebDriverJS internally. Protractor can truly run your test cases on the browser, completely simulate the real user behavior.
The following are some of its resource addresses:
1. Test api provided by Protractor
2. Simple Example of Protractor
3. WebDriverJs guide, which is the core of Protractor dependency. The npm module is named selenium-webdriver.
How Protractor works
Protractor runs the e2e test on the following items:
1. WebDriver APIs, WebDriverJs mentioned above, is a js api provided by Selenium for front-end testing.
2. Selenium Server, a back-end jar package, used to communicate with the browser driver
3. WebDriver browser drivers is used to display the content of a real website and communicate with Selenium Server. This is where the actual browser operations are transmitted.
The entire running process is as follows:
Want to know