The Page Object Model pattern was a thing long before Protractor and even Testacular were ever created. POM is a design pattern for Selenium WebDriver, and it is basically a way to structure your e2e test code so that it is more maintainable, readable, and reusable. In Protractor, we code in JavaScript, but what we are doing is very similar to the code of various WebDriver languages; selecting things from the DOM. This DOM selection code comes up quite a lot, and the POM allows you to define variables in another file so they would only need to be changed in at most one place. Let's take a look at an example of protractor tests without the POM:
0 Comments
I've been struggling to wrap my head around how to not only test directives, but how to approach teaching others how to test directives. I've been working on this github page with examples of common AngularJS things and how to test them, and how could I even pretend the list was complete without covering directives? I was looking at two resources today that opened my eyes a little bit, and I'll try to convey what I learned in this post.
Before, I was making my directory structures way more complicated then they needed to be. I had a main "git repositories" folder, and then inside of that I would use mkdir to create a new folder for each project. Then I would cd inside of that and run:
If you are going to be doing a lot of work in a command prompt you then you should enjoy it. It should be easy to read in terms of size and colors. It should be practical and functional but still show off your own personal style.
It should be noted that you can be running your angular application locally and testing it in your browser (updating automatically when a file changes from good old browsersyc) while at the same time you have your tests runner (karma, in my case) running from the command line with autoWatch turned on. This is a fantastic way to develop. I have said many times that I feel browsersync spoils developers and leads them away from TDD and good testing, but actually browsersync can be pretty useful to have open as a sanity check with the unit tests as your main source of truth. Here's a meme that I created from the "Why not Both?" image:
|
AuthorThe posts on this site are written and maintained by Jim Lynch. About Jim...
Categories
All
Archives
March 2023
|