O'Reilly logo

Jasmine Cookbook by Munish Sethi

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

Writing your first Jasmine test

To write our first Jasmine test, we will use a program that will calculate the factorial of a given number.

"As a user, I want to validate/evaluate factorial functionality so that I can get the exact factorial value for a given number."

Let's consider some scenarios in the current context:

  • Scenario-1: Factorial value should be evaluated for a given positive number
  • Scenario-2: A 'null' value should be returned for negative numbers

Getting ready

To start writing Jasmine tests, you need to download Jasmine from the official website. Download the Jasmine Standalone release (that is, jasmine-standalone-2.x.x.zip) from the following website:

https://github.com/pivotal/jasmine/releases

How to do it...

To start a Jasmine test, ...

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