Introducing Jasmine

Karma is one of the most commonly used tools for test execution; it is compatible with many testing frameworks (such as Mocha, QUnit, and Jasmine). You can use it to test any JavaScript code, and it is highly recommended that you use some tool to test and perform automated testing on SPA.

In the following examples, we will be using Jasmine to write the tests and Karma to run the test. Jasmine has a very simple and easy writing syntax. Also, it is not dependent on any other framework. A basic example of writing tests looks like the following code:

describe("The test name", function() {
  it("contains spec with an expectation", function() {
    expect(true).toBe(true);
  });
});

describe() and it() are two functions. The describe() function ...

Get Learning Single-page Web Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.