Ignition: Week 8

GIT & Unit Testing

Holy toledo! I just assumed that week 8 would be a nice transition week, not necessarily a breeze but certainly not what it was – pretty damn difficult. Now, there are a couple of factors that contributed to this week being difficult for me, such as:

  • Short on Time
  • A lot of new material

So, with this being the last week of Ignition, it was also my last chance to settle all of my affairs before heading to classes On-Campus. The last thing I want is to sacrifice precious in class time or 1on1 mentoring time to go settle some nonsense with the DMV.

As a result, Monday through Wednesday were completely shot in terms of being able to work on the week’s material. When I finally got around to looking through things on Thursday I realized that I was..er, screwed – mostly anyways.


First thing we learned was Git. It isn’t short for anything, that’s just the name. Git is a version control system used by developers to ‘save their progress’.

The ‘programs‘, if you want to call them that, that I have been working on thus far are pretty tiny. I mean, we’re talking about maybe 100 lines of code – tops. Real programs however, are likely to hit several hundreds if not thousands of lines of code spanning across multiple files and folders.

This is when Git becomes crucial to a project, if you screw something up you don’t need to spend weeks trying to rewrite code, you can just pull down your old code from the cloud and be done with it.

Having a strong understanding of how to use Git is going to pay dividends for sure. I would strongly recommend working with Git now to acclimate yourself to its commands. Get yourself an account on Github.com and familiarize yourself with all of its functions.

Unit Testing and the Jasmine Framework:

Second thing we learned was Unit Testing in Javascript using the Jasmine Framework. Being honest here, it was incredibly difficult for me for the first 4-5 hours of me looking at this. I felt like the documentation that was provided to us was seriously lacking and as a result, I found it very difficult to make sense of anything. Here is an example of what a Unit Test looks like.

This is the function being tested

What we have here is a function called ‘append‘. It takes 2 arguments arr and item the result of calling this function is that the argument for item gets appended (pushed) to the array passed as the first argument of the function (arr), and then the function ‘returns‘ the array in question (arr).

Now we need to test it. Testing allows us to create multiple scenarios that would mimic real world use and then use those as a way test the integrity of our programs. 

This is the test

Now, this may look like nonsense but if we start slow you will begin to get it.

Look at the beginning – it('you should be...

The (it)is our way of initializing the test. The test begins with (it). Then, inside of the parentheses is a string. In this case, ‘You should be able to add an item to the end of an array’. I will get to this later in the article, but this is essentially just a note you write to yourself describing the code to be tested and what it should be doing. This is then followed by a typical Javascript Function syntax (...of an array', () => {...) which leads into a code block inside the function.

In this code block we are assigning the result of calling the function ‘append‘ with the arguments of (a and 10) to a variable called result.

Now, pay attention, this is the meat and potatoes of how Unit Testing works. Following our variable result we have syntax that starts with expect. What expect does, is it runs the program with the given input (provided above). Think of it like when you write your code and you then head over to your console to test it out, same thing – except it’s isolated to this one example, and it’s returning a true or false boolean based on whether or not the function being tested fulfilled the parameters of the test.

In this case, we are saying with our expect syntax the following:

I expect the variable, result, to be equal to 10

Why is it  (result[result.length - 1])? Because, the function itself, takes in an array as an argument and then an integer as a second argument and then adds to that array the integer provided. Now, since the array we are creating is an empty array to begin with, we would expect that after adding 10 to that array, the [0] index of that array would equal 10. But, if we wanted to really test this function, we could create another array with other elements in it say,arr = [1,2,3,4,5]and then run it like this let result = append(arr, 10)then we could say the following:


expect(result.length).toBe(6) => We are expecting the new length to be 6

expect(result[result.length -1]).toBe(10) => We are expecting the last element to be 10

The tail end of our expect syntax has a .toBe(x). As you could probably already imagine, .toBe is just another way of saying === but in the syntax of Unit Testing.

Now the kinda cool part, you sync up a framework called, Jasmine to your file and then output all of your results to a webpage that displays it in something other than the ugly console that you always have to look at. As you create more tests you work you way down until your checklist is complete. It looks like this:


This is a visual representation of your test, you check this to make sure the test passed. If it didn’t go back to your test subject and make sure it is structured in such a way that it could universally pass. What I mean by this is that sometimes your functions do what you want them to do and you’re happy about this so you move on, but sometimes they do both what you want and what you DO NOT want them to do. The latter is the part we hope to eliminate through Unit Testing. Unit Testing allows you to be sure you are not getting false positives with your code, that could otherwise hamper you later on down the road.

Regex (Regular Expressions):

Damnit. Ugh. This was not fun. Not a little, not a lot. Not. At. All. 

Regular expressions or regex is a way to search through a given data set (string) and pull out specific information. Go ahead and press on your keyboard, CMD+F or Control+F. A search bar popped up right? That’s regex. Regex is your search box and then you send it into a data set to see if you can find any matches. Well, that sounds super easy, but what about the syntax? It fucking sucks. Pardon my broken French.


Huh? Yeah, that’s what I thought. This is, albeit a more complicated, regex that is searching for the following pattern (xxx-xxx-xxxx) where X = any integer between 0 and 9. 

Maybe it is just me, but this stuff was just so difficult to make work. Thankfully I found some really great resources to not only learn from but to practice with that I will link below, and I highly recommend them as they make things a lot more clear, even if it’s still confusing.

I am not going to breakdown all the components of regex because it is basically just an isolated and fancy syntax. That’s all it is, there isn’t any functions, classes methods or variables. You are simply defining a search term and then applying that search term to a given data set, like a string, or a whole host of strings.

Those were the 2 big things that we covered this week, but there were also a lot of different material that was scattered throughout. For instance, we learned about this stuff too:

I had a lot of difficulty with the markdown assignment. It was a little strange I thought, we were given no introduction to what it was, not even a hint and then came an assignment that said – Here is a link explaining what Markdown is, learn it and then come back and do this assignment. Really? I still don’t even know if it’s something that I’ll be using as a Developer in the future. No clue.

The rest are fairly straightforward but the bulk of this week’s difficulties came from the overwhelming amount of information being presented to us, and in the way it was presented. When you combine that with the seriously limited amount of time leftover for legit study once all commitments are taken care of, you have a recipe for stress and anxietynevertheless, once again all of my assignments were completed on time, despite my negative prognostications.

If you are looking to join Launch, or if you are already in Ignition but not at this point yet, I cannot recommend enough the need to drill on using Modules, Regex and Unit Testing. I would think that out of those 3 the most important and valuable would be Unit Testing. I just see so much potential there, not just for the integrity of your programs but it forces you into thinking about your code in a different way. When you are writing tests for your code, you are essentially trying to break it. When you think like this you can see flaws in your code, which will lead to more efficient refactoring and an overall better understanding of the concepts you are employing in the first place.

As for now? Time to go get some tasty Pho soup, write up a couple more blog drafts and try and get some sleep tonight, because Launch starts first thing in the morning tomorrow. Despite all of the hurdles and late night’s thus far, I am actually even more amped up to be learning in class. I know things will get even more difficult but I will be able to bounce ideas off of other people and really make sense of things in a way I wasn’t able to on my own – or at least do it quicker. So, stay tuned a buckle up because it’s going to be one hell of a ride!

One comment

Submit a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s