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

Get Jasmine JavaScript Testing now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.