Let's talk about unit tests and directory structure. If you're doing it right you're going to be creating at least one test file for every JavaScript file you create so it's a given that there are going to be quite a lot of tests. Where do you put all of these tests? There are basically 2 schools of thought here. In this post I'll explain the two theories and then put forth an argument for why you should be putting unit tests in your src folder.
0 Comments
I woke up very hung over this morning and started thinking about how I was going to the solve the issue of button pressed states not working properly on touch devices in the corporate container app for my current work project. I had googled a lot for it already, but this time I decided to try to google for videos. I came across this video. Honestly, he doesn't talk much about touch device specific things here; it just has Touch Screen in the title because the actual project was meant to run on that giant touch panel on the left there in the video preview. However, I still enjoyed this video and liked getting inside of this guy's head. He reports directly tot he CEO of his company he's in charge of basically all aspects of building the software and getting it out so you know that he has successfully completed at least a few projects (although he admits that he is pretty new to AngularJS). Overall he gives some insight on thinking about custom directives (although he has a weird style where inside of the .directive() he just returns basically the equivalent of the link function, but nothing is labeled in the way you might be used to seeing directives). He also does some other weird things like using Coffeescript, Haml, and he talks about the yeoman seed project as if there's only one. hehe. But weirdness aside, it's a good video, and you should give it a watch.
I'm sitting in the Houston intercontinental airport right now waiting for my connecting flight back home, and I'm just reflecting on everything I did and saw this past week. I had never been to California before, and I was able to experience a ton of stuff while still somehow thinking about coding the entire time. :)
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.
Brandon Braithwaite is a developer from the UK with a solid TDD background and deep knowledge of unit testing so naturally his blog is a great place to learn about unit testing for your Angular projects. In particular, this is a great page with tons of links:
http://www.bradoncode.com/tutorials/angularjs-unit-testing/ |
AuthorThe posts on this site are written and maintained by Jim Lynch. About Jim...
Categories
All
Archives
March 2023
|