firebase

Jasmine Unit Tests in an RxJs + Firebase app: Part 2

For today’s post, we’ll cover some useful test execution shortcuts and then dive into how to test code that uses AngularFire’s database.list.push() method to write data into the database.

Jasmine Test Execution Shortcuts

Part 1 covered describe and it, functions that are part of Jasmine that provide BDD-style tests. We looked at the following simple test:


describe("The Alert Helper", () => {

   // DI, setup, and beforeEach code elided

  it("should create an error alert with a provided message", () => {
    spyOn(AlertCtrlStub.prototype, "create").and.callThrough();

    alertHelper.triggerErrorAlert("This is a message!");

    expect(alertHelper.prototype.create).toHaveBeenCalledWith({
      message: "This is a message!",
      buttons: [
        {
          text: "Ok",
          role: "cancel",
        },
      ],
    });
  });

As you can see describe can be used to mark a suite of tests and each individual test can live in an it.

Now consider what happens when you build up enough tests in your application that it takes awhile for your entire test suite to run . . .

First impressions of TypeScript

For a few months I’ve spent a few hours here and there with TypeScript and Angular 2. I have a number of impressions and reactions. These range from “Microsoft made this?” to “This part is pretty good” to “Man, JavaScript sucks.” The last one is because I haven’t really touched Javascript for a few years and I got really comfortable with a concise, elegant language known as Scala.

If you want to see a really good example of why I don’t like JavaScript / TypeScript let me show you a snippet of something I commonly see in these codebases…