Reader small image

You're reading from  Jasmine JavaScript Testing Update

Product typeBook
Published inApr 2015
Reading LevelBeginner
Publisher
ISBN-139781785282041
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Paulo Vitor Zacharias Ragonha
Paulo Vitor Zacharias Ragonha
author image
Paulo Vitor Zacharias Ragonha

Paulo Ragonha is a software engineer with over 7 years of professional experience. An advocate of the open Web, he is inspired and driven to build compelling experiences on top of this ubiquitous platform. H e loves to hack, so you will often see him wandering around in conferences or attending hackathons. His most recent professional experiences ranged from DevOps (with Chef and Docker) to moving up the stack with Node.js, Ruby, and Python and all the way toward building single-page applications (mostly with Backbone.js and "ad hoc" solutions). Passionate about automation, he sees testing as a liberating tool to enjoy the craft of writing code even more. Back in 2013, he wrote the first edition of the book Jasmine JavaScript Testing, Packt Publishing. Paulo has an amazing wife, who he loves very much. He lives in beautiful Florianópolis, a coastal city in the south of Brazil. He is a casual speaker, a biker, a runner, and a hobbyist photographer.
Read more about Paulo Vitor Zacharias Ragonha

Right arrow

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 page is locked
Previous PageNext Page
You have been reading a chapter from
Jasmine JavaScript Testing Update
Published in: Apr 2015Publisher: ISBN-13: 9781785282041

Author (1)

author image
Paulo Vitor Zacharias Ragonha

Paulo Ragonha is a software engineer with over 7 years of professional experience. An advocate of the open Web, he is inspired and driven to build compelling experiences on top of this ubiquitous platform. H e loves to hack, so you will often see him wandering around in conferences or attending hackathons. His most recent professional experiences ranged from DevOps (with Chef and Docker) to moving up the stack with Node.js, Ruby, and Python and all the way toward building single-page applications (mostly with Backbone.js and "ad hoc" solutions). Passionate about automation, he sees testing as a liberating tool to enjoy the craft of writing code even more. Back in 2013, he wrote the first edition of the book Jasmine JavaScript Testing, Packt Publishing. Paulo has an amazing wife, who he loves very much. He lives in beautiful Florianópolis, a coastal city in the south of Brazil. He is a casual speaker, a biker, a runner, and a hobbyist photographer.
Read more about Paulo Vitor Zacharias Ragonha