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 . . .

Tutorial: Full-Stack Web Application Development on Tomcat, Part 2

Part 2 of my tutorial series on how to use Eclipse IDE, Tomcat, Java EE, HTML, CSS, JQuery, MustacheJS, and H2 database together to implement a modern web application.

hydrogen_23413_sm

Part two of the tutorial series is now available! The application that you will build in the tutorial is a simple search on the periodic table of the elements that returns a box from the table based on the atomic number, the name, or the symbol. Should be fun!

If you have not gone through part one yet, start there!

Tutorial: Full-Stack Web Application Development on Tomcat, Part 1

I will be posting a tutorial series on how to use Eclipse IDE, Tomcat, Java EE, HTML, CSS, JQuery, MustacheJS, and H2 database together to implement a modern web application.

chemistry1

I say “modern web application” because it uses JS templating and AJAX rather than a server-side MVC framework. This came up because I was trying to think of a good example of what I was talking about in the “Leverage” post from a few days ago. It occurred to me that actually offering a tutorial on this stuff could be valuable. In order to make the most barebones application possible, I chose the most lightweight stuff I could find which happens to be Tomcat, Mustache, and H2 database.

Part one of the tutorial series is now available! The application that you will build in the tutorial is a simple search on the periodic table of the elements that returns a box from the table based on the atomic number, the name, or the symbol. That’s why I chose the chemistry set image that is shown here. Should be fun!