O'Reilly logo

Jasmine JavaScript Testing by Paulo Ragonha

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

Jasmine basics and thinking in BDD

Based on the application presented previously, we can start writing acceptance criteria that define investment:

  • Given an investment, it should be of a stock
  • Given an investment, it should have the invested shares quantity
  • Given an investment, it should have the share paid price
  • Given an investment, it should have a cost

And to start coding these as a Jasmine spec, the first thing we need to do, is to create a new spec file. This file can be created anywhere, but it is a good idea to stick to a convention, and Jasmine already has a good one: specs should be in the /spec folder. Create a spec/InvestmentSpec.js file and add the following lines:

describe("Investment", function() {

});

describe is a global Jasmine function ...

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