Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Jasmine JavaScript Testing Update

You're reading from  Jasmine JavaScript Testing Update

Product type Book
Published in Apr 2015
Publisher
ISBN-13 9781785282041
Pages 134 pages
Edition 1st Edition
Languages
Author (1):
Paulo Vitor Zacharias Ragonha Paulo Vitor Zacharias Ragonha
Profile icon Paulo Vitor Zacharias Ragonha

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 is a global Jasmine function used to define test contexts. When used as the first call in a spec, it creates a new test suite (a collection of test cases). It accepts two parameters, which are as follows:

  • The name of the test suite—in this case...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at AU $19.99/month. Cancel anytime}