Posts

How to Mock JSNLog in Jasmine Unit Tests of Angular Code

One of the development teams at work implemented JSNLog to log from JavaScript in an Angular application we're working on, but even though the documentation to get this set up and running was very clear, the way to get it mocked for unit testing was not.

Fortunately, it's not too difficult. The key in getting this to work was to spy on the JL function and have it return a mock with spy methods for the different logging methods (debug(), trace(), etc). Then set it up in your providers declaration.

Here's the mock object:

exportclassJLMock {     trace = jasmine.createSpy('trace');     debug = jasmine.createSpy('debug');     info = jasmine.createSpy('info');     warn = jasmine.createSpy('warn');     error = jasmine.createSpy('error');     fatal = jasmine.createSpy('fatal'); }
In your spec, instantiate an instance of that and then spy on the JL function and return that instance:
let jlMock = new JLMock(); let JL = jasmine.createSpy…

W. T. Grant’s A Very Merry Christmas

Image
I didn’t have a very happy childhood, but some of my fondest memories from when I was young, memories which I cherish, are of baking Christmas cookies with my mother. I was in my early school days, starting around kindergarten or maybe before. I remember rolling out the dough on a round table in our kitchen and using cutouts to make the cookies we would then decorate. Thinking about it now, these are probably my happiest childhood memories.

While we’d be making the cookies, my mother would play Christmas music from some old records. They were compilation albums from the 1960s featuring artists of the day performing traditional Christmas songs. To this day it remains my favorite kind of Christmas music. In the years since then, I remembered two album covers specifically: one was a white cover featuring round Christmas tree ornaments with pictures of contemporary stars like Jim Nabors and Johnny Mathis, who appeared on the album, inside the ornaments; the other, which I was sure was ca…

Retro Review: The Mummy's Ghost

Image
Synopsis
The Mummy terrorizes New England. Again. Wash, rinse, repeat.

Review
This movie is almost an exact copy of the previous film, The Mummy's Tomb, which I enjoyed (read my review here -- shameless plug). So why didn't I like this one?

For starters, I didn't find any of the characters likable. The plot was too similar to the previous film -- I was hoping for something different this time around. This was just more of the same. There's an additional plot twist this time around, with the main character (Biff? Joe? Butch?) having a girlfriend of Egyptian descent who has a strange connection to the Mummy and (SPOILER) is the reincarnation of the Mummy's old love...which was part of he plot of the original film.

It did have an ending I didn't expect. I'll give it that much.

It just felt like a rehash. Also, I'm not sure why it was called The Mummy's Ghost. Unless I missed something, he was just the same old undead Mummy we'd seen in the previous …

Retro Review: Bride of Frankenstein

Image
Synopsis
The villagers thought they destroyed the monster, but they were wrong. As he makes his way through the countryside, Dr. Frankenstein’s mentor returns, on a quest to once again create new life.

Review
I enjoyed this film more than the original. Even though it’s titled Bride of Frankenstein (though the poster and advertising refer to it as The Bride of Frankenstein), the movie is about much more than that. We see the monster grow and develop. He becomes a sympathetic character. Meanwhile, Frankenstein’s former mentor Dr. Pretorius arrives at the castle and shows Henry Frankenstein the life forms he’s created, which I found to be unexpected. It was an odd turn for the film, but one that isn’t lingered on. The ending is a little predictable, but also has an unexpected bit of heart to it. I found this one to be an enjoyable entry Universal’s series of monster films.

Retro Review: The Mummy's Tomb

Image
Synopsis
30 years after the events of the previous film, Steve Banning is telling his house guests about the undead mummy he and Babe Jensen (now named Babe Hanson for some reason) battled in Egypt all those years ago. But unbeknownst to any of them, the villains from the previous film survived and have waited 30 years (again, for some reason) to plot their revenge.

Review
Now we're talkin'. I found the original 1932 The Mummy to be tedious (and lacking in much mummy, ironically), and found the sequel, 1940s The Mummy's Hand to be an improvement, but still...lacking much of the mummy. However, this time around he gets plenty of screen time and the plot moves at a quicker pace.

I found the timing to be too coincidental: Steve is telling his guests about the mummy, and miles away in Egypt, the plot for revenge is being hatched. What timing. And yes, that's the part I find unbelievable, and not that an ancient mummy walks the earth! But I digress.

The film takes some inter…

Universal Monsters and Retro Review: The Mummy's Hand

Image
I've only recently become a fan of the old Universal monster movies. My interest was first piqued a long time ago by one of my favorite retro video games, Zombies Ate My Neighbors, with its extensive use of classic monster movie imagery. But only in the past two years have I begun going through those old films. And while they're not specific to Halloween, so closely has this imagery been associated with the season that they may as well be Halloween movies for me, and that's when I watch them.

These films tend to run a little over an hour, which is obviously very short for a film by today's standards. And even though they're quite old, I was surprised by how well some of them still hold up. For example, I think House of Frankenstein is a great film.

I recently watched The Mummy's Hand, which is the first sequel to 1932's The Mummy. Even though that film is considered a horror classic, I don't care much for it, as I found it extremely slow and not having…

How Unit Tests Have Helped Me Write Better Code

Image
I am not perfect. This fact alone supports the need to do my due diligence when it comes to the code I write to make sure it does what it's supposed to, without unintended side-effects, in the most efficient, and extensible, way possible.
Rather than say why I think developers should write unit tests, I will instead describe how I've benefited from them.
PROLOGUE A number of years back, I worked with a lead developer who had a wide breadth of technical knowledge and whom I considered highly intelligent, perhaps even borderline brilliant. He was (and is) a smart individual, but he saw no use in unit tests. He told me that when he first started working for the company, one of the first things he did was to delete all the unit tests, and he even tried to convince me that the practice of writing unit tests was now being considered a thing of the past, and told me he'd forward me a link to an article he'd read stating as much.
I try to keep an open mind, but in this case I wasn…