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 price paid
- Given an investment, it should have a cost
Using the standalone distribution downloaded in the previous chapter, the first thing we need to do is 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 an InvestmentSpec.js
file and add the following lines:
describe("Investment", function() { });
The describe
function ...
Get Jasmine JavaScript Testing - Second Edition 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.