O'Reilly logo

Mastering AngularJS for .NET Developers by Mohammad Wadood Majid, Golrokh Mirzaei

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Unit testing using Jasmine

Jasmine is an open source framework, which is the most popular choice for unit testing of AngularJS applications. Jasmine is a framework for JavaScript test driven development. Jasmine provides functions and assertions to structure the test. Jasmine can be executed on any JavaScript-enabled framework, as it does not require any integrated development environment (IDE).

The Jasmine framework is informal to read. Let's assume that we have a helloWorld() function for which we want to write a test using Jasmine. The following is the unit test code:

describe('Hello world', function() {

  it('says hello', function() {

    expect(helloWorld()).toEqual("Hello world!");

  });

});

In the preceding code the describe() function is known as ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required