describe and specs
We have seen tests suites in many tools in the previous chapters. In Jasmine, we use describe
to start a test suite. describe
is a global function, which takes two parameters—a string and a function. The string is the title for the suite and function contains all of the tests implementations. A test in Jasmine is known as spec. The parameter function in the describe
function contains one or more specs. A spec is also defined by calling a global function it
, which takes two parameters just like describe
.
Let's take a look at the following code:
describe("Title of a Suite", function() { // variables available for all specs var amountToConvert; var rateOfConversion; // the function 'it' defines a spec it("Title of a Spec", function() { // do some testing here }); it("Another spec", function() { // do some testing here }); });
As seen from the preceding code, describe
defined a suite and specs were defined using it
. To make these...