First, is our Page Object Class located in the app.po.ts file. There are two parts to writing an E2E test with Protractor. In the Angular Pokédex app repo, we have a few tests already created. In our Angular CLI project we have a folder named e2e. Let's take a look at a simple example of an E2E test. Jasmine is a testing library the provides all the assertion and utility functions needed to write unit and E2E tests. The test code itself is written using Jasmine. Protractor is an E2E test runner that can take scenario tests and run them in the browser for us like in the video above. Our E2E tests are powered by a testing library called Protractor. This scaffolding the Angular CLI provides includes unit tests and the setup needed for our E2E tests. The Angular CLI gives us all the functionality we need for scaffolding, building and testing our Angular applications. It extends webdriverJS functionalities on web applications. It tests your application running in a real world browser that interacts with its users. It is designed by Google developers on the top of webdriverJS for node.js program. The NG-Pokédex app is an Angular CLI app. Protractor is an end-to-end testing framework, is an open source automation for Angular and AngularJS applications. I slowed down the tests slightly, so it is visible that our tests are interacting with the browser. This short video clip shows an Angular E2E test automatically opening a browser and running through our tests to make sure our application is behaving correctly. Let's take a look at a running E2E test that tests this feature. We would like to write an E2E test to make sure this functionality works in our application. In our Pokédex app, the user can open a modal to see details about specific Pokémon and then use the arrow keys to navigate between Pokémon. Our E2E tests can open our app in the browser and interact with our app to make sure the feature works correctly. This is where an automated E2E test will be invaluable. For our app, we would want to make sure this core feature works every time we go to deploy our app. The NG-Pokédex app allows users to view and search Pokemon characters. We will use the Angular Pokédex app for our example. E2E tests but focus on how integration and E2E tests work in Angular. I won't dig into all the details of Unit tests vs. E2E tests are also ideal for making sure critical line of business features such as checkouts and sign-ups are well tested. Unit tests should test a small isolated piece of code while the E2E test is a high-level test of a feature or several interactions. Commonly we use E2E tests to help ensure our components are working correctly together to create an entirely functioning feature cohesively. End to end testing (E2E) or also known as integration testing is a great way to make sure at a high-level overview that our applications function correctly.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |